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

Add sensor relays and OSP sensors #756

Merged
merged 19 commits into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6c6a2ed
Add relay functionality for GMP scanners
timopollmeier Sep 19, 2019
8ff5363
Merge branch 'master' of github.com:greenbone/gvm into sensor-relays
timopollmeier Sep 19, 2019
fd8af5e
Add scanner type "OSP Sensor"
timopollmeier Sep 20, 2019
760cc0e
Merge branch 'master' of github.com:greenbone/gvm into sensor-relays
timopollmeier Sep 23, 2019
6a837e9
Make credential optional in create_scanner
timopollmeier Sep 24, 2019
0bd5d07
Improve credential handling in modify_scanner
timopollmeier Sep 24, 2019
5f65d18
Use client certificate with OSP relays as well
timopollmeier Sep 24, 2019
b03a7c0
Fix adjust doc and logging for --relay-mapper
timopollmeier Sep 24, 2019
6634522
Add CHANGELOG entry for relays and OSP sensor type
timopollmeier Sep 24, 2019
34b3a4a
Merge branch 'master' into sensor-relays
timopollmeier Sep 25, 2019
72268d0
Fix documentation of slave_get_relay
timopollmeier Sep 26, 2019
2efd8bf
Clean up declarations and inits in slave_get_relay
timopollmeier Sep 26, 2019
a268ef5
Fix warnings in osp_connect_with_data
timopollmeier Sep 26, 2019
3f9d765
Clarify --relay-mapper option documentation
timopollmeier Sep 26, 2019
6996e4a
Get system/performance reports list also via OSP
timopollmeier Sep 26, 2019
30bee72
Get performance reports from OSP
timopollmeier Sep 26, 2019
cbd3f82
Free strings in get_osp_performance_string
timopollmeier Sep 26, 2019
fa06038
Remove unused return values from functions
timopollmeier Sep 26, 2019
2486eea
Move comment in get_system_report_types OSP case
timopollmeier Sep 26, 2019
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 @@ -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