Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ typedef struct
array_t *results; ///< All results.
char *scan_end; ///< End time for a scan.
char *scan_start; ///< Start time for a scan.
char *task_id; ///< ID of container task.
char *task_id; ///< ID of import task.
char *type; ///< Type of report.
int wrapper; ///< Whether there was a wrapper REPORT.
} create_report_data_t;
Expand Down Expand Up @@ -19859,7 +19859,7 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error)
}
else
{
/* Container tasks have no associated scanner. */
/* Import tasks have no associated scanner. */
task_scanner_uuid = g_strdup ("");
task_scanner_name = g_strdup ("");
task_scanner_type = 0;
Expand Down Expand Up @@ -23781,7 +23781,7 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context,
case -5:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_report",
"TASK must be a container"));
"TASK must be an import task"));
log_event_fail ("report", "Report", NULL, "created");
break;
case -6:
Expand Down Expand Up @@ -24987,7 +24987,7 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context,
&& !is_agent_task
&& !is_container_scanning_task)
{
/* Container task. */
/* Import task. */

set_task_target (create_task_data->task, 0);
set_task_usage_type (create_task_data->task,
Expand Down Expand Up @@ -27997,7 +27997,7 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context,
case 17:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_task",
"For container tasks only name, comment"
"For import tasks only name, comment"
" and observers can be modified"));
log_event_fail ("task", "Task",
modify_task_data->task_id,
Expand Down Expand Up @@ -28796,7 +28796,7 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context,
"started");
break;
case -2:
/* Task lacks target. This is true for container
/* Task lacks target. This is true for Import
* tasks. */
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("start_task",
Expand Down
2 changes: 1 addition & 1 deletion src/manage_pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ manage_create_sql_functions ()
/* Get trend only for authenticated users. */
" WHEN gvmd_user () = 0"
" THEN RETURN ''::text;"
/* Skip running and container tasks. */
/* Skip running and import tasks. */
" WHEN (SELECT run_status = %u OR target = 0"
" FROM tasks WHERE id = $1)"
" THEN RETURN ''::text;"
Expand Down
8 changes: 4 additions & 4 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -7828,7 +7828,7 @@ task_severity_double (task_t task, int overrides, int min_qod, int offset)
report_t report;

if (current_credentials.uuid == NULL
|| task_target (task) == 0 /* Container task. */)
|| task_target (task) == 0 /* import task. */)
return SEVERITY_MISSING;

report = sql_int64_0 ("SELECT id FROM reports"
Expand Down Expand Up @@ -9927,7 +9927,7 @@ process_report_import (report_t report)
* @brief Create a report from an array of results.
*
* @param[in] results Array of create_report_result_t pointers.
* @param[in] task_id UUID of container task, or NULL to create new one.
* @param[in] task_id UUID of import task, or NULL to create new one.
* @param[in] in_assets Whether to create assets from the report.
* @param[in] scan_start Scan start time text.
* @param[in] scan_end Scan end time text.
Expand All @@ -9940,7 +9940,7 @@ process_report_import (report_t report)
*
* @return 0 success, 99 permission denied, -1 error, -2 failed to generate ID,
* -3 task_id is NULL, -4 failed to find task, -5 task must be
* container, -6 permission to create assets denied.
* import task, -6 permission to create assets denied.
*/
int
create_report (array_t *results, const char *task_id, const char *in_assets,
Expand Down Expand Up @@ -20820,7 +20820,7 @@ DEF_ACCESS (task_file_iterator_content, 1);
* alterable state, 10 failed to find group, 11 failed to find schedule,
* 12 failed to find target, 13 invalid auto_delete value, 14 auto
* delete count out of range, 15 config and scanner types mismatch,
* 16 status must be new to edit target, 17 for container tasks only
* 16 status must be new to edit target, 17 for import tasks only
* certain fields may be edited, 18 failed to find agent group,
19 failed to find OCI image target, -1 error.
*/
Expand Down
34 changes: 26 additions & 8 deletions src/manage_sql_filters.c
Original file line number Diff line number Diff line change
Expand Up @@ -1188,9 +1188,15 @@ filter_clause (const char* type, const char* filter,
g_string_append_printf
(order,
" ORDER BY"
" (CASE WHEN (SELECT target = 0 FROM tasks"
" (CASE WHEN (SELECT "
" ( "
" target = 0 "
" and COALESCE( agent_group, 0) = 0 "
" and COALESCE( oci_image_target, 0) = 0"
" ) "
" FROM tasks"
" WHERE tasks.id = task)"
" THEN 'Container'"
" THEN '0'"
" ELSE run_status_name (scan_run_status)"
" || (SELECT CAST (temp / 100 AS text)"
" || CAST (temp / 10 AS text)"
Expand All @@ -1204,8 +1210,11 @@ filter_clause (const char* type, const char* filter,
g_string_append_printf
(order,
" ORDER BY"
" (CASE WHEN target = 0"
" THEN 'Container'"
" (CASE WHEN ( target = 0 "
" and COALESCE( agent_group, 0) = 0 "
" and COALESCE( oci_image_target, 0) = 0"
" ) "
" THEN '0'"
" ELSE run_status_name (run_status)"
" || (SELECT CAST (temp / 100 AS text)"
" || CAST (temp / 10 AS text)"
Expand Down Expand Up @@ -1384,9 +1393,15 @@ filter_clause (const char* type, const char* filter,
g_string_append_printf
(order,
" ORDER BY"
" (CASE WHEN (SELECT target = 0 FROM tasks"
" (CASE WHEN (SELECT "
" ( "
" target = 0 "
" and COALESCE( agent_group, 0) = 0 "
" and COALESCE( oci_image_target, 0) = 0"
" ) "
" FROM tasks"
" WHERE tasks.id = task)"
" THEN 'Container'"
" THEN '0'"
" ELSE run_status_name (scan_run_status)"
" || (SELECT CAST (temp / 100 AS text)"
" || CAST (temp / 10 AS text)"
Expand All @@ -1400,8 +1415,11 @@ filter_clause (const char* type, const char* filter,
g_string_append_printf
(order,
" ORDER BY"
" (CASE WHEN target = 0"
" THEN 'Container'"
" (CASE WHEN ( target = 0 "
" and COALESCE( agent_group, 0) = 0 "
" and COALESCE( oci_image_target, 0) = 0"
" ) "
" THEN '0'"
" ELSE run_status_name (run_status)"
" || (SELECT CAST (temp / 100 AS text)"
" || CAST (temp / 10 AS text)"
Expand Down
20 changes: 10 additions & 10 deletions src/schema_formats/XML/GMP.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -6400,14 +6400,14 @@ END:VCALENDAR
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
When given a target with an id of 0, the command creates an
"import" 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,
When creating an import task, the elements config, hosts_ordering,
scanner, alert, schedule, schedule_periods, observers and preferences
are ignored.
</p>
Expand Down Expand Up @@ -6644,10 +6644,10 @@ END:VCALENDAR
</response>
</example>
<example>
<summary>Create a container task, for importing reports</summary>
<summary>Create an import task, for importing reports</summary>
<request>
<create_task>
<name>Container Example</name>
<name>Import Example</name>
<comment>This task provides for importing reports</comment>
<target id="0"/>
</create_task>
Expand Down Expand Up @@ -25898,9 +25898,9 @@ END:VCALENDAR
that the manager applied when selecting the tasks.
</p>
<p>
A task may be a "container" task. This means the task may not be
A task may be an "import" 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
create_report. Import tasks are identified by having an empty
id attribute in the target element.
</p>
</description>
Expand Down Expand Up @@ -26442,7 +26442,7 @@ END:VCALENDAR
<name>id</name>
<type>uuid</type>
<required>1</required>
<summary>ID of target. Empty for container tasks</summary>
<summary>ID of target. Empty for import tasks</summary>
</attrib>
<e>name</e>
<o><e>permissions</e></o>
Expand Down Expand Up @@ -27185,7 +27185,7 @@ END:VCALENDAR
</response>
</example>
<example>
<summary>Get a single container task</summary>
<summary>Get a single import task</summary>
<request>
<get_tasks task_id="f404781f-6d2b-420c-b7a1-0d3f27f1a43b">
</get_tasks>
Expand All @@ -27197,7 +27197,7 @@ END:VCALENDAR
<owner>
<name>m</name>
</owner>
<name>Container Example</name>
<name>Import Example</name>
<comment>This task provides for uploading reports</comment>
<creation_time>2019-08-13T12:28:43+02:00</creation_time>
<modification_time>
Expand Down
Loading