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 option to update NVTs via OSP #392

Merged
merged 29 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
744a494
Add skeleton of option to update NVTs via OSP
mattmundell Feb 11, 2019
b15c392
Merge branch 'master' into nvt-rebuild-via-osp
mattmundell Feb 11, 2019
dd59802
Split INSERT section out of make_nvt_from_nvti
mattmundell Feb 22, 2019
f699cd4
Use function to set NVT check time
mattmundell Feb 22, 2019
21a2b82
Add INSERTing of NVTs to OSP NVT update
mattmundell Feb 22, 2019
c45ed8b
Merge branch 'nvt-rebuild-via-osp' of mattmundell.github.com:mattmund…
mattmundell Feb 22, 2019
792a755
Merge branch 'master' into nvt-rebuild-via-osp
mattmundell Feb 22, 2019
445d7dd
Include NVT times in get_tag
mattmundell Feb 22, 2019
69d25ac
Also do update if there's no feed version in db
mattmundell Feb 22, 2019
cc468b1
Add and correct comment docs
mattmundell Feb 22, 2019
4eb8a45
Also store cvss_base in OSP NVT update
mattmundell Mar 1, 2019
559f577
Add --osp-vt-update to control the OSP NVT update
mattmundell Mar 5, 2019
5eeb3f6
Add missing param doc
mattmundell Mar 5, 2019
f70e169
Remove stray warning
mattmundell Mar 6, 2019
a58d1c2
Add OSP NVT update message
mattmundell Mar 10, 2019
d61913f
Merge branch 'master' into nvt-rebuild-via-osp
mattmundell May 15, 2019
4e9a695
Merge branch 'master' into nvt-rebuild-via-osp
mattmundell May 17, 2019
370cc3c
Move VT update to function for readability
mattmundell May 18, 2019
9f3d613
Replace 'NOBID' etc with ''
mattmundell May 18, 2019
40a5889
Remove unused get_ref return checks
mattmundell May 18, 2019
7aaca5d
Add NVT preferences to OSP NVT update
mattmundell May 18, 2019
07364fc
Merge branch 'master' into nvt-rebuild-via-osp
mattmundell May 19, 2019
203acf6
Expect REFS instead of VT_REFS
mattmundell May 23, 2019
f4ec026
Merge branch 'nvt-rebuild-via-osp' of mattmundell.github.com:mattmund…
mattmundell May 23, 2019
d00160b
Merge branch 'master' into nvt-rebuild-via-osp
mattmundell May 23, 2019
be78697
Expect PARAMS/PARAM instead of VT_PARAMS/VT_PARAM
mattmundell May 23, 2019
5d17b27
Merge branch 'nvt-rebuild-via-osp' of mattmundell.github.com:mattmund…
mattmundell May 23, 2019
be0dfab
Allow PARAM/DEFAULT to be optional
mattmundell May 23, 2019
6aaca99
Downgrade attribute warnings, not gvmd's job to catch this
mattmundell May 23, 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
34 changes: 31 additions & 3 deletions src/gvmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ static int update_in_progress = 0;
*/
GSList *log_config = NULL;

/**
* @brief File socket for OSP NVT update. NULL to update via OTP.
*/
static gchar *osp_update_socket = NULL;


/* Helpers. */

Expand Down Expand Up @@ -1173,6 +1178,21 @@ update_nvt_cache (int register_cleanup)
}
}

/**
* @brief Update the NVT Cache using OSP.
*
* @param[in] update_socket UNIX socket for contacting openvas-ospd.
*
* @return 0 success.
*/
static int
update_nvt_cache_osp (const gchar *update_socket)
{
proctitle_set ("gvmd: OSP: Updating NVT cache");

return manage_update_nvts_osp (update_socket);
}

/**
* @brief Update NVT cache in forked child, retrying if scanner loading.
*
Expand Down Expand Up @@ -1204,9 +1224,10 @@ update_nvt_cache_retry ()
else if (child_pid == 0)
{
/* Child: Try reload. */
int ret = update_nvt_cache (0);

exit (ret);
if (osp_update_socket)
exit (update_nvt_cache_osp (osp_update_socket));
else
exit (update_nvt_cache (0));
}
}
}
Expand Down Expand Up @@ -1705,6 +1726,7 @@ main (int argc, char** argv)
static gchar *listen_mode = NULL;
static gchar *new_password = NULL;
static gchar *optimize = NULL;
static gchar *osp_vt_update = NULL;
static gchar *password = NULL;
static gchar *manager_address_string = NULL;
static gchar *manager_address_string_2 = NULL;
Expand Down Expand Up @@ -1791,6 +1813,9 @@ main (int argc, char** argv)
G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE,
&decrypt_all_credentials, NULL, NULL },
{ "new-password", '\0', 0, G_OPTION_ARG_STRING, &new_password, "Modify user's password and exit.", "<password>" },
{ "osp-vt-update", '\0', 0, G_OPTION_ARG_STRING, &osp_vt_update,
"Unix socket for OSP NVT update. Default is to do an OTP update.",
"<scanner-socket>" },
{ "optimize", '\0', 0, G_OPTION_ARG_STRING, &optimize, "Run an optimization: vacuum, analyze, cleanup-config-prefs, cleanup-port-names, cleanup-result-severities, cleanup-schedule-times, rebuild-report-cache or update-report-cache.", "<name>" },
{ "password", '\0', 0, G_OPTION_ARG_STRING, &password, "Password, for --create-user.", "<password>" },
{ "port", 'p', 0, G_OPTION_ARG_STRING, &manager_port_string, "Use port number <number>.", "<number>" },
Expand Down Expand Up @@ -2076,6 +2101,9 @@ main (int argc, char** argv)
* These can run concurrently, so they set the shared lock gvm-helping, and
* release gvm-checking, via option_lock. */

if (osp_vt_update)
osp_update_socket = osp_vt_update;

if (backup_database)
{
/* Backup the database and then exit. */
Expand Down
13 changes: 13 additions & 0 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -8849,6 +8849,19 @@ gvm_migrate_secinfo (int feed_type)
return ret;
}

/**
* @brief Update NVT cache using OSP.
*
* @param[in] update_socket Socket to use to contact ospd-openvas scanner.
*
* @return 0 success, -1 error, 2 scanner still loading.
*/
int
manage_update_nvts_osp (const gchar *update_socket)
{
return manage_update_nvt_cache_osp (update_socket);
}


/* Wizards. */

Expand Down
3 changes: 3 additions & 0 deletions src/manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -4189,6 +4189,9 @@ gvm_get_sync_script_description (const gchar *, gchar **);
gboolean
gvm_get_sync_script_feed_version (const gchar *, gchar **);

int
manage_update_nvts_osp (const gchar *);


/* Wizards. */

Expand Down
Loading