Skip to content

Commit

Permalink
Merge pull request #823 from janowagner/drop_modify_report_command
Browse files Browse the repository at this point in the history
Drop "modify_report" GMP command
  • Loading branch information
mattmundell authored Nov 18, 2019
2 parents 2649fc1 + 04cab8a commit adf4f9d
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 225 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Removed
- Remove support for "All SecInfo": removal of "allinfo" for type in get_info [#790](https://github.com/greenbone/gvmd/pull/790)
- Removed tag_value() by using nvti_get_tag() [#825](https://github.com/greenbone/gvmd/pull/825)
- Remove support for "MODIFY_REPORT" GMP command [#823](https://github.com/greenbone/gvmd/pull/823)

[20.4]: https://github.com/greenbone/gvmd/compare/v9.0.0...master

Expand Down
107 changes: 0 additions & 107 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3191,29 +3191,6 @@ modify_port_list_data_reset (modify_port_list_data_t *data)
memset (data, 0, sizeof (modify_port_list_data_t));
}

/**
* @brief Command data for the modify_report command.
*/
typedef struct
{
char *comment; ///< Comment.
char *report_id; ///< ID of report to modify.
} modify_report_data_t;

/**
* @brief Reset command data.
*
* @param[in] data Command data.
*/
static void
modify_report_data_reset (modify_report_data_t *data)
{
free (data->comment);
free (data->report_id);

memset (data, 0, sizeof (modify_report_data_t));
}

/**
* @brief Command data for the modify_report_format command.
*/
Expand Down Expand Up @@ -4011,7 +3988,6 @@ typedef union
modify_group_data_t modify_group; ///< modify_group
modify_permission_data_t modify_permission; ///< modify_permission
modify_port_list_data_t modify_port_list; ///< modify_port_list
modify_report_data_t modify_report; ///< modify_report
modify_report_format_data_t modify_report_format; ///< modify_report_format
modify_role_data_t modify_role; ///< modify_role
modify_scanner_data_t modify_scanner; ///< modify_scanner
Expand Down Expand Up @@ -4557,12 +4533,6 @@ static modify_permission_data_t *modify_permission_data
static modify_port_list_data_t *modify_port_list_data
= &(command_data.modify_port_list);

/**
* @brief Parser callback data for MODIFY_REPORT.
*/
static modify_report_data_t *modify_report_data
= &(command_data.modify_report);

/**
* @brief Parser callback data for MODIFY_REPORT_FORMAT.
*/
Expand Down Expand Up @@ -5213,8 +5183,6 @@ typedef enum
CLIENT_MODIFY_PORT_LIST,
CLIENT_MODIFY_PORT_LIST_COMMENT,
CLIENT_MODIFY_PORT_LIST_NAME,
CLIENT_MODIFY_REPORT,
CLIENT_MODIFY_REPORT_COMMENT,
CLIENT_MODIFY_REPORT_FORMAT,
CLIENT_MODIFY_REPORT_FORMAT_ACTIVE,
CLIENT_MODIFY_REPORT_FORMAT_NAME,
Expand Down Expand Up @@ -6645,12 +6613,6 @@ gmp_xml_handle_start_element (/* unused */ GMarkupParseContext* context,
&modify_permission_data->permission_id);
set_client_state (CLIENT_MODIFY_PERMISSION);
}
else if (strcasecmp ("MODIFY_REPORT", element_name) == 0)
{
append_attribute (attribute_names, attribute_values, "report_id",
&modify_report_data->report_id);
set_client_state (CLIENT_MODIFY_REPORT);
}
else if (strcasecmp ("MODIFY_REPORT_FORMAT", element_name) == 0)
{
append_attribute (attribute_names, attribute_values,
Expand Down Expand Up @@ -7292,11 +7254,6 @@ gmp_xml_handle_start_element (/* unused */ GMarkupParseContext* context,
}
ELSE_READ_OVER;

case CLIENT_MODIFY_REPORT:
if (strcasecmp ("COMMENT", element_name) == 0)
set_client_state (CLIENT_MODIFY_REPORT_COMMENT);
ELSE_READ_OVER;

case CLIENT_MODIFY_REPORT_FORMAT:
if (strcasecmp ("ACTIVE", element_name) == 0)
set_client_state (CLIENT_MODIFY_REPORT_FORMAT_ACTIVE);
Expand Down Expand Up @@ -26195,66 +26152,6 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context,
CLOSE (CLIENT_MODIFY_PORT_LIST, COMMENT);
CLOSE (CLIENT_MODIFY_PORT_LIST, NAME);

case CLIENT_MODIFY_REPORT:
{
switch (modify_report
(modify_report_data->report_id,
modify_report_data->comment))
{
case 0:
SENDF_TO_CLIENT_OR_FAIL (XML_OK ("modify_report"));
log_event ("report", "Report", modify_report_data->report_id,
"modified");
break;
case 1:
if (send_find_error_to_client ("modify_report", "report",
modify_report_data->report_id,
gmp_parser))
{
error_send_to_client (error);
return;
}
log_event_fail ("report", "Report",
modify_report_data->report_id,
"modified");
break;
case 2:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_report",
"A report_id is required"));
log_event_fail ("report", "Report",
modify_report_data->report_id,
"modified");
break;
case 3:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX
("modify_report",
"A COMMENT element is required"));
break;
case 99:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_report",
"Permission denied"));
log_event_fail ("report", "Report",
modify_report_data->report_id,
"modified");
break;
default:
case -1:
SEND_TO_CLIENT_OR_FAIL (XML_INTERNAL_ERROR ("modify_report"));
log_event_fail ("report", "Report",
modify_report_data->report_id,
"modified");
break;
}

modify_report_data_reset (modify_report_data);
set_client_state (CLIENT_AUTHENTIC);
break;
}
CLOSE (CLIENT_MODIFY_REPORT, COMMENT);

case CLIENT_MODIFY_REPORT_FORMAT:
{
switch (modify_report_format
Expand Down Expand Up @@ -28317,10 +28214,6 @@ gmp_xml_handle_text (/* unused */ GMarkupParseContext* context,
&modify_config_data->preference_value);


APPEND (CLIENT_MODIFY_REPORT_COMMENT,
&modify_report_data->comment);


APPEND (CLIENT_MODIFY_REPORT_FORMAT_ACTIVE,
&modify_report_format_data->active);

Expand Down
3 changes: 0 additions & 3 deletions src/manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -1368,9 +1368,6 @@ set_scan_host_end_time_ctime (report_t, const char*, const char*);
int
report_timestamp (const char*, gchar**);

int
modify_report (const char*, const char*);

int
delete_report (const char *, int);

Expand Down
34 changes: 34 additions & 0 deletions src/manage_migrators.c
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,39 @@ migrate_220_to_221 ()
return 0;
}

/**
* @brief Migrate the database from version 221 to version 222.
*
* @return 0 success, -1 error.
*/
int
migrate_221_to_222 ()
{
sql_begin_immediate ();

/* Ensure that the database is currently version 221. */

if (manage_db_version () != 221)
{
sql_rollback ();
return -1;
}

/* Update the database. */

/* Remove permissions on the remove command MODIFY_REPORT */
sql ("DELETE FROM permissions WHERE name = 'modify_report';");
sql ("DELETE FROM permissions_trash WHERE name = 'modify_report';");

/* Set the database version to 222. */

set_db_version (222);

sql_commit ();

return 0;
}

#undef UPDATE_DASHBOARD_SETTINGS

/**
Expand Down Expand Up @@ -1591,6 +1624,7 @@ static migrator_t database_migrators[] = {
{219, migrate_218_to_219},
{220, migrate_219_to_220},
{221, migrate_220_to_221},
{222, migrate_221_to_222},
/* End marker. */
{-1, NULL}};

Expand Down
60 changes: 0 additions & 60 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ command_t gmp_commands[]
{"MODIFY_OVERRIDE", "Modify an existing override."},
{"MODIFY_PERMISSION", "Modify an existing permission."},
{"MODIFY_PORT_LIST", "Modify an existing port list."},
{"MODIFY_REPORT", "Modify an existing report."},
{"MODIFY_REPORT_FORMAT", "Modify an existing report format."},
{"MODIFY_ROLE", "Modify an existing role."},
{"MODIFY_SCANNER", "Modify an existing scanner."},
Expand Down Expand Up @@ -26258,65 +26257,6 @@ delete_report_internal (report_t report)
return 0;
}

/**
* @brief Modify a report.
*
* @param[in] report_id UUID of report.
* @param[in] comment Comment on report.
*
* @return 0 success, 1 failed to find report, 2 report_id required, 3 comment
* required, 99 permission denied, -1 internal error.
*/
int
modify_report (const char *report_id, const char *comment)
{
gchar *quoted_comment;
report_t report;

if (report_id == NULL)
return 2;

if (comment == NULL)
return 3;

sql_begin_immediate ();

assert (current_credentials.uuid);

if (acl_user_may ("modify_report") == 0)
{
sql_rollback ();
return 99;
}

report = 0;
if (find_report_with_permission (report_id, &report, "modify_report"))
{
sql_rollback ();
return -1;
}

if (report == 0)
{
sql_rollback ();
return 1;
}

quoted_comment = sql_quote (comment ? comment : "");

sql ("UPDATE reports SET"
" comment = '%s'"
" WHERE id = %llu;",
quoted_comment,
report);

g_free (quoted_comment);

sql_commit ();

return 0;
}

/**
* @brief Delete a report.
*
Expand Down
66 changes: 11 additions & 55 deletions src/schema_formats/XML/GMP.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -3146,7 +3146,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
<c>modify_override</c>
<c>modify_permission</c>
<c>modify_port_list</c>
<c>modify_report</c>
<c>modify_report_format</c>
<c>modify_role</c>
<c>modify_scanner</c>
Expand Down Expand Up @@ -3277,7 +3276,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
<r>modify_override</r>
<r>modify_permission</r>
<r>modify_port_list</r>
<r>modify_report</r>
<r>modify_report_format</r>
<r>modify_role</r>
<r>modify_scanner</r>
Expand Down Expand Up @@ -25407,58 +25405,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
</response>
</example>
</command>
<command>
<name>modify_report</name>
<summary>Modify an existing report</summary>
<description>
<p>
The client uses the modify_report command to change an existing
report.
</p>
</description>
<pattern>
<attrib>
<name>report_id</name>
<summary>ID of report to modify</summary>
<type>uuid</type>
<required>1</required>
</attrib>
<e>comment</e>
</pattern>
<ele>
<name>comment</name>
<summary>The comment on the report</summary>
<pattern>
text
</pattern>
</ele>
<response>
<pattern>
<attrib>
<name>status</name>
<type>status</type>
<required>1</required>
</attrib>
<attrib>
<name>status_text</name>
<type>text</type>
<required>1</required>
</attrib>
</pattern>
</response>
<example>
<summary>Modify a report comment</summary>
<request>
<modify_report report_id="254cd3ef-bbe1-4d58-859d-21b8d0c046c6">
<comment>Monthly scan of the webserver.</comment>
</modify_report>
</request>
<response>
<modify_report_response status="200" status_text="OK">
</modify_report_response>
</response>
</example>
</command>
<command>
<name>modify_report_format</name>
<summary>Update an existing report format</summary>
Expand Down Expand Up @@ -27213,7 +27159,17 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
<summary>Attribute "type" can not be "ALLINFO" anymore</summary>
<description>
<p>
The type "ALLINFO" is not supported aymore.
The type "ALLINFO" is not supported anymore.
</p>
</description>
<version>20.04</version>
</change>
<change>
<command>MODIFY_REPORT</command>
<summary>The command MODIFY_REPORT is removed</summary>
<description>
<p>
The command "MODIFY_REPORT" is not supported anymore.
</p>
</description>
<version>20.04</version>
Expand Down

0 comments on commit adf4f9d

Please sign in to comment.