Skip to content

Commit

Permalink
Merge pull request #756 from timopollmeier/sensor-relays
Browse files Browse the repository at this point in the history
Add sensor relays and OSP sensors
  • Loading branch information
mattmundell authored Sep 26, 2019
2 parents 2659caf + 2486eea commit dbe3ac6
Show file tree
Hide file tree
Showing 9 changed files with 944 additions and 198 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- 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)
- Add lean option to GET_REPORTS [#745](https://github.com/greenbone/gvmd/pull/745)
- Add scanner relays and OSP sensor scanner type [#756](https://github.com/greenbone/gvmd/pull/756)

### Changed
- Check if NVT preferences exist before inserting. [#406](https://github.com/greenbone/gvmd/pull/406)
Expand Down
3 changes: 3 additions & 0 deletions doc/gvmd.8
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ Use port number NUMBER.
\fB--port2=\fINUMBER\fB\f1
Use port number NUMBER for address 2.
.TP
\fB--relay-mapper=\fIFILE\fB\f1
Executable for mapping scanner hosts to relays. Use an empty string to explicitly disable. If the option is not given, $PATH is checked for gvm-relay-mapper.
.TP
\fB--role=\fIROLE\fB\f1
Role for --create-user and --get-users.
.TP
Expand Down
9 changes: 9 additions & 0 deletions doc/gvmd.8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
<p>Use port number NUMBER for address 2.</p>
</optdesc>
</option>
<option>
<p><opt>--relay-mapper=<arg>FILE</arg></opt></p>
<optdesc>
<p>Executable for mapping scanner hosts to relays.
Use an empty string to explicitly disable.
If the option is not given, $PATH is checked for gvm-relay-mapper.
</p>
</optdesc>
</option>
<option>
<p><opt>--role=<arg>ROLE</arg></opt></p>
<optdesc>
Expand Down
9 changes: 9 additions & 0 deletions doc/gvmd.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ <h2>Options</h2>



<p><b>--relay-mapper=<em>FILE</em></b></p>

<p>Executable for mapping scanner hosts to relays.
Use an empty string to explicitly disable.
If the option is not given, $PATH is checked for gvm-relay-mapper.
</p>



<p><b>--role=<em>ROLE</em></b></p>

<p>Role for --create-user and --get-users.</p>
Expand Down
40 changes: 36 additions & 4 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -19500,12 +19500,31 @@ handle_create_scanner (gmp_parser_t *gmp_parser, GError **error)
goto create_scanner_leave;
}

if (!create_scanner_data->name || !create_scanner_data->host
|| !create_scanner_data->port || !create_scanner_data->type
|| !create_scanner_data->credential_id)
if (!create_scanner_data->name)
{
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_scanner", "Missing entity"));
(XML_ERROR_SYNTAX ("create_scanner", "Missing NAME"));
goto create_scanner_leave;
}

if (!create_scanner_data->host)
{
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_scanner", "Missing HOST"));
goto create_scanner_leave;
}

if (!create_scanner_data->port)
{
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_scanner", "Missing PORT"));
goto create_scanner_leave;
}

if (!create_scanner_data->type)
{
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_scanner", "Missing TYPE"));
goto create_scanner_leave;
}

Expand Down Expand Up @@ -19572,6 +19591,12 @@ handle_create_scanner (gmp_parser_t *gmp_parser, GError **error)
" (client certificate)"));
log_event_fail ("scanner", "Scanner", NULL, "created");
break;
case 6:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_scanner",
"Scanner type requires a credential"));
log_event_fail ("scanner", "Scanner", NULL, "created");
break;
case 99:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_scanner", "Permission denied"));
Expand Down Expand Up @@ -19686,6 +19711,13 @@ handle_modify_scanner (gmp_parser_t *gmp_parser, GError **error)
log_event_fail ("scanner", "Scanner", modify_scanner_data->scanner_id,
"modified");
break;
case 8:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_scanner",
"Scanner type requires a credential"));
log_event_fail ("scanner", "Scanner", modify_scanner_data->scanner_id,
"modified");
break;
case 99:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_scanner", "Permission denied"));
Expand Down
38 changes: 38 additions & 0 deletions src/gvmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,7 @@ gvmd (int argc, char** argv)
static gchar *modify_setting = NULL;
static gchar *scanner_name = NULL;
static gchar *rc_name = NULL;
static gchar *relay_mapper = NULL;
static gchar *role = NULL;
static gchar *disable = NULL;
static gchar *value = NULL;
Expand Down Expand Up @@ -1810,6 +1811,13 @@ gvmd (int argc, char** argv)
&manager_port_string_2,
"Use port number <number> for address 2.",
"<number>" },
{ "relay-mapper", '\0', 0, G_OPTION_ARG_FILENAME,
&relay_mapper,
"Executable for mapping scanner hosts to relays."
" Use an empty string to explicitly disable."
" If the option is not given, $PATH is checked for"
" gvm-relay-mapper.",
"<file>" },
{ "role", '\0', 0, G_OPTION_ARG_STRING,
&role,
"Role for --create-user and --get-users.",
Expand Down Expand Up @@ -2015,6 +2023,36 @@ gvmd (int argc, char** argv)
}
}

/* Set relay mapper */
if (relay_mapper)
{
if (strcmp (relay_mapper, ""))
{
if (g_file_test (relay_mapper, G_FILE_TEST_EXISTS) == 0)
g_warning ("Relay mapper '%s' not found.", relay_mapper);
else if (g_file_test (relay_mapper, G_FILE_TEST_IS_EXECUTABLE) == 0)
g_warning ("Relay mapper '%s' is not executable.", relay_mapper);
else
{
g_debug ("Using relay mapper '%s'.", relay_mapper);
set_relay_mapper_path (relay_mapper);
}
}
else
g_debug ("Relay mapper disabled.");
}
else
{
gchar *default_mapper = g_find_program_in_path ("gvm-relay-mapper");
if (default_mapper)
{
g_debug ("Using default relay mapper '%s'.", default_mapper);
set_relay_mapper_path (default_mapper);
}
else
g_debug ("No default relay mapper found.");
}

#ifdef GVMD_GIT_REVISION
g_message (" Greenbone Vulnerability Manager version %s (GIT revision %s) (DB revision %i)",
GVMD_VERSION,
Expand Down
Loading

0 comments on commit dbe3ac6

Please sign in to comment.