Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove OSP scanners from gvmd #1689

Merged
merged 7 commits into from
Sep 23, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Removed OVAL definitions from GMP and gvmd documentation [1551](https://github.com/greenbone/gvmd/pull/1551)
- Removed the Business Process Map from gvmd [1627](https://github.com/greenbone/gvmd/pull/1627)
- Removed ifaces element from users [#1676](https://github.com/greenbone/gvmd/pull/1676)
- Removed OSP scanners from gvmd [#1689](https://github.com/greenbone/gvmd/pull/1689) [#1691](https://github.com/greenbone/gvmd/pull/1691)

[Unreleased]: https://github.com/greenbone/gvmd/compare/gvmd-21.04...master

Expand Down
2 changes: 1 addition & 1 deletion doc/gvmd.8
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Scanner port for --create-scanner and --modify-scanner.
\fB--scanner-type=\fISCANNER-TYPE\fB\f1
Scanner type for --create-scanner and --modify-scanner.

Either 'OpenVAS', 'OSP', 'GMP', 'OSP-Sensor' or a number as used in GMP.
Either 'OpenVAS', 'GMP', 'OSP-Sensor' or a number as used in GMP.
.TP
\fB--scanner-connection-retry=\fINUMBER\fB\f1
Number of auto retries if scanner connection is lost in a running task.
Expand Down
2 changes: 1 addition & 1 deletion doc/gvmd.8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<p><opt>--scanner-type=<arg>SCANNER-TYPE</arg></opt></p>
<optdesc>
<p>Scanner type for --create-scanner and --modify-scanner.</p>
<p>Either 'OpenVAS', 'OSP', 'GMP', 'OSP-Sensor' or a number
<p>Either 'OpenVAS', 'GMP', 'OSP-Sensor' or a number
as used in GMP.</p>
</optdesc>
</option>
Expand Down
2 changes: 1 addition & 1 deletion doc/gvmd.html
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ <h2>Options</h2>
<p><b>--scanner-type=<em>SCANNER-TYPE</em></b></p>

<p>Scanner type for --create-scanner and --modify-scanner.</p>
<p>Either 'OpenVAS', 'OSP', 'GMP', 'OSP-Sensor' or a number
<p>Either 'OpenVAS', 'GMP', 'OSP-Sensor' or a number
as used in GMP.</p>


Expand Down
117 changes: 1 addition & 116 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3161,27 +3161,6 @@ stop_task_data_reset (stop_task_data_t *data)
memset (data, 0, sizeof (stop_task_data_t));
}

/**
* @brief Command data for the sync_config command.
*/
typedef struct
{
char *config_id; ///< Config UUID.
} sync_config_data_t;

/**
* @brief Reset command data.
*
* @param[in] data Command data.
*/
static void
sync_config_data_reset (sync_config_data_t *data)
{
g_free (data->config_id);

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

/**
* @brief Command data for the test_alert command.
*/
Expand Down Expand Up @@ -3382,7 +3361,6 @@ typedef union
resume_task_data_t resume_task; ///< resume_task
start_task_data_t start_task; ///< start_task
stop_task_data_t stop_task; ///< stop_task
sync_config_data_t sync_config; ///< sync_config
test_alert_data_t test_alert; ///< test_alert
verify_report_format_data_t verify_report_format; ///< verify_report_format
verify_scanner_data_t verify_scanner; ///< verify_scanner
Expand Down Expand Up @@ -3952,12 +3930,6 @@ static start_task_data_t *start_task_data
static stop_task_data_t *stop_task_data
= (stop_task_data_t*) &(command_data.stop_task);

/**
* @brief Parser callback data for SYNC_CONFIG.
*/
static sync_config_data_t *sync_config_data
= (sync_config_data_t*) &(command_data.sync_config);

/**
* @brief Parser callback data for TEST_ALERT.
*/
Expand Down Expand Up @@ -4534,7 +4506,6 @@ typedef enum
CLIENT_RUN_WIZARD_PARAMS_PARAM_VALUE,
CLIENT_START_TASK,
CLIENT_STOP_TASK,
CLIENT_SYNC_CONFIG,
CLIENT_TEST_ALERT,
CLIENT_VERIFY_REPORT_FORMAT,
CLIENT_VERIFY_SCANNER,
Expand Down Expand Up @@ -5924,12 +5895,6 @@ gmp_xml_handle_start_element (/* unused */ GMarkupParseContext* context,
&stop_task_data->task_id);
set_client_state (CLIENT_STOP_TASK);
}
else if (strcasecmp ("SYNC_CONFIG", element_name) == 0)
{
append_attribute (attribute_names, attribute_values, "config_id",
&sync_config_data->config_id);
set_client_state (CLIENT_SYNC_CONFIG);
}
else if (strcasecmp ("TEST_ALERT", element_name) == 0)
{
append_attribute (attribute_names, attribute_values,
Expand Down Expand Up @@ -15439,8 +15404,7 @@ handle_get_scanners (gmp_parser_t *gmp_parser, GError **error)
cleanup_iterator (&tasks);
SEND_TO_CLIENT_OR_FAIL ("</tasks>");
}
if ((scanner_iterator_type (&scanners) == SCANNER_TYPE_OSP
|| scanner_iterator_type (&scanners) == SCANNER_TYPE_OPENVAS)
if ((scanner_iterator_type (&scanners) == SCANNER_TYPE_OPENVAS)
&& get_scanners_data->get.details)
{
char *s_name = NULL, *s_ver = NULL;
Expand Down Expand Up @@ -17722,81 +17686,6 @@ handle_get_vulns (gmp_parser_t *gmp_parser, GError **error)
set_client_state (CLIENT_AUTHENTIC);
}

/**
* @brief Handle end of SYNC_CONFIG element.
*
* @param[in] gmp_parser GMP parser.
* @param[in] error Error parameter.
*/
static void
handle_sync_config (gmp_parser_t *gmp_parser, GError **error)
{
assert (current_credentials.username);
if (!sync_config_data->config_id)
{
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("sync_config",
"SYNC_CONFIG requires a config_id attribute"));
sync_config_data_reset (sync_config_data);
set_client_state (CLIENT_AUTHENTIC);
return;
}
switch (sync_config (sync_config_data->config_id))
{
case 0:
log_event ("config", "config", sync_config_data->config_id,
"synchronized");
SEND_TO_CLIENT_OR_FAIL (XML_OK ("sync_config"));
break;
case 1:
if (send_find_error_to_client
("sync_config", "config", sync_config_data->config_id, gmp_parser))
{
error_send_to_client (error);
return;
}
log_event_fail ("config", "Config", sync_config_data->config_id,
"synchronized");
break;
case 2:
SEND_TO_CLIENT_OR_FAIL (XML_ERROR_SYNTAX
("sync_config", "Config not of type OSP"));
log_event_fail ("config", "Config", sync_config_data->config_id,
"synchronized");
break;
case 3:
SEND_TO_CLIENT_OR_FAIL (XML_ERROR_SYNTAX
("sync_config", "Config has no scanner"));
log_event_fail ("config", "Config", sync_config_data->config_id,
"synchronized");
break;
case 4:
SEND_TO_CLIENT_OR_FAIL (XML_ERROR_SYNTAX
("sync_config",
"Couldn't get parameters from scanner"));
log_event_fail ("config", "Config", sync_config_data->config_id,
"synchronized");
break;
case 99:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("sync_config", "Permission denied"));
log_event_fail ("config", "Config", sync_config_data->config_id,
"synchronized");
break;
case -1:
SEND_TO_CLIENT_OR_FAIL (XML_INTERNAL_ERROR ("sync_config"));
log_event_fail ("config", "Config", sync_config_data->config_id,
"synchronized");
break;
default:
abort ();
break;
}

sync_config_data_reset (sync_config_data);
set_client_state (CLIENT_AUTHENTIC);
}

/**
* @brief Handle end of CREATE_SCANNER element.
*
Expand Down Expand Up @@ -25546,10 +25435,6 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context,
set_client_state (CLIENT_AUTHENTIC);
break;

case CLIENT_SYNC_CONFIG:
handle_sync_config (gmp_parser, error);
break;

case CLIENT_VERIFY_REPORT_FORMAT:
if (verify_report_format_data->report_format_id)
{
Expand Down
64 changes: 1 addition & 63 deletions src/gmp_configs.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ parse_config_entity (entity_t config, const char **config_id, char **name,
void
create_config_run (gmp_parser_t *gmp_parser, GError **error)
{
entity_t entity, get_configs_response, config, name, copy, scanner;
entity_t entity, get_configs_response, config, name, copy;

entity = (entity_t) create_config_data.context->first->data;

Expand Down Expand Up @@ -527,68 +527,6 @@ create_config_run (gmp_parser_t *gmp_parser, GError **error)
return;
}

/* Check for creation from scanner. */

scanner = entity_child (entity, "scanner");
if (scanner && strlen (entity_text (scanner)))
{
char *uuid;

uuid = NULL;

switch (create_config_from_scanner
(entity_text (scanner),
text_or_null (entity_child (entity, "name")),
text_or_null (entity_child (entity, "comment")),
text_or_null (entity_child (entity, "usage_type")),
&uuid))
{
case 0:
SENDF_TO_CLIENT_OR_FAIL (XML_OK_CREATED_ID
("create_config"), uuid);
log_event ("config", "Scan config", uuid, "created");
break;
case 1:
SENDF_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_config",
"Failed to find scanner"));
break;
case 2:
SENDF_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_config",
"Scanner not of type OSP"));
break;
case 3:
SENDF_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_config",
"Config name exists already"));
break;
case 4:
SENDF_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_config",
"Failed to get params from scanner"
" - the scanner may be offline or not"
" configured correctly"));
break;
case 99:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_config",
"Permission denied"));
log_event_fail ("config", "Scan config", NULL, "created");
break;
case -1:
default:
SEND_TO_CLIENT_OR_FAIL
(XML_INTERNAL_ERROR ("create_config"));
log_event_fail ("config", "Scan config", NULL, "created");
break;
}
g_free (uuid);

create_config_reset ();
return;
}

/* Try copy from an existing config. */

copy = entity_child (entity, "copy");
Expand Down
4 changes: 0 additions & 4 deletions src/gvmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2668,8 +2668,6 @@ gvmd (int argc, char** argv)

if (!scanner_type || !strcasecmp (scanner_type, "OpenVAS"))
type = SCANNER_TYPE_OPENVAS;
else if (!strcasecmp (scanner_type, "OSP"))
type = SCANNER_TYPE_OSP;
else if (!strcasecmp (scanner_type, "OSP-Sensor"))
type = SCANNER_TYPE_OSP_SENSOR;
else
Expand Down Expand Up @@ -2712,8 +2710,6 @@ gvmd (int argc, char** argv)

if (strcasecmp (scanner_type, "OpenVAS") == 0)
type = SCANNER_TYPE_OPENVAS;
else if (strcasecmp (scanner_type, "OSP") == 0)
type = SCANNER_TYPE_OSP;
else if (!strcasecmp (scanner_type, "OSP-Sensor"))
type = SCANNER_TYPE_OSP_SENSOR;
else
Expand Down
Loading