Skip to content

Commit

Permalink
Directly store the nvti tags string into the db.
Browse files Browse the repository at this point in the history
Since the timestamps do not appear anymore in the
tags string, there is no need to parse them out of the
tags string.
Now the tags string can simply directly be inserted
into the database as is.
  • Loading branch information
janowagner committed Aug 28, 2019
1 parent 97501c4 commit efad960
Showing 1 changed file with 1 addition and 52 deletions.
53 changes: 1 addition & 52 deletions src/manage_sql_nvts.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,58 +215,7 @@ insert_nvt (const nvti_t *nvti)
quoted_detection = sql_quote (nvti_detection (nvti) ?
nvti_detection (nvti) : "");

if (nvti_tag (nvti))
{
gchar **split, **point;
GString *tag;

/* creation_date=2009-04-09 14:18:58 +0200 (Thu, 09 Apr 2009)|... */

split = g_strsplit (nvti_tag (nvti), "|", 0);
point = split;

while (*point)
{
if (((strlen (*point) > strlen ("creation_date"))
&& (strncmp (*point, "creation_date", strlen ("creation_date"))
== 0)
&& ((*point)[strlen ("creation_date")] == '='))
|| ((strlen (*point) > strlen ("last_modification"))
&& (strncmp (*point, "last_modification",
strlen ("last_modification"))
== 0)
&& ((*point)[strlen ("last_modification")] == '=')))
{
gchar **move;
move = point;
g_free (*point);
while (*move)
{
move[0] = move[1];
move++;
}
}
else
point++;
}

point = split;
tag = g_string_new ("");
while (*point)
{
if (point[1])
g_string_append_printf (tag, "%s|", *point);
else
g_string_append_printf (tag, "%s", *point);
point++;
}
g_strfreev (split);

quoted_tag = sql_quote (tag->str);
g_string_free (tag, TRUE);
}
else
quoted_tag = g_strdup ("");
quoted_tag = sql_quote (nvti_tag (nvti) ? nvti_tag (nvti) : "");

quoted_cvss_base = sql_quote (nvti_cvss_base (nvti) ? nvti_cvss_base (nvti) : "");

Expand Down

0 comments on commit efad960

Please sign in to comment.