Skip to content

Commit

Permalink
Merge pull request #386 from janowagner/resolve_tags
Browse files Browse the repository at this point in the history
Remove dead code about tags.
  • Loading branch information
jjnicola authored Sep 9, 2019
2 parents b39f550 + 7dd3bc0 commit 625872c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 93 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- OpenVAS Scanner has been renamed to OpenVAS (Open Vulnerability Assessment Scanner). [#337](https://github.com/greenbone/openvas/pull/337) [#343](https://github.com/greenbone/openvas/pull/343)
- Retry until a host finishes and frees a db before running a new host scan, in case there is no free redis db. Therefore a infinite loop has been added when it call kb_new(). [#340](https://github.com/greenbone/openvas/pull/340)
- Use new nvti_add_tag() instead of plug_set_tag() and remove plug_set_tag(). [#385](https://github.com/greenbone/openvas/pull/385)
- Remove dead code about tags regarding former openvas settings "result_prepend_tags" and "result_append_tags". [#386](https://github.com/greenbone/openvas/pull/386)

### Fixed
- An issue with stuck scans where only a single plugin is running and is beyond its timeout has been addressed. [#289](https://github.com/greenbone/openvas/pull/289)
Expand Down
97 changes: 4 additions & 93 deletions misc/plugutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,7 @@ plug_get_host_ip_str (struct script_infos *desc)
* @brief Post a security message (e.g. LOG, NOTE, WARNING ...).
*
* @param oid The oid of the NVT
* @param desc The script infos where to get the nvtichache from and some
* other settings and it is used to send the messages
* @param desc The script infos where to get settings.
* @param port Port number related to the issue.
* @param proto Protocol related to the issue (tcp or udp).
* @param action The actual result text
Expand All @@ -308,15 +307,15 @@ void
proto_post_wrapped (const char *oid, struct script_infos *desc, int port,
const char *proto, const char *action, const char *what)
{
const char *prepend_tags, *append_tags, *hostname = "";
char *buffer, *data, **nvti_tags = NULL, port_s[16] = "general";
const char *hostname = "";
char *buffer, *data, port_s[16] = "general";
char ip_str[INET6_ADDRSTRLEN];
GString *action_str;
gsize length;
kb_t kb;

/* Should not happen, just to avoid trouble stop here if no NVTI found */
if (!nvticache_initialized () || !oid)
if (!oid)
return;

if (action == NULL)
Expand All @@ -327,94 +326,6 @@ proto_post_wrapped (const char *oid, struct script_infos *desc, int port,
g_string_append (action_str, "\n");
}

prepend_tags = prefs_get ("result_prepend_tags");
append_tags = prefs_get ("result_append_tags");

if (prepend_tags || append_tags)
{
char *tags = nvticache_get_tags (oid);
nvti_tags = g_strsplit (tags, "|", 0);
g_free (tags);
}

/* This is convenience functionality in preparation for the breaking up of the
* NVT description block and adding proper handling of refined meta
* information all over the OpenVAS Framework.
*/
if (nvti_tags != NULL)
{
if (prepend_tags != NULL)
{
gchar **tags = g_strsplit (prepend_tags, ",", 0);
int i = 0;
gchar *tag_prefix;
gchar *tag_value;
while (tags[i] != NULL)
{
int j = 0;
tag_value = NULL;
tag_prefix = g_strconcat (tags[i], "=", NULL);
while (nvti_tags[j] != NULL && tag_value == NULL)
{
if (g_str_has_prefix (nvti_tags[j], tag_prefix))
{
tag_value = g_strstr_len (nvti_tags[j], -1, "=");
}
j++;
}
g_free (tag_prefix);

if (tag_value != NULL)
{
tag_value = tag_value + 1;
gchar *tag_line =
g_strdup_printf ("%s:\n%s\n\n", tags[i], tag_value);
g_string_prepend (action_str, tag_line);

g_free (tag_line);
}
i++;
}
g_strfreev (tags);
}

if (append_tags != NULL)
{
gchar **tags = g_strsplit (append_tags, ",", 0);
int i = 0;
gchar *tag_prefix;
gchar *tag_value;

while (tags[i] != NULL)
{
int j = 0;
tag_value = NULL;
tag_prefix = g_strconcat (tags[i], "=", NULL);
while (nvti_tags[j] != NULL && tag_value == NULL)
{
if (g_str_has_prefix (nvti_tags[j], tag_prefix))
{
tag_value = g_strstr_len (nvti_tags[j], -1, "=");
}
j++;
}
g_free (tag_prefix);

if (tag_value != NULL)
{
tag_value = tag_value + 1;
gchar *tag_line =
g_strdup_printf ("%s:\n%s\n\n", tags[i], tag_value);
g_string_append (action_str, tag_line);

g_free (tag_line);
}
i++;
}
g_strfreev (tags);
}
}

if (port > 0)
snprintf (port_s, sizeof (port_s), "%d", port);
if (current_vhost)
Expand Down

0 comments on commit 625872c

Please sign in to comment.