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

Extend command line options for managing scanners (9.0) #815

Merged
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 @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added

### Changed
- Extend command line options for managing scanners [#815](https://github.com/greenbone/gvmd/pull/815)
- Update SCAP and CERT feed info in sync scripts [#809](https://github.com/greenbone/gvmd/pull/809)

### Fixed
Expand Down
11 changes: 9 additions & 2 deletions doc/gvmd.8
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,19 @@ Role for --create-user and --get-users.
\fB--scanner-ca-pub=\fISCANNER-CA-PUB\fB\f1
Scanner CA Certificate path for --[create|modify]-scanner.
.TP
\fB--scanner-credential=\fISCANNER-CREDENTIAL\fB\f1
Scanner credential for --create-scanner and --modify-scanner.

Can be blank to unset or a credential UUID. If omitted, a new credential can be created instead.
.TP
\fB--scanner-host=\fISCANNER-HOST\fB\f1
Scanner host for --create-scanner and --modify-scanner.
.TP
\fB--scanner-key-priv=\fISCANNER-KEY-PRIVATE\fB\f1
Scanner private key path for --[create|modify]-scanner.
Scanner private key path for --[create|modify]-scanner if --scanner-credential is not given.
.TP
\fB--scanner-key-pub=\fISCANNER-KEY-PUBLIC\fB\f1
Scanner Certificate path for --[create|modify]-scanner.
Scanner Certificate path for --[create|modify]-scanner if --scanner-credential is not given.
.TP
\fB--scanner-name=\fINAME\fB\f1
Name for --modify-scanner.
Expand All @@ -150,6 +155,8 @@ Scanner port for --create-scanner and --modify-scanner.
.TP
\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.
.TP
\fB--schedule-timeout=\fITIME\fB\f1
Time out tasks that are more than TIME minutes overdue. -1 to disable, 0 for minimum time.
Expand Down
16 changes: 14 additions & 2 deletions doc/gvmd.8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
<p>Scanner CA Certificate path for --[create|modify]-scanner.</p>
</optdesc>
</option>
<option>
<p><opt>--scanner-credential=<arg>SCANNER-CREDENTIAL</arg></opt></p>
<optdesc>
<p>Scanner credential for --create-scanner and --modify-scanner.</p>
<p>Can be blank to unset or a credential UUID. If omitted, a new
credential can be created instead.</p>
</optdesc>
</option>
<option>
<p><opt>--scanner-host=<arg>SCANNER-HOST</arg></opt></p>
<optdesc>
Expand All @@ -310,13 +318,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
<option>
<p><opt>--scanner-key-priv=<arg>SCANNER-KEY-PRIVATE</arg></opt></p>
<optdesc>
<p>Scanner private key path for --[create|modify]-scanner.</p>
<p>Scanner private key path for --[create|modify]-scanner
if --scanner-credential is not given.</p>
</optdesc>
</option>
<option>
<p><opt>--scanner-key-pub=<arg>SCANNER-KEY-PUBLIC</arg></opt></p>
<optdesc>
<p>Scanner Certificate path for --[create|modify]-scanner.</p>
<p>Scanner Certificate path for --[create|modify]-scanner
if --scanner-credential is not given.</p>
</optdesc>
</option>
<option>
Expand All @@ -335,6 +345,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
<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
as used in GMP.</p>
</optdesc>
</option>
<option>
Expand Down
16 changes: 14 additions & 2 deletions doc/gvmd.html
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ <h2>Options</h2>



<p><b>--scanner-credential=<em>SCANNER-CREDENTIAL</em></b></p>

<p>Scanner credential for --create-scanner and --modify-scanner.</p>
<p>Can be blank to unset or a credential UUID. If omitted, a new
credential can be created instead.</p>



<p><b>--scanner-host=<em>SCANNER-HOST</em></b></p>

<p>Scanner host for --create-scanner and --modify-scanner.</p>
Expand All @@ -293,13 +301,15 @@ <h2>Options</h2>

<p><b>--scanner-key-priv=<em>SCANNER-KEY-PRIVATE</em></b></p>

<p>Scanner private key path for --[create|modify]-scanner.</p>
<p>Scanner private key path for --[create|modify]-scanner
if --scanner-credential is not given.</p>



<p><b>--scanner-key-pub=<em>SCANNER-KEY-PUBLIC</em></b></p>

<p>Scanner Certificate path for --[create|modify]-scanner.</p>
<p>Scanner Certificate path for --[create|modify]-scanner
if --scanner-credential is not given.</p>



Expand All @@ -318,6 +328,8 @@ <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
as used in GMP.</p>



Expand Down
52 changes: 41 additions & 11 deletions src/gvmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,7 @@ gvmd (int argc, char** argv)
static gchar *scanner_port = NULL;
static gchar *scanner_type = NULL;
static gchar *scanner_ca_pub = NULL;
static gchar *scanner_credential = NULL;
static gchar *scanner_key_pub = NULL;
static gchar *scanner_key_priv = NULL;
static int schedule_timeout = SCHEDULE_TIMEOUT_DEFAULT;
Expand Down Expand Up @@ -1812,17 +1813,25 @@ gvmd (int argc, char** argv)
&scanner_ca_pub,
"Scanner CA Certificate path for --[create|modify]-scanner.",
"<scanner-ca-pub>" },
{ "scanner-credential", '\0', 0, G_OPTION_ARG_STRING,
&scanner_credential,
"Scanner credential for --create-scanner and --modify-scanner."
" Can be blank to unset or a credential UUID."
" If omitted, a new credential can be created instead.",
"<scanner-credential>" },
{ "scanner-host", '\0', 0, G_OPTION_ARG_STRING,
&scanner_host,
"Scanner host for --create-scanner and --modify-scanner.",
"<scanner-host>" },
{ "scanner-key-priv", '\0', 0, G_OPTION_ARG_STRING,
&scanner_key_priv,
"Scanner private key path for --[create|modify]-scanner.",
"Scanner private key path for --[create|modify]-scanner"
" if --scanner-credential is not given.",
"<scanner-key-private>" },
{ "scanner-key-pub", '\0', 0, G_OPTION_ARG_STRING,
&scanner_key_pub,
"Scanner Certificate path for --[create|modify]-scanner.",
"Scanner Certificate path for --[create|modify]-scanner"
" if --scanner-credential is not given.",
"<scanner-key-public>" },
{ "scanner-name", '\0', 0, G_OPTION_ARG_STRING,
&scanner_name,
Expand All @@ -1836,7 +1845,8 @@ gvmd (int argc, char** argv)
{ "scanner-type", '\0', 0, G_OPTION_ARG_STRING,
&scanner_type,
"Scanner type for --create-scanner and --modify-scanner."
" Either 'OpenVAS' or 'OSP'.",
" Either 'OpenVAS', 'OSP', 'GMP', 'OSP-Sensor'"
" or a number as used in GMP.",
"<scanner-type>" },
{ "schedule-timeout", '\0', 0, G_OPTION_ARG_INT,
&schedule_timeout,
Expand Down Expand Up @@ -2249,16 +2259,26 @@ gvmd (int argc, char** argv)
type = SCANNER_TYPE_OPENVAS;
else if (!strcasecmp (scanner_type, "OSP"))
type = SCANNER_TYPE_OSP;
else if (!strcasecmp (scanner_type, "GMP"))
type = SCANNER_TYPE_GMP;
else if (!strcasecmp (scanner_type, "OSP-Sensor"))
type = SCANNER_TYPE_OSP_SENSOR;
else
{
printf ("Invalid scanner type value.\n");
return EXIT_FAILURE;
type = atoi (scanner_type);
if (type <= SCANNER_TYPE_NONE
|| type >= SCANNER_TYPE_MAX
|| type == SCANNER_TYPE_CVE)
{
fprintf (stderr, "Invalid scanner type value.\n");
return EXIT_FAILURE;
}
}
stype = g_strdup_printf ("%u", type);
ret = manage_create_scanner (log_config, database, create_scanner,
scanner_host, scanner_port, stype,
scanner_ca_pub, scanner_key_pub,
scanner_key_priv);
scanner_ca_pub, scanner_credential,
scanner_key_pub, scanner_key_priv);
g_free (stype);
log_config_free ();
if (ret)
Expand Down Expand Up @@ -2286,10 +2306,20 @@ gvmd (int argc, char** argv)
type = SCANNER_TYPE_OPENVAS;
else if (strcasecmp (scanner_type, "OSP") == 0)
type = SCANNER_TYPE_OSP;
else if (!strcasecmp (scanner_type, "GMP"))
type = SCANNER_TYPE_GMP;
else if (!strcasecmp (scanner_type, "OSP-Sensor"))
type = SCANNER_TYPE_OSP_SENSOR;
else
{
g_warning ("Invalid scanner type value");
return EXIT_FAILURE;
type = atoi (scanner_type);
if (type <= SCANNER_TYPE_NONE
|| type >= SCANNER_TYPE_MAX
|| type == SCANNER_TYPE_CVE)
{
fprintf (stderr, "Invalid scanner type value.\n");
return EXIT_FAILURE;
}
}

stype = g_strdup_printf ("%u", type);
Expand All @@ -2299,8 +2329,8 @@ gvmd (int argc, char** argv)

ret = manage_modify_scanner (log_config, database, modify_scanner,
scanner_name, scanner_host, scanner_port,
stype, scanner_ca_pub, scanner_key_pub,
scanner_key_priv);
stype, scanner_ca_pub, scanner_credential,
scanner_key_pub, scanner_key_priv);
g_free (stype);
log_config_free ();
if (ret)
Expand Down
4 changes: 2 additions & 2 deletions src/manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -2679,12 +2679,12 @@ manage_system_report (const char *, const char *, const char *, const char *,
int
manage_create_scanner (GSList *, const char *, const char *, const char *,
const char *, const char *, const char *, const char *,
const char *);
const char *, const char *);

int
manage_modify_scanner (GSList *, const gchar *, const char *, const char *,
const char *, const char *, const char *, const char *,
const char *, const char *);
const char *, const char *, const char *);

int
manage_delete_scanner (GSList *, const gchar *, const gchar *);
Expand Down
Loading