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 alternative options for radio type preferences when exporting a scan config #1278

Merged
merged 1 commit into from
Aug 31, 2020
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 @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix SCP alert authentication and logging [#1264](https://github.com/greenbone/gvmd/pull/1264)
- Set file mode creation mask for feed lock handling [#1265](https://github.com/greenbone/gvmd/pull/1265)
- Ignore min_qod when getting single results by UUID [#1276](http://github.com/greenbone/gvmd/pull/1276)
- Fix alternative options for radio type preferences when exporting a scan_config [#1278](http://github.com/greenbone/gvmd/pull/1278)

### Removed

Expand Down
14 changes: 7 additions & 7 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -8674,13 +8674,6 @@ buffer_config_preference_xml (GString *buffer, iterator_t *prefs,
char *pos = strchr (value, ';');
if (pos) *pos = '\0';
buffer_xml_append_printf (buffer, "<value>%s</value>", value);
while (pos)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely this hasn't been broken since 2010? I think this worked because OTP sent the alts with the value. Has ospd-openvas stopped doing that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think somewhere along the line we lost track of keeping the alts in the preference value in the XML. For example in the feed config XML one radio value includes the alts but the other one does not.

And gvmd was not checking for the alts when importing XML configs, so the values ended up in dbs without alts. My current db has both.

I think using using default_value which comes from the nvts table is a good solution.

{
char *pos2 = strchr (++pos, ';');
if (pos2) *pos2 = '\0';
buffer_xml_append_printf (buffer, "<alt>%s</alt>", pos);
pos = pos2;
}
}
else if (value
&& type
Expand All @@ -8698,6 +8691,13 @@ buffer_config_preference_xml (GString *buffer, iterator_t *prefs,
char *pos = strchr (default_value, ';');
if (pos) *pos = '\0';
buffer_xml_append_printf (buffer, "<default>%s</default>", default_value);
while (pos)
{
char *pos2 = strchr (++pos, ';');
if (pos2) *pos2 = '\0';
buffer_xml_append_printf (buffer, "<alt>%s</alt>", pos);
pos = pos2;
}
}
else if (default_value
&& type
Expand Down