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

Fix whole-only config family selection #1517

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 @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Improve VT version handling for CVE & OVAL results [#1496](https://github.com/greenbone/gvmd/pull/1496)
- Fix migration to DB version 242 from gvmd 20.08 [#1498](https://github.com/greenbone/gvmd/pull/1498)
- Update subject alternative name in certificate generation [#1503](https://github.com/greenbone/gvmd/pull/1503)
- Fix whole-only config family selection [#1517](https://github.com/greenbone/gvmd/pull/1517)

[21.4.0]: https://github.com/greenbone/gvmd/compare/v21.4.0...gvmd-21.04

Expand Down
15 changes: 11 additions & 4 deletions src/gmp_configs.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,12 +904,15 @@ modify_config_handle_family_selection (config_t config,
gmp_parser_t *gmp_parser,
GError **error)
{
gchar *rejected_family;

switch (manage_set_config_families
(config,
families_growing_all,
families_static_all,
families_growing_empty,
family_selection_growing))
family_selection_growing,
&rejected_family))
{
case 0:
return 0;
Expand All @@ -919,9 +922,13 @@ modify_config_handle_family_selection (config_t config,
return -1;
case 2:
SENDF_TO_CLIENT_OR_FAIL_WITH_RETURN
(-1, XML_ERROR_SYNTAX ("modify_config",
"Whole-only families must include entire"
" family and be growing"));
(-1,
XML_ERROR_SYNTAX ("modify_config",
"Family "%s" must be growing and"
" include all VTs or it must be static and"
" empty."),
rejected_family);
g_free (rejected_family);
return -1;
case -1:
SENDF_TO_CLIENT_OR_FAIL_WITH_RETURN
Expand Down
3 changes: 2 additions & 1 deletion src/manage_configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ int
manage_set_config_nvts (config_t, const char*, GPtrArray*);

int
manage_set_config_families (config_t, GPtrArray*, GPtrArray*, GPtrArray*, int);
manage_set_config_families (config_t, GPtrArray*, GPtrArray*, GPtrArray*, int,
gchar **);

void
init_config_timeout_iterator (iterator_t*, config_t);
Expand Down
26 changes: 22 additions & 4 deletions src/manage_sql_configs.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@ manage_modify_config_commit ()
* @param[in] static_all_families Static families with all selection.
* @param[in] growing_families The rest of the growing families.
* @param[in] grow_families 1 if families should grow, else 0.
* @param[out] rejected_family Return of family if one was rejected.
*
* @return 0 success, 1 config in use, 2 whole-only families must be growing
* and include entire family, -1 error.
Expand All @@ -928,7 +929,8 @@ manage_set_config_families (config_t config,
GPtrArray* growing_all_families,
GPtrArray* static_all_families,
GPtrArray* growing_families,
int grow_families)
int grow_families,
gchar **rejected_family)
{
static const gchar *wholes[] = FAMILIES_WHOLE_ONLY;
iterator_t families;
Expand All @@ -938,10 +940,26 @@ manage_set_config_families (config_t config,

/* Ensure that whole-only families include all NVTs and are growing. */

if (rejected_family)
*rejected_family = NULL;

for (const gchar **whole = wholes; *whole; whole++)
if (member (growing_all_families, *whole)
|| member (static_all_families, *whole))
return 2;
{
if (member (static_all_families, *whole)
|| member (growing_families, *whole))
{
if (member (static_all_families, *whole))
g_debug ("%s rejected static/all whole-only family %s",
__func__, *whole);
else if (member (growing_families, *whole))
g_debug ("%s rejected growing/empty whole-only family %s",
__func__, *whole);

if (rejected_family)
*rejected_family = g_strdup (*whole);
return 2;
}
}

/* Check the args. */

Expand Down