Skip to content

Commit

Permalink
Merge branch 'master' into tls-setting
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmundell authored Aug 15, 2019
2 parents 737cd0a + 7f3ce72 commit 4fa90b5
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 43 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Cgreen based unit tests for gvmd has been added. [#579](https://github.com/greenbone/gvmd/pull/579)
- New usage_type property to distinguish normal scan tasks and configs from compliance audits and policies [#613](https://github.com/greenbone/gvmd/pull/613) [#625](https://github.com/greenbone/gvmd/pull/625) [#633](https://github.com/greenbone/gvmd/pull/633)
- Command cleanup-report-formats for --optimize option [#652](https://github.com/greenbone/gvmd/pull/652)
- Document container tasks in GMP doc [#688](https://github.com/greenbone/gvmd/pull/688)

### Changed
- Check if NVT preferences exist before inserting. [#406](https://github.com/greenbone/gvmd/pull/406)
Expand All @@ -31,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Update result diff generation at delta reports [#650](https://github.com/greenbone/gvmd/pull/650)
- Check and create default permissions individually [#671](https://github.com/greenbone/gvmd/pull/671)
- Add -f arg to sendmail call in email alert [#676](https://github.com/greenbone/gvmd/pull/676) [#678](https://github.com/greenbone/gvmd/pull/678)
- Change get_tickets to use the status text for filtering. [#697](https://github.com/greenbone/gvmd/pull/697)

### Fixed
- A PostgreSQL statement order issue [#611](https://github.com/greenbone/gvmd/issues/611) has been addressed [#642](https://github.com/greenbone/gvmd/pull/642)
Expand All @@ -41,6 +43,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix RAW_DATA when calling GET_INFO with type NVT without attributes name or info_id [#682](https://github.com/greenbone/gvmd/pull/682)
- Fix ORPHAN calculations in GET_TICKETS [#684](https://github.com/greenbone/gvmd/pull/684) [#692](https://github.com/greenbone/gvmd/pull/692)
- Fix assignment of orphaned tickets to the current user [#685](https://github.com/greenbone/gvmd/pull/685)
- Fix response from GET_VULNS when given vuln_id does not exists [#696](https://github.com/greenbone/gvmd/pull/696)

### Removed
- The handling of NVT updates via OTP has been removed. [#575](https://github.com/greenbone/gvmd/pull/575)
Expand Down
38 changes: 30 additions & 8 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -19163,15 +19163,37 @@ handle_get_vulns (gmp_parser_t *gmp_parser, GError **error)
INIT_GET (vuln, Vulnerabilitie);

ret = init_vuln_iterator (&vulns, get);
switch (ret)
if (ret)
{
case 0:
break;
default:
internal_error_send_to_client (error);
get_vulns_data_reset (get_vulns_data);
set_client_state (CLIENT_AUTHENTIC);
return;
switch (ret)
{
case 1:
if (send_find_error_to_client ("get_vulns",
"vuln",
get_vulns_data->get.id,
gmp_parser))
{
error_send_to_client (error);
return;
}
break;
case 2:
if (send_find_error_to_client
("get_vulns", "filter",
get_vulns_data->get.filt_id, gmp_parser))
{
error_send_to_client (error);
return;
}
break;
case -1:
SEND_TO_CLIENT_OR_FAIL
(XML_INTERNAL_ERROR ("get_vulns"));
break;
}
get_vulns_data_reset (get_vulns_data);
set_client_state (CLIENT_AUTHENTIC);
return;
}

SEND_GET_START ("vuln");
Expand Down
52 changes: 17 additions & 35 deletions src/manage_sql_tickets.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,31 +79,6 @@ ticket_status_integer (const char *status)
return TICKET_STATUS_ERROR;
}

/**
* @brief Get ticket status name from DB identifier.
*
* @param[in] status Status integer.
*
* @return Status name.
*/
static const gchar *
ticket_status_name (ticket_status_t status)
{
switch (status)
{
case TICKET_STATUS_OPEN:
return "Open";
case TICKET_STATUS_FIXED:
return "Fixed";
case TICKET_STATUS_FIX_VERIFIED:
return "Fix Verified";
case TICKET_STATUS_CLOSED:
return "Closed";
default:
return "Error";
}
}

/**
* @brief Filter columns for ticket iterator.
*/
Expand Down Expand Up @@ -157,7 +132,14 @@ ticket_status_name (ticket_status_t status)
{ "host", NULL, KEYWORD_TYPE_STRING }, \
{ "location", NULL, KEYWORD_TYPE_STRING }, \
{ "solution_type", NULL, KEYWORD_TYPE_STRING }, \
{ "status", NULL, KEYWORD_TYPE_STRING }, \
{ "(CASE status" \
" WHEN 0 THEN 'Open'" \
" WHEN 1 THEN 'Fixed'" \
" WHEN 2 THEN 'Fix Verified'" \
" WHEN 3 THEN 'Closed'" \
" ELSE 'Error' END)", \
"status", \
KEYWORD_TYPE_STRING }, \
{ "iso_time (open_time)", NULL, KEYWORD_TYPE_STRING }, \
{ "open_time", "opened", KEYWORD_TYPE_INTEGER }, \
{ "iso_time (fixed_time)", NULL, KEYWORD_TYPE_STRING }, \
Expand Down Expand Up @@ -226,7 +208,14 @@ ticket_status_name (ticket_status_t status)
{ "host", NULL, KEYWORD_TYPE_STRING }, \
{ "location", NULL, KEYWORD_TYPE_STRING }, \
{ "solution_type", NULL, KEYWORD_TYPE_STRING }, \
{ "status", NULL, KEYWORD_TYPE_STRING }, \
{ "(CASE status" \
" WHEN 0 THEN 'Open'" \
" WHEN 1 THEN 'Fixed'" \
" WHEN 2 THEN 'Fix Verified'" \
" WHEN 3 THEN 'Closed'" \
" ELSE 'Error' END)", \
"status", \
KEYWORD_TYPE_STRING }, \
{ "iso_time (open_time)", NULL, KEYWORD_TYPE_STRING }, \
{ "open_time", "opened", KEYWORD_TYPE_INTEGER }, \
{ "iso_time (fixed_time)", NULL, KEYWORD_TYPE_STRING }, \
Expand Down Expand Up @@ -391,14 +380,7 @@ DEF_ACCESS (ticket_iterator_solution_type, GET_ITERATOR_COLUMN_COUNT + 6);
*
* @return Status of the ticket or NULL if iteration is complete.
*/
const char*
ticket_iterator_status (iterator_t* iterator)
{
int status;
if (iterator->done) return NULL;
status = iterator_int (iterator, GET_ITERATOR_COLUMN_COUNT + 7);
return ticket_status_name (status);
}
DEF_ACCESS (ticket_iterator_status, GET_ITERATOR_COLUMN_COUNT + 7);

/**
* @brief Get column value from a ticket iterator.
Expand Down
137 changes: 137 additions & 0 deletions src/schema_formats/XML/GMP.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -5777,6 +5777,18 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
<p>
The client uses the create_task command to create a new task.
</p>
<p>
When given a target with an id of 0, the command creates a
"container" task. This kind of task can not be run, but it
is possible to import reports into the task. Importing is
done using the create_report command. The report being
imported must be in the XML format.
</p>
<p>
When creating a container task, the elements config, hosts_ordering,
scanner, alert, schedule, schedule_periods, observers and preferences
are ignored.
</p>
</description>
<pattern>
<e>name</e>
Expand Down Expand Up @@ -5963,6 +5975,22 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
</create_task_response>
</response>
</example>
<example>
<summary>Create a container task, for importing reports</summary>
<request>
<create_task>
<name>Container Example</name>
<comment>This task provides for importing reports</comment>
<target id="0"/>
</create_task>
</request>
<response>
<create_task_response status="201"
status_text="OK, resource created"
id="b7f0afbe-bdb3-11e9-9847-28d24461215b">
</create_task_response>
</response>
</example>
</command>
<command>
<name>create_ticket</name>
Expand Down Expand Up @@ -20408,6 +20436,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
the values of the sort order, sort field and apply overrides flag
that the manager applied when selecting the tasks.
</p>
<p>
A task may be a "container" task. This means the task may not be
run, but reports may be uploaded to the task with the command
create_report. Container tasks are identified by having an empty
id attribute in the target element.
</p>
</description>
<pattern>
<attrib>
Expand Down Expand Up @@ -20899,6 +20933,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
<name>id</name>
<type>uuid</type>
<required>1</required>
<summary>ID of target. Empty for container tasks</summary>
</attrib>
<e>name</e>
<o><e>permissions</e></o>
Expand Down Expand Up @@ -21624,6 +21659,108 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
</get_tasks_response>
</response>
</example>
<example>
<summary>Get a single container task</summary>
<request>
<get_tasks task_id="f404781f-6d2b-420c-b7a1-0d3f27f1a43b">
</get_tasks>
</request>
<response>
<get_tasks_response status="200" status_text="OK">
<apply_overrides>0</apply_overrides>
<task id="f404781f-6d2b-420c-b7a1-0d3f27f1a43b">
<owner>
<name>m</name>
</owner>
<name>Container Example</name>
<comment>This task provides for uploading reports</comment>
<creation_time>2019-08-13T12:28:43+02:00</creation_time>
<modification_time>
2019-08-13T12:28:44+02:00</modification_time>
<writable>1</writable>
<in_use>0</in_use>
<permissions>
<permission>
<name>Everything</name>
</permission>
</permissions>
<alterable>0</alterable>
<usage_type>scan</usage_type>
<config id="">
<name></name>
<type>-1</type>
<trash>0</trash>
</config>
<target id="">
<name></name>
<trash>0</trash>
</target>
<hosts_ordering></hosts_ordering>
<scanner id=''>
<name></name>
<type>0</type>
<trash>0</trash>
</scanner>
<status>Done</status>
<progress>-1</progress>
<report_count>1
<finished>1</finished></report_count>
<trend></trend>
<schedule id="">
<name></name>
<next_time>over</next_time>
<trash>0</trash>
</schedule>
<last_report>
<report id="5496f417-9b3b-4582-b450-c05ca99009d8">
<timestamp>2019-08-13T12:29:25+02:00</timestamp>
<scan_start>2019-04-24T14:26:01+02:00</scan_start>
<scan_end>2019-04-24T14:50:59+02:00</scan_end>
<result_count>
<debug>0</debug>
<hole>1</hole>
<info>0</info>
<log>77</log>
<warning>8</warning>
<false_positive>0</false_positive>
</result_count>
<severity>9.0</severity>
</report>
</last_report>
<observers></observers>
<preferences>
<preference>
<name>Maximum concurrently executed NVTs per host</name>
<scanner_name>max_checks</scanner_name>
<value>4</value>
</preference>
<truncated>...</truncated>
</preferences>
</task>
<filters id="">
<term>apply_overrides=0 min_qod=70
uuid=f404781f-6d2b-420c-b7a1-0d3f27f1a43b first=1 rows=10
sort=name</term>
<keywords>
<keyword>
<column>apply_overrides</column>
<relation>=</relation>
<value>0</value>
</keyword>
<truncated>...</truncated>
</keywords>
</filters>
<sort>
<field>name
<order>ascending</order></field>
</sort>
<tasks start="1" max="10" />
<task_count>21
<filtered>1</filtered>
<page>1</page></task_count>
</get_tasks_response>
</response>
</example>
</command>
<command>
<name>get_tickets</name>
Expand Down

0 comments on commit 4fa90b5

Please sign in to comment.