Greenbone Vulnerability Management Libraries  22.8.0
nvti.c
Go to the documentation of this file.
1 /* SPDX-FileCopyrightText: 2009-2023 Greenbone AG
2  *
3  * SPDX-License-Identifier: GPL-2.0-or-later
4  */
5 
6 // One of the files of gvm-libs needs to specify the meta data
7 // for the doxygen documentation.
8 
33 /* For strptime in time.h. */
34 #undef _XOPEN_SOURCE
35 #define _XOPEN_SOURCE
36 #include "nvti.h"
37 
38 #include <stdio.h> // for sscanf
39 #include <string.h> // for strcmp
40 #include <strings.h> // for strcasecmp
41 #include <time.h> // for strptime
42 
43 #undef G_LOG_DOMAIN
44 
47 #define G_LOG_DOMAIN "libgvm base"
48 
49 /* VT references */
50 
57 typedef struct vtref
58 {
59  gchar *type;
60  gchar *ref_id;
61  gchar *ref_text;
63 
77 vtref_t *
78 vtref_new (const gchar *type, const gchar *ref_id, const gchar *ref_text)
79 {
80  vtref_t *ref = g_malloc0 (sizeof (vtref_t));
81 
82  if (type)
83  ref->type = g_strdup (type);
84  if (ref_id)
85  ref->ref_id = g_strdup (ref_id);
86  if (ref_text)
87  ref->ref_text = g_strdup (ref_text);
88 
89  return ref;
90 }
91 
97 void
99 {
100  if (!ref)
101  return;
102 
103  g_free (ref->type);
104  g_free (ref->ref_id);
105  g_free (ref->ref_text);
106  g_free (ref);
107 }
108 
117 const gchar *
118 vtref_type (const vtref_t *r)
119 {
120  return r ? r->type : NULL;
121 }
122 
131 const gchar *
132 vtref_id (const vtref_t *r)
133 {
134  return r ? r->ref_id : NULL;
135 }
136 
145 const gchar *
146 vtref_text (const vtref_t *r)
147 {
148  return r ? r->ref_text : NULL;
149 }
150 
151 /* VT severities */
152 
158 typedef struct vtseverity
159 {
160  gchar *type;
161  gchar *origin;
162  int date;
164  double score;
165  gchar *value;
167 
181 vtseverity_t *
182 vtseverity_new (const gchar *type, const gchar *origin, int date, double score,
183  const gchar *value)
184 {
185  vtseverity_t *s = g_malloc0 (sizeof (vtseverity_t));
186 
187  if (type)
188  s->type = g_strdup (type);
189  if (origin)
190  s->origin = g_strdup (origin);
191  s->date = date;
192  s->score = score;
193  if (value)
194  s->value = g_strdup (value);
195 
196  return s;
197 }
198 
204 void
206 {
207  if (!s)
208  return;
209 
210  g_free (s->type);
211  g_free (s->origin);
212  g_free (s->value);
213  g_free (s);
214 }
215 
224 const gchar *
226 {
227  return s ? s->type : NULL;
228 }
229 
238 const gchar *
240 {
241  return s ? s->origin : NULL;
242 }
243 
252 const gchar *
254 {
255  return s ? s->value : NULL;
256 }
257 
266 int
268 {
269  return s->date;
270 }
271 
280 double
282 {
283  return s->score;
284 }
285 
286 /* Support function for timestamps */
287 
296 static time_t
297 parse_nvt_timestamp (const gchar *str_time)
298 {
299  time_t epoch_time;
300  int offset;
301  struct tm tm;
302 
303  if ((strcmp ((char *) str_time, "") == 0)
304  || (strcmp ((char *) str_time, "$Date: $") == 0)
305  || (strcmp ((char *) str_time, "$Date$") == 0)
306  || (strcmp ((char *) str_time, "$Date:$") == 0)
307  || (strcmp ((char *) str_time, "$Date") == 0)
308  || (strcmp ((char *) str_time, "$$") == 0))
309  {
310  return 0;
311  }
312 
313  /* Parse the time. */
314 
315  /* 2011-08-09 08:20:34 +0200 (Tue, 09 Aug 2011) */
316  /* $Date: 2012-02-17 16:05:26 +0100 (Fr, 17. Feb 2012) $ */
317  /* $Date: Fri, 11 Nov 2011 14:42:28 +0100 $ */
318  memset (&tm, 0, sizeof (struct tm));
319  if (strptime ((char *) str_time, "%F %T %z", &tm) == NULL)
320  {
321  memset (&tm, 0, sizeof (struct tm));
322  if (strptime ((char *) str_time, "$Date: %F %T %z", &tm) == NULL)
323  {
324  memset (&tm, 0, sizeof (struct tm));
325  if (strptime ((char *) str_time, "%a %b %d %T %Y %z", &tm) == NULL)
326  {
327  memset (&tm, 0, sizeof (struct tm));
328  if (strptime ((char *) str_time, "$Date: %a, %d %b %Y %T %z", &tm)
329  == NULL)
330  {
331  memset (&tm, 0, sizeof (struct tm));
332  if (strptime ((char *) str_time, "$Date: %a %b %d %T %Y %z",
333  &tm)
334  == NULL)
335  {
336  g_warning ("%s: Failed to parse time: %s", __func__,
337  str_time);
338  return 0;
339  }
340  }
341  }
342  }
343  }
344  epoch_time = mktime (&tm);
345  if (epoch_time == -1)
346  {
347  g_warning ("%s: Failed to make time: %s", __func__, str_time);
348  return 0;
349  }
350 
351  /* Get the timezone offset from the str_time. */
352 
353  if ((sscanf ((char *) str_time, "%*u-%*u-%*u %*u:%*u:%*u %d%*[^]]", &offset)
354  != 1)
355  && (sscanf ((char *) str_time, "$Date: %*u-%*u-%*u %*u:%*u:%*u %d%*[^]]",
356  &offset)
357  != 1)
358  && (sscanf ((char *) str_time, "%*s %*s %*s %*u:%*u:%*u %*u %d%*[^]]",
359  &offset)
360  != 1)
361  && (sscanf ((char *) str_time,
362  "$Date: %*s %*s %*s %*u %*u:%*u:%*u %d%*[^]]", &offset)
363  != 1)
364  && (sscanf ((char *) str_time,
365  "$Date: %*s %*s %*s %*u:%*u:%*u %*u %d%*[^]]", &offset)
366  != 1))
367  {
368  g_warning ("%s: Failed to parse timezone offset: %s", __func__, str_time);
369  return 0;
370  }
371 
372  /* Use the offset to convert to UTC. */
373 
374  if (offset < 0)
375  {
376  epoch_time += ((-offset) / 100) * 60 * 60;
377  epoch_time += ((-offset) % 100) * 60;
378  }
379  else if (offset > 0)
380  {
381  epoch_time -= (offset / 100) * 60 * 60;
382  epoch_time -= (offset % 100) * 60;
383  }
384 
385  return epoch_time;
386 }
387 
388 /* VT Information */
389 
393 typedef struct nvti
394 {
395  gchar *oid;
396  gchar *name;
398  gchar *summary;
399  gchar *insight;
400  gchar *affected;
401  gchar *impact;
403  time_t creation_time;
406  gchar *solution;
407  gchar *solution_type;
410  gchar *tag;
411  gchar *cvss_base;
413  gchar *dependencies;
414  gchar *required_keys;
415  gchar *mandatory_keys;
416  gchar *excluded_keys;
417  gchar *required_ports;
418  gchar
421  gchar *detection;
422  gchar *qod_type;
423  gchar *qod;
425  GSList *refs;
426  GSList *severities;
427  GSList *prefs;
429  // The following are not settled yet.
430  gint category;
431  gchar *family;
433 
443 int
445 {
446  if (!vt)
447  return -1;
448 
449  vt->refs = g_slist_append (vt->refs, ref);
450  return 0;
451 }
452 
461 int
463 {
464  if (!vt)
465  return -1;
466 
467  vt->severities = g_slist_append (vt->severities, s);
468  return 0;
469 }
470 
471 /* VT preferences */
472 
476 typedef struct nvtpref
477 {
478  int id;
479  gchar *type;
480  gchar *name;
481  gchar *dflt;
483 
499 nvtpref_t *
500 nvtpref_new (int id, const gchar *name, const gchar *type, const gchar *dflt)
501 {
502  nvtpref_t *np = g_malloc0 (sizeof (nvtpref_t));
503 
504  np->id = id;
505  if (name)
506  np->name = g_strdup (name);
507  if (type)
508  np->type = g_strdup (type);
509  if (dflt)
510  np->dflt = g_strdup (dflt);
511 
512  return np;
513 }
514 
520 void
522 {
523  if (!np)
524  return;
525 
526  g_free (np->name);
527  g_free (np->type);
528  g_free (np->dflt);
529  g_free (np);
530 }
531 
540 int
542 {
543  return np ? np->id : -1;
544 }
545 
554 gchar *
556 {
557  return np ? np->name : NULL;
558 }
559 
568 gchar *
570 {
571  return np ? np->type : NULL;
572 }
573 
582 gchar *
584 {
585  return np ? np->dflt : NULL;
586 }
587 
596 nvti_t *
597 nvti_new (void)
598 {
599  return (nvti_t *) g_malloc0 (sizeof (nvti_t));
600 }
601 
607 void
609 {
610  if (!n)
611  return;
612 
613  g_free (n->oid);
614  g_free (n->name);
615  g_free (n->summary);
616  g_free (n->insight);
617  g_free (n->affected);
618  g_free (n->impact);
619  g_free (n->solution);
620  g_free (n->solution_type);
621  g_free (n->solution_method);
622  g_free (n->tag);
623  g_free (n->cvss_base);
624  g_free (n->dependencies);
625  g_free (n->required_keys);
626  g_free (n->mandatory_keys);
627  g_free (n->excluded_keys);
628  g_free (n->required_ports);
629  g_free (n->required_udp_ports);
630  g_free (n->detection);
631  g_free (n->qod_type);
632  g_free (n->qod);
633  g_free (n->family);
634  g_slist_free_full (n->refs, (void (*) (void *)) vtref_free);
635  g_slist_free_full (n->severities, (void (*) (void *)) vtseverity_free);
636  g_slist_free_full (n->prefs, (void (*) (void *)) nvtpref_free);
637  g_free (n);
638 }
639 
648 gchar *
649 nvti_oid (const nvti_t *n)
650 {
651  return n ? n->oid : NULL;
652 }
653 
662 gchar *
663 nvti_name (const nvti_t *n)
664 {
665  return n ? n->name : NULL;
666 }
667 
676 gchar *
678 {
679  return n ? n->summary : NULL;
680 }
681 
690 gchar *
692 {
693  return n ? n->insight : NULL;
694 }
695 
704 gchar *
706 {
707  return n ? n->affected : NULL;
708 }
709 
718 gchar *
719 nvti_impact (const nvti_t *n)
720 {
721  return n ? n->impact : NULL;
722 }
723 
732 time_t
734 {
735  return n ? n->creation_time : 0;
736 }
737 
746 time_t
748 {
749  return n ? n->modification_time : 0;
750 }
751 
759 guint
761 {
762  return n ? g_slist_length (n->refs) : 0;
763 }
764 
774 vtref_t *
775 nvti_vtref (const nvti_t *n, guint p)
776 {
777  return n ? g_slist_nth_data (n->refs, p) : NULL;
778 }
779 
803 gchar *
804 nvti_refs (const nvti_t *n, const gchar *type, const gchar *exclude_types,
805  guint use_types)
806 {
807  gchar *refs, *refs2, **exclude_item;
808  vtref_t *ref;
809  guint i, exclude;
810  gchar **exclude_split;
811 
812  if (!n)
813  return NULL;
814 
815  refs = NULL;
816  refs2 = NULL;
817  exclude = 0;
818 
819  if (exclude_types && exclude_types[0])
820  exclude_split = g_strsplit (exclude_types, ",", 0);
821  else
822  exclude_split = NULL;
823 
824  for (i = 0; i < g_slist_length (n->refs); i++)
825  {
826  ref = g_slist_nth_data (n->refs, i);
827  if (type && strcasecmp (ref->type, type) != 0)
828  continue;
829 
830  if (exclude_split)
831  {
832  exclude = 0;
833  for (exclude_item = exclude_split; *exclude_item; exclude_item++)
834  {
835  if (strcasecmp (g_strstrip (*exclude_item), ref->type) == 0)
836  {
837  exclude = 1;
838  break;
839  }
840  }
841  }
842 
843  if (!exclude)
844  {
845  if (use_types)
846  {
847  if (refs)
848  refs2 =
849  g_strdup_printf ("%s, %s:%s", refs, ref->type, ref->ref_id);
850  else
851  refs2 = g_strdup_printf ("%s:%s", ref->type, ref->ref_id);
852  }
853  else
854  {
855  if (refs)
856  refs2 = g_strdup_printf ("%s, %s", refs, ref->ref_id);
857  else
858  refs2 = g_strdup_printf ("%s", ref->ref_id);
859  }
860  g_free (refs);
861  refs = refs2;
862  }
863  }
864 
865  g_strfreev (exclude_split);
866 
867  return refs;
868 }
869 
877 guint
879 {
880  return n ? g_slist_length (n->severities) : 0;
881 }
882 
892 vtseverity_t *
893 nvti_vtseverity (const nvti_t *n, guint p)
894 {
895  return n ? g_slist_nth_data (n->severities, p) : NULL;
896 }
897 
905 double
907 {
908  unsigned int i;
909  double score = -1.0;
910 
911  for (i = 0; i < nvti_vtseverities_len (n); i++)
912  {
913  vtseverity_t *severity;
914 
915  severity = nvti_vtseverity (n, i);
916  if (vtseverity_score (severity) > score)
917  score = vtseverity_score (severity);
918  }
919 
920  return score;
921 }
922 
937 gchar *
939 {
940  gchar *vector;
941 
942  /* Currently, only one severity_vector can be stored as tag.
943  * Therfore we just check this one. */
944  vector = nvti_get_tag (n, "severity_vector");
945  if (vector)
946  return vector;
947 
948  vector = nvti_get_tag (n, "cvss_base_vector");
949 
950  return vector;
951 }
952 
961 gchar *
963 {
964  return n ? n->solution : NULL;
965 }
966 
975 gchar *
977 {
978  return n ? n->solution_type : NULL;
979 }
980 
989 gchar *
991 {
992  return n ? n->solution_method : NULL;
993 }
994 
1003 gchar *
1004 nvti_tag (const nvti_t *n)
1005 {
1006  return n ? n->tag : NULL;
1007 }
1008 
1019 gchar *
1020 nvti_get_tag (const nvti_t *n, const gchar *name)
1021 {
1022  gchar **split, **point;
1023 
1024  if (!n || n->tag == NULL || !name)
1025  return NULL;
1026 
1027  split = g_strsplit (n->tag, "|", 0);
1028  point = split;
1029 
1030  while (*point)
1031  {
1032  if ((strlen (*point) > strlen (name))
1033  && (strncmp (*point, name, strlen (name)) == 0)
1034  && ((*point)[strlen (name)] == '='))
1035  {
1036  gchar *ret;
1037  ret = g_strdup (*point + strlen (name) + 1);
1038  g_strfreev (split);
1039  return ret;
1040  }
1041  point++;
1042  }
1043  g_strfreev (split);
1044  return NULL;
1045 }
1046 
1055 gchar *
1057 {
1058  return n ? n->cvss_base : NULL;
1059 }
1060 
1069 gchar *
1071 {
1072  return n ? n->dependencies : NULL;
1073 }
1074 
1083 gchar *
1085 {
1086  return n ? n->required_keys : NULL;
1087 }
1088 
1097 gchar *
1099 {
1100  return n ? n->mandatory_keys : NULL;
1101 }
1102 
1111 gchar *
1113 {
1114  return n ? n->excluded_keys : NULL;
1115 }
1116 
1125 gchar *
1127 {
1128  return n ? n->required_ports : NULL;
1129 }
1130 
1139 gchar *
1141 {
1142  return n ? n->required_udp_ports : NULL;
1143 }
1144 
1153 gchar *
1155 {
1156  return n ? n->detection : NULL;
1157 }
1158 
1167 gchar *
1169 {
1170  return n ? n->qod_type : NULL;
1171 }
1172 
1181 gchar *
1182 nvti_qod (const nvti_t *n)
1183 {
1184  return n ? n->qod : NULL;
1185 }
1186 
1195 gchar *
1197 {
1198  return n ? n->family : NULL;
1199 }
1200 
1208 guint
1210 {
1211  return n ? g_slist_length (n->prefs) : 0;
1212 }
1213 
1223 const nvtpref_t *
1224 nvti_pref (const nvti_t *n, guint p)
1225 {
1226  return n ? g_slist_nth_data (n->prefs, p) : NULL;
1227 }
1228 
1236 gint
1238 {
1239  return n ? n->category : -1;
1240 }
1241 
1251 int
1252 nvti_set_oid (nvti_t *n, const gchar *oid)
1253 {
1254  if (!n)
1255  return -1;
1256 
1257  g_free (n->oid);
1258  n->oid = g_strdup (oid);
1259  return 0;
1260 }
1261 
1271 int
1272 nvti_set_name (nvti_t *n, const gchar *name)
1273 {
1274  if (!n)
1275  return -1;
1276 
1277  g_free (n->name);
1278  n->name = g_strdup (name);
1279  return 0;
1280 }
1281 
1291 int
1292 nvti_put_name (nvti_t *n, gchar *name)
1293 {
1294  if (!n)
1295  return -1;
1296 
1297  g_free (n->name);
1298  n->name = name;
1299  return 0;
1300 }
1301 
1311 int
1312 nvti_set_summary (nvti_t *n, const gchar *summary)
1313 {
1314  if (!n)
1315  return -1;
1316 
1317  g_free (n->summary);
1318  n->summary = g_strdup (summary);
1319  return 0;
1320 }
1321 
1331 int
1332 nvti_put_summary (nvti_t *n, gchar *summary)
1333 {
1334  if (!n)
1335  return -1;
1336 
1337  g_free (n->summary);
1338  n->summary = summary;
1339  return 0;
1340 }
1341 
1351 int
1352 nvti_set_insight (nvti_t *n, const gchar *insight)
1353 {
1354  if (!n)
1355  return -1;
1356 
1357  g_free (n->insight);
1358  n->insight = g_strdup (insight);
1359  return 0;
1360 }
1361 
1371 int
1372 nvti_put_insight (nvti_t *n, gchar *insight)
1373 {
1374  if (!n)
1375  return -1;
1376 
1377  g_free (n->insight);
1378  n->insight = insight;
1379  return 0;
1380 }
1381 
1391 int
1392 nvti_set_affected (nvti_t *n, const gchar *affected)
1393 {
1394  if (!n)
1395  return -1;
1396 
1397  g_free (n->affected);
1398  n->affected = g_strdup (affected);
1399  return 0;
1400 }
1401 
1411 int
1412 nvti_put_affected (nvti_t *n, gchar *affected)
1413 {
1414  if (!n)
1415  return -1;
1416 
1417  g_free (n->affected);
1418  n->affected = affected;
1419  return 0;
1420 }
1421 
1431 int
1432 nvti_set_impact (nvti_t *n, const gchar *impact)
1433 {
1434  if (!n)
1435  return -1;
1436 
1437  g_free (n->impact);
1438  n->impact = g_strdup (impact);
1439  return 0;
1440 }
1441 
1451 int
1452 nvti_put_impact (nvti_t *n, gchar *impact)
1453 {
1454  if (!n)
1455  return -1;
1456 
1457  g_free (n->impact);
1458  n->impact = impact;
1459  return 0;
1460 }
1461 
1471 int
1472 nvti_set_creation_time (nvti_t *n, const time_t creation_time)
1473 {
1474  if (!n)
1475  return -1;
1476 
1477  n->creation_time = creation_time;
1478  return 0;
1479 }
1480 
1490 int
1491 nvti_set_modification_time (nvti_t *n, const time_t modification_time)
1492 {
1493  if (!n)
1494  return -1;
1495 
1496  n->modification_time = modification_time;
1497  return 0;
1498 }
1499 
1509 int
1510 nvti_set_solution (nvti_t *n, const gchar *solution)
1511 {
1512  if (!n)
1513  return -1;
1514 
1515  g_free (n->solution);
1516  n->solution = g_strdup (solution);
1517  return 0;
1518 }
1519 
1529 int
1530 nvti_put_solution (nvti_t *n, gchar *solution)
1531 {
1532  if (!n)
1533  return -1;
1534 
1535  g_free (n->solution);
1536  n->solution = solution;
1537  return 0;
1538 }
1539 
1550 int
1551 nvti_set_solution_type (nvti_t *n, const gchar *solution_type)
1552 {
1553  if (!n)
1554  return -1;
1555 
1556  g_free (n->solution_type);
1557  n->solution_type = g_strdup (solution_type);
1558  return 0;
1559 }
1560 
1571 int
1572 nvti_set_solution_method (nvti_t *n, const gchar *solution_method)
1573 {
1574  if (!n)
1575  return -1;
1576 
1577  g_free (n->solution_method);
1578  n->solution_method = g_strdup (solution_method);
1579  return 0;
1580 }
1581 
1598 int
1599 nvti_add_tag (nvti_t *n, const gchar *name, const gchar *value)
1600 {
1601  gchar *newvalue = NULL;
1602 
1603  if (!n)
1604  return -1;
1605 
1606  if (!name || !name[0])
1607  return -2;
1608 
1609  if (!value || !value[0])
1610  return -3;
1611 
1612  if (!strcmp (name, "last_modification"))
1613  {
1615  newvalue = g_strdup_printf ("%i", (int) nvti_modification_time (n));
1616  }
1617  else if (!strcmp (name, "creation_date"))
1618  {
1620  newvalue = g_strdup_printf ("%i", (int) nvti_creation_time (n));
1621  }
1622  else if (!strcmp (name, "severity_date"))
1623  newvalue = g_strdup_printf ("%i", (int) parse_nvt_timestamp (value));
1624  else if (!strcmp (name, "cvss_base"))
1625  {
1626  /* Ignore this tag because it is not being used.
1627  * It is redundant with the tag cvss_base_vector from which
1628  * it is computed.
1629  * Once GOS 6 and GVM 11 are retired, all set_tag commands
1630  * in the NASL scripts can be removed that set "cvss_base".
1631  * Once this happened this exception can be removed from the code.
1632  */
1633  return 0;
1634  }
1635 
1636  if (n->tag)
1637  {
1638  gchar *newtag;
1639 
1640  newtag =
1641  g_strconcat (n->tag, "|", name, "=", newvalue ? newvalue : value, NULL);
1642  g_free (n->tag);
1643  n->tag = newtag;
1644  }
1645  else
1646  n->tag = g_strconcat (name, "=", newvalue ? newvalue : value, NULL);
1647 
1648  g_free (newvalue);
1649 
1650  return 0;
1651 }
1652 
1662 int
1663 nvti_set_tag (nvti_t *n, const gchar *tag)
1664 {
1665  if (!n)
1666  return -1;
1667 
1668  g_free (n->tag);
1669  if (tag && tag[0])
1670  n->tag = g_strdup (tag);
1671  else
1672  n->tag = NULL;
1673  return 0;
1674 }
1675 
1685 int
1686 nvti_set_cvss_base (nvti_t *n, const gchar *cvss_base)
1687 {
1688  if (!n)
1689  return -1;
1690 
1691  g_free (n->cvss_base);
1692  if (cvss_base && cvss_base[0])
1693  n->cvss_base = g_strdup (cvss_base);
1694  else
1695  n->cvss_base = NULL;
1696  return 0;
1697 }
1698 
1709 int
1710 nvti_set_dependencies (nvti_t *n, const gchar *dependencies)
1711 {
1712  if (!n)
1713  return -1;
1714 
1715  g_free (n->dependencies);
1716  if (dependencies && dependencies[0])
1717  n->dependencies = g_strdup (dependencies);
1718  else
1719  n->dependencies = NULL;
1720  return 0;
1721 }
1722 
1733 int
1734 nvti_set_required_keys (nvti_t *n, const gchar *required_keys)
1735 {
1736  if (!n)
1737  return -1;
1738 
1739  g_free (n->required_keys);
1740  if (required_keys && required_keys[0])
1741  n->required_keys = g_strdup (required_keys);
1742  else
1743  n->required_keys = NULL;
1744  return 0;
1745 }
1746 
1757 int
1758 nvti_set_mandatory_keys (nvti_t *n, const gchar *mandatory_keys)
1759 {
1760  if (!n)
1761  return -1;
1762 
1763  g_free (n->mandatory_keys);
1764  if (mandatory_keys && mandatory_keys[0])
1765  n->mandatory_keys = g_strdup (mandatory_keys);
1766  else
1767  n->mandatory_keys = NULL;
1768  return 0;
1769 }
1770 
1781 int
1782 nvti_set_excluded_keys (nvti_t *n, const gchar *excluded_keys)
1783 {
1784  if (!n)
1785  return -1;
1786 
1787  g_free (n->excluded_keys);
1788  if (excluded_keys && excluded_keys[0])
1789  n->excluded_keys = g_strdup (excluded_keys);
1790  else
1791  n->excluded_keys = NULL;
1792  return 0;
1793 }
1794 
1805 int
1806 nvti_set_required_ports (nvti_t *n, const gchar *required_ports)
1807 {
1808  if (!n)
1809  return -1;
1810 
1811  g_free (n->required_ports);
1812  if (required_ports && required_ports[0])
1813  n->required_ports = g_strdup (required_ports);
1814  else
1815  n->required_ports = NULL;
1816  return 0;
1817 }
1818 
1829 int
1830 nvti_set_required_udp_ports (nvti_t *n, const gchar *required_udp_ports)
1831 {
1832  if (!n)
1833  return -1;
1834 
1835  g_free (n->required_udp_ports);
1836  if (required_udp_ports && required_udp_ports[0])
1837  n->required_udp_ports = g_strdup (required_udp_ports);
1838  else
1839  n->required_udp_ports = NULL;
1840  return 0;
1841 }
1842 
1852 int
1853 nvti_set_detection (nvti_t *n, const gchar *detection)
1854 {
1855  if (!n)
1856  return -1;
1857 
1858  g_free (n->detection);
1859  n->detection = g_strdup (detection);
1860  return 0;
1861 }
1862 
1872 int
1873 nvti_put_detection (nvti_t *n, gchar *detection)
1874 {
1875  if (!n)
1876  return -1;
1877 
1878  g_free (n->detection);
1879  n->detection = detection;
1880  return 0;
1881 }
1882 
1893 int
1894 nvti_set_qod_type (nvti_t *n, const gchar *qod_type)
1895 {
1896  if (!n)
1897  return -1;
1898 
1899  g_free (n->qod_type);
1900  if (qod_type && qod_type[0])
1901  n->qod_type = g_strdup (qod_type);
1902  else
1903  n->qod_type = NULL;
1904  return 0;
1905 }
1906 
1917 int
1918 nvti_set_qod (nvti_t *n, const gchar *qod)
1919 {
1920  if (!n)
1921  return -1;
1922 
1923  g_free (n->qod);
1924  if (qod && qod[0])
1925  n->qod = g_strdup (qod);
1926  else
1927  n->qod = NULL;
1928  return 0;
1929 }
1930 
1940 int
1941 nvti_set_family (nvti_t *n, const gchar *family)
1942 {
1943  if (!n)
1944  return -1;
1945 
1946  g_free (n->family);
1947  n->family = g_strdup (family);
1948  return 0;
1949 }
1950 
1960 int
1961 nvti_put_family (nvti_t *n, gchar *family)
1962 {
1963  if (!n)
1964  return -1;
1965 
1966  g_free (n->family);
1967  n->family = family;
1968  return 0;
1969 }
1970 
1980 int
1981 nvti_set_category (nvti_t *n, const gint category)
1982 {
1983  if (!n)
1984  return -1;
1985 
1986  n->category = category;
1987  return 0;
1988 }
1989 
2005 int
2006 nvti_add_refs (nvti_t *n, const gchar *type, const gchar *ref_ids,
2007  const gchar *ref_text)
2008 {
2009  gchar **split, **item;
2010 
2011  if (!n)
2012  return 1;
2013 
2014  if (!ref_ids)
2015  return 2;
2016 
2017  split = g_strsplit (ref_ids, ",", 0);
2018 
2019  for (item = split; *item; item++)
2020  {
2021  gchar *id;
2022 
2023  id = *item;
2024  g_strstrip (id);
2025 
2026  if (strcmp (id, "") == 0)
2027  continue;
2028 
2029  if (type)
2030  {
2031  nvti_add_vtref (n, vtref_new (type, id, ref_text));
2032  }
2033  else
2034  {
2035  gchar **split2;
2036 
2037  split2 = g_strsplit (id, ":", 2);
2038  if (split2[0] && split2[1])
2039  nvti_add_vtref (n, vtref_new (split2[0], split2[1], ""));
2040  g_strfreev (split2);
2041  }
2042  }
2043  g_strfreev (split);
2044 
2045  return 0;
2046 }
2047 
2057 int
2058 nvti_add_required_keys (nvti_t *n, const gchar *key)
2059 {
2060  gchar *old;
2061 
2062  if (!n)
2063  return 1;
2064  if (!key)
2065  return 2;
2066 
2067  old = n->required_keys;
2068 
2069  if (old)
2070  {
2071  n->required_keys = g_strdup_printf ("%s, %s", old, key);
2072  g_free (old);
2073  }
2074  else
2075  n->required_keys = g_strdup (key);
2076 
2077  return 0;
2078 }
2079 
2089 int
2090 nvti_add_mandatory_keys (nvti_t *n, const gchar *key)
2091 {
2092  gchar *old;
2093 
2094  if (!n)
2095  return 1;
2096  if (!key)
2097  return 2;
2098 
2099  old = n->mandatory_keys;
2100 
2101  if (old)
2102  {
2103  n->mandatory_keys = g_strdup_printf ("%s, %s", old, key);
2104  g_free (old);
2105  }
2106  else
2107  n->mandatory_keys = g_strdup (key);
2108 
2109  return 0;
2110 }
2111 
2121 int
2122 nvti_add_excluded_keys (nvti_t *n, const gchar *key)
2123 {
2124  gchar *old;
2125 
2126  if (!n)
2127  return 1;
2128  if (!key)
2129  return 2;
2130 
2131  old = n->excluded_keys;
2132 
2133  if (old)
2134  {
2135  n->excluded_keys = g_strdup_printf ("%s, %s", old, key);
2136  g_free (old);
2137  }
2138  else
2139  n->excluded_keys = g_strdup (key);
2140 
2141  return 0;
2142 }
2143 
2153 int
2154 nvti_add_required_ports (nvti_t *n, const gchar *port)
2155 {
2156  gchar *old;
2157 
2158  if (!n)
2159  return 1;
2160  if (!port)
2161  return 2;
2162 
2163  old = n->required_ports;
2164 
2165  if (old)
2166  {
2167  n->required_ports = g_strdup_printf ("%s, %s", old, port);
2168  g_free (old);
2169  }
2170  else
2171  n->required_ports = g_strdup (port);
2172 
2173  return 0;
2174 }
2175 
2185 int
2186 nvti_add_required_udp_ports (nvti_t *n, const gchar *port)
2187 {
2188  gchar *old;
2189 
2190  if (!n)
2191  return 1;
2192  if (!port)
2193  return 2;
2194 
2195  old = n->required_udp_ports;
2196 
2197  if (old)
2198  {
2199  n->required_udp_ports = g_strdup_printf ("%s, %s", old, port);
2200  g_free (old);
2201  }
2202  else
2203  n->required_udp_ports = g_strdup (port);
2204 
2205  return 0;
2206 }
2207 
2217 int
2219 {
2220  if (!n)
2221  return -1;
2222 
2223  n->prefs = g_slist_append (n->prefs, np);
2224  return 0;
2225 }
2226 
2227 /* Collections of nvtis. */
2228 
2234 static void
2236 {
2237  nvti_free ((nvti_t *) nvti);
2238 }
2239 
2245 nvtis_t *
2247 {
2248  return g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
2250 }
2251 
2257 void
2259 {
2260  if (nvtis)
2261  g_hash_table_destroy (nvtis);
2262 }
2263 
2270 void
2272 {
2273  if (nvti)
2274  g_hash_table_insert (
2275  nvtis, (gpointer) (nvti_oid (nvti) ? g_strdup (nvti_oid (nvti)) : NULL),
2276  (gpointer) nvti);
2277 }
2278 
2287 nvti_t *
2288 nvtis_lookup (nvtis_t *nvtis, const char *oid)
2289 {
2290  return g_hash_table_lookup (nvtis, oid);
2291 }
nvti_solution_type
gchar * nvti_solution_type(const nvti_t *n)
Get the solution type.
Definition: nvti.c:976
vtref_text
const gchar * vtref_text(const vtref_t *r)
Get the text of a reference.
Definition: nvti.c:146
nvti_pref
const nvtpref_t * nvti_pref(const nvti_t *n, guint p)
Get the n'th preferences of the NVT.
Definition: nvti.c:1224
nvti_add_vtref
int nvti_add_vtref(nvti_t *vt, vtref_t *ref)
Add a reference to the VT Info.
Definition: nvti.c:444
nvti::mandatory_keys
gchar * mandatory_keys
List of mandatory KB keys of this NVT.
Definition: nvti.c:415
nvti::insight
gchar * insight
The insight.
Definition: nvti.c:399
nvti_set_required_udp_ports
int nvti_set_required_udp_ports(nvti_t *n, const gchar *required_udp_ports)
Set the required udp ports of a NVT.
Definition: nvti.c:1830
vtref::ref_text
gchar * ref_text
Optional additional text.
Definition: nvti.c:61
nvti::required_keys
gchar * required_keys
List of required KB keys of this NVT.
Definition: nvti.c:414
nvtis_free
void nvtis_free(nvtis_t *nvtis)
Free a collection of NVT Infos.
Definition: nvti.c:2258
nvti_severity_vector_from_tag
gchar * nvti_severity_vector_from_tag(const nvti_t *n)
Get the severity score.
Definition: nvti.c:938
nvti_cvss_base
gchar * nvti_cvss_base(const nvti_t *n)
Get the CVSS base.
Definition: nvti.c:1056
nvti::severities
GSList * severities
Collection of VT severities.
Definition: nvti.c:426
nvti_put_summary
int nvti_put_summary(nvti_t *n, gchar *summary)
Set the summary of a NVT, using the given memory.
Definition: nvti.c:1332
nvti_t
struct nvti nvti_t
The structure of a information record that corresponds to a NVT.
nvtis_t
GHashTable nvtis_t
A collection of information records corresponding to NVTs.
Definition: nvti.h:252
nvti::solution_type
gchar * solution_type
The solution type.
Definition: nvti.c:407
nvti_set_creation_time
int nvti_set_creation_time(nvti_t *n, const time_t creation_time)
Set the creation time of a NVT.
Definition: nvti.c:1472
nvti_set_impact
int nvti_set_impact(nvti_t *n, const gchar *impact)
Set the impact text of a NVT.
Definition: nvti.c:1432
nvti_vtref_len
guint nvti_vtref_len(const nvti_t *n)
Get the number of references of the NVT.
Definition: nvti.c:760
nvti_set_required_keys
int nvti_set_required_keys(nvti_t *n, const gchar *required_keys)
Set the required keys of a NVT.
Definition: nvti.c:1734
nvti_family
gchar * nvti_family(const nvti_t *n)
Get the family name.
Definition: nvti.c:1196
nvtpref_t
struct nvtpref nvtpref_t
The structure for a preference of a NVT.
vtref
The structure for a cross reference of a VT.
Definition: nvti.c:58
nvti_insight
gchar * nvti_insight(const nvti_t *n)
Get the text about insight.
Definition: nvti.c:691
nvti_add_required_ports
int nvti_add_required_ports(nvti_t *n, const gchar *port)
Add a required port of a NVT.
Definition: nvti.c:2154
nvti_set_qod
int nvti_set_qod(nvti_t *n, const gchar *qod)
Set the QoD of a NVT.
Definition: nvti.c:1918
nvti_get_tag
gchar * nvti_get_tag(const nvti_t *n, const gchar *name)
Get a tag value by a tag name.
Definition: nvti.c:1020
nvti::detection
gchar * detection
Detection description.
Definition: nvti.c:421
vtseverity::score
double score
The score derived from the value in range [0.0-10.0].
Definition: nvti.c:164
nvti_detection
gchar * nvti_detection(const nvti_t *n)
Get the text about detection.
Definition: nvti.c:1154
nvti_oid
gchar * nvti_oid(const nvti_t *n)
Get the OID string.
Definition: nvti.c:649
vtseverity::value
gchar * value
The value which corresponds to the type.
Definition: nvti.c:165
nvti_severity_score
double nvti_severity_score(const nvti_t *n)
Get the maximum severity score.
Definition: nvti.c:906
nvti_vtseverities_len
guint nvti_vtseverities_len(const nvti_t *n)
Get the number of severities of the NVT.
Definition: nvti.c:878
nvti_set_insight
int nvti_set_insight(nvti_t *n, const gchar *insight)
Set the insight text of a NVT.
Definition: nvti.c:1352
nvti::solution_method
gchar * solution_method
The solution method.
Definition: nvti.c:408
nvti::name
gchar * name
The name.
Definition: nvti.c:396
nvti_add_required_keys
int nvti_add_required_keys(nvti_t *n, const gchar *key)
Add a required key of a NVT.
Definition: nvti.c:2058
nvti_add_pref
int nvti_add_pref(nvti_t *n, nvtpref_t *np)
Add a preference to the NVT Info.
Definition: nvti.c:2218
nvti::solution
gchar * solution
The solution.
Definition: nvti.c:406
nvtis_add
void nvtis_add(nvtis_t *nvtis, nvti_t *nvti)
Add an NVT Info to a collection of NVT Infos.
Definition: nvti.c:2271
nvti_set_cvss_base
int nvti_set_cvss_base(nvti_t *n, const gchar *cvss_base)
Set the CVSS base of an NVT.
Definition: nvti.c:1686
nvtpref::dflt
gchar * dflt
Default value of the preference.
Definition: nvti.c:481
nvti_set_solution_method
int nvti_set_solution_method(nvti_t *n, const gchar *solution_method)
Set the solution method of a NVT.
Definition: nvti.c:1572
nvti_add_vtseverity
int nvti_add_vtseverity(nvti_t *vt, vtseverity_t *s)
Add a severity to the VT Info.
Definition: nvti.c:462
vtseverity_score
double vtseverity_score(const vtseverity_t *s)
Get the score of a severity.
Definition: nvti.c:281
vtref::type
gchar * type
Reference type ("cve", "bid", ...)
Definition: nvti.c:59
nvti_put_affected
int nvti_put_affected(nvti_t *n, gchar *affected)
Set the affected text of a NVT, using the given memory.
Definition: nvti.c:1412
nvtpref_id
int nvtpref_id(const nvtpref_t *np)
Get the ID of a NVT Preference.
Definition: nvti.c:541
nvti_solution_method
gchar * nvti_solution_method(const nvti_t *n)
Get the solution method.
Definition: nvti.c:990
vtseverity_date
int vtseverity_date(const vtseverity_t *s)
Get the date of a severity.
Definition: nvti.c:267
nvti_set_name
int nvti_set_name(nvti_t *n, const gchar *name)
Set the name of a NVT.
Definition: nvti.c:1272
vtseverity_type
const gchar * vtseverity_type(const vtseverity_t *s)
Get the type of a severity.
Definition: nvti.c:225
nvti::creation_time
time_t creation_time
Time of creation, seconds since epoch.
Definition: nvti.c:403
nvti::cvss_base
gchar * cvss_base
CVSS base score for this NVT.
Definition: nvti.c:411
nvti_set_solution
int nvti_set_solution(nvti_t *n, const gchar *solution)
Set the solution of a NVT.
Definition: nvti.c:1510
nvti::affected
gchar * affected
Affected systems.
Definition: nvti.c:400
nvti::required_udp_ports
gchar * required_udp_ports
List of required UDP ports of this NVT.
Definition: nvti.c:419
nvti::category
gint category
The category, this NVT belongs to.
Definition: nvti.c:430
nvti_refs
gchar * nvti_refs(const nvti_t *n, const gchar *type, const gchar *exclude_types, guint use_types)
Get references as string.
Definition: nvti.c:804
nvti_required_udp_ports
gchar * nvti_required_udp_ports(const nvti_t *n)
Get the required udp ports list.
Definition: nvti.c:1140
nvti
The structure of a information record that corresponds to a NVT.
Definition: nvti.c:394
nvti_required_ports
gchar * nvti_required_ports(const nvti_t *n)
Get the required ports list.
Definition: nvti.c:1126
nvti_modification_time
time_t nvti_modification_time(const nvti_t *n)
Get the modification time.
Definition: nvti.c:747
nvti_put_impact
int nvti_put_impact(nvti_t *n, gchar *impact)
Set the impact text of a NVT, using the given memory.
Definition: nvti.c:1452
nvti_category
gint nvti_category(const nvti_t *n)
Get the category for this NVT.
Definition: nvti.c:1237
vtref_free
void vtref_free(vtref_t *ref)
Free memory of a vtref structure.
Definition: nvti.c:98
nvti_set_excluded_keys
int nvti_set_excluded_keys(nvti_t *n, const gchar *excluded_keys)
Set the excluded keys of a NVT.
Definition: nvti.c:1782
nvtpref::name
gchar * name
Name of the preference.
Definition: nvti.c:480
nvti_set_qod_type
int nvti_set_qod_type(nvti_t *n, const gchar *qod_type)
Set the QoD type of a NVT.
Definition: nvti.c:1894
nvti::oid
gchar * oid
Object ID.
Definition: nvti.c:395
nvti::excluded_keys
gchar * excluded_keys
List of excluded KB keys of this NVT.
Definition: nvti.c:416
vtseverity::type
gchar * type
Severity type ("cvss_base_v2", ...)
Definition: nvti.c:160
nvti_add_refs
int nvti_add_refs(nvti_t *n, const gchar *type, const gchar *ref_ids, const gchar *ref_text)
Add many new vtref from a comma-separated list.
Definition: nvti.c:2006
nvti_solution
gchar * nvti_solution(const nvti_t *n)
Get the solution.
Definition: nvti.c:962
nvti_free
void nvti_free(nvti_t *n)
Free memory of a nvti structure.
Definition: nvti.c:608
nvtis_new
nvtis_t * nvtis_new(void)
Make a collection of NVT Infos.
Definition: nvti.c:2246
nvti_impact
gchar * nvti_impact(const nvti_t *n)
Get the text about impact.
Definition: nvti.c:719
nvti_set_modification_time
int nvti_set_modification_time(nvti_t *n, const time_t modification_time)
Set the modification time of a NVT.
Definition: nvti.c:1491
nvtpref
The structure for a preference of a NVT.
Definition: nvti.c:477
vtref_t
struct vtref vtref_t
The structure for a cross reference of a VT.
vtseverity
The structure for a severity of a VT.
Definition: nvti.c:159
vtseverity_t
struct vtseverity vtseverity_t
The structure for a severity of a VT.
nvti_pref_len
guint nvti_pref_len(const nvti_t *n)
Get the number of preferences of the NVT.
Definition: nvti.c:1209
nvtpref_free
void nvtpref_free(nvtpref_t *np)
Free memory of a nvtpref structure.
Definition: nvti.c:521
nvti_set_dependencies
int nvti_set_dependencies(nvti_t *n, const gchar *dependencies)
Set the dependencies of a NVT.
Definition: nvti.c:1710
nvti_add_tag
int nvti_add_tag(nvti_t *n, const gchar *name, const gchar *value)
Add a tag to the NVT tags. The tag names "severity_date", "last_modification" and "creation_date" are...
Definition: nvti.c:1599
nvtpref::type
gchar * type
Preference type.
Definition: nvti.c:479
nvti::impact
gchar * impact
Impact of vulnerability.
Definition: nvti.c:401
vtref_new
vtref_t * vtref_new(const gchar *type, const gchar *ref_id, const gchar *ref_text)
Create a new vtref structure filled with the given values.
Definition: nvti.c:78
nvtis_lookup
nvti_t * nvtis_lookup(nvtis_t *nvtis, const char *oid)
Add an NVT Info to a collection of NVT Infos.
Definition: nvti.c:2288
nvti_put_detection
int nvti_put_detection(nvti_t *n, gchar *detection)
Set the detection text of a NVT, using the given memory.
Definition: nvti.c:1873
free_nvti_for_hash_table
static void free_nvti_for_hash_table(gpointer nvti)
Free an NVT Info, for g_hash_table_destroy.
Definition: nvti.c:2235
nvti_tag
gchar * nvti_tag(const nvti_t *n)
Get the tags.
Definition: nvti.c:1004
nvti_vtref
vtref_t * nvti_vtref(const nvti_t *n, guint p)
Get the n'th reference of the NVT.
Definition: nvti.c:775
nvti::summary
gchar * summary
The summary.
Definition: nvti.c:398
vtseverity::origin
gchar * origin
Definition: nvti.c:161
strings.h
String utilities.
nvti_set_tag
int nvti_set_tag(nvti_t *n, const gchar *tag)
Set the tags of a NVT.
Definition: nvti.c:1663
nvti_add_required_udp_ports
int nvti_add_required_udp_ports(nvti_t *n, const gchar *port)
Add a required udp port of a NVT.
Definition: nvti.c:2186
nvti::family
gchar * family
Family the NVT belongs to.
Definition: nvti.c:431
nvtpref::id
int id
Preference ID.
Definition: nvti.c:478
nvti::modification_time
time_t modification_time
Time of last change, sec. since epoch.
Definition: nvti.c:404
nvti_affected
gchar * nvti_affected(const nvti_t *n)
Get the text about affected systems.
Definition: nvti.c:705
nvtpref_name
gchar * nvtpref_name(const nvtpref_t *np)
Get the Name of a NVT Preference.
Definition: nvti.c:555
nvti_mandatory_keys
gchar * nvti_mandatory_keys(const nvti_t *n)
Get the mandatory keys list.
Definition: nvti.c:1098
nvti_dependencies
gchar * nvti_dependencies(const nvti_t *n)
Get the dependencies list.
Definition: nvti.c:1070
nvti_add_mandatory_keys
int nvti_add_mandatory_keys(nvti_t *n, const gchar *key)
Add a mandatory key of a NVT.
Definition: nvti.c:2090
nvti::dependencies
gchar * dependencies
List of dependencies of this NVT.
Definition: nvti.c:413
nvti_put_solution
int nvti_put_solution(nvti_t *n, gchar *solution)
Set the solution of a NVT, using the given memory.
Definition: nvti.c:1530
nvti_name
gchar * nvti_name(const nvti_t *n)
Get the name.
Definition: nvti.c:663
nvti::tag
gchar * tag
List of tags attached to this NVT.
Definition: nvti.c:410
nvti_excluded_keys
gchar * nvti_excluded_keys(const nvti_t *n)
Get the excluded keys list.
Definition: nvti.c:1112
nvti_put_family
int nvti_put_family(nvti_t *n, gchar *family)
Set the family of a NVT, using the given memory.
Definition: nvti.c:1961
nvti::required_ports
gchar * required_ports
List of required ports of this NVT.
Definition: nvti.c:417
nvti_set_required_ports
int nvti_set_required_ports(nvti_t *n, const gchar *required_ports)
Set the required ports of a NVT.
Definition: nvti.c:1806
nvti_qod_type
gchar * nvti_qod_type(const nvti_t *n)
Get the QoD type.
Definition: nvti.c:1168
nvti_set_summary
int nvti_set_summary(nvti_t *n, const gchar *summary)
Set the summary of a NVT.
Definition: nvti.c:1312
nvti::qod_type
gchar * qod_type
Quality of detection type.
Definition: nvti.c:422
nvti_qod
gchar * nvti_qod(const nvti_t *n)
Get the QoD.
Definition: nvti.c:1182
nvti_set_solution_type
int nvti_set_solution_type(nvti_t *n, const gchar *solution_type)
Set the solution type of a NVT.
Definition: nvti.c:1551
nvti_set_detection
int nvti_set_detection(nvti_t *n, const gchar *detection)
Set the detection text of a NVT.
Definition: nvti.c:1853
nvtpref_default
gchar * nvtpref_default(const nvtpref_t *np)
Get the Default of a NVT Preference.
Definition: nvti.c:583
vtseverity_new
vtseverity_t * vtseverity_new(const gchar *type, const gchar *origin, int date, double score, const gchar *value)
Create a new vtseverity structure filled with the given values.
Definition: nvti.c:182
nvti_put_insight
int nvti_put_insight(nvti_t *n, gchar *insight)
Set the insight text of a NVT, using the given memory.
Definition: nvti.c:1372
nvti::qod
gchar * qod
Quality of detection.
Definition: nvti.c:423
nvti_creation_time
time_t nvti_creation_time(const nvti_t *n)
Get the creation time.
Definition: nvti.c:733
nvti_new
nvti_t * nvti_new(void)
Create a new (empty) nvti structure.
Definition: nvti.c:597
nvti_set_affected
int nvti_set_affected(nvti_t *n, const gchar *affected)
Set the affected text of a NVT.
Definition: nvti.c:1392
nvtpref_type
gchar * nvtpref_type(const nvtpref_t *np)
Get the Type of a NVT Preference.
Definition: nvti.c:569
vtref_type
const gchar * vtref_type(const vtref_t *r)
Get the type of a reference.
Definition: nvti.c:118
vtseverity_origin
const gchar * vtseverity_origin(const vtseverity_t *s)
Get the origin of a severity.
Definition: nvti.c:239
nvti_set_family
int nvti_set_family(nvti_t *n, const gchar *family)
Set the family of a NVT.
Definition: nvti.c:1941
nvti_set_category
int nvti_set_category(nvti_t *n, const gint category)
Set the category type of a NVT Info.
Definition: nvti.c:1981
nvti_put_name
int nvti_put_name(nvti_t *n, gchar *name)
Set the name of a NVT, using the given memory.
Definition: nvti.c:1292
parse_nvt_timestamp
static time_t parse_nvt_timestamp(const gchar *str_time)
Try convert an NVT tag time string into epoch time or return 0 upon parse errors.
Definition: nvti.c:297
vtseverity_value
const gchar * vtseverity_value(const vtseverity_t *s)
Get the value of a severity.
Definition: nvti.c:253
nvti_set_oid
int nvti_set_oid(nvti_t *n, const gchar *oid)
Set the OID of a NVT Info.
Definition: nvti.c:1252
nvti_set_mandatory_keys
int nvti_set_mandatory_keys(nvti_t *n, const gchar *mandatory_keys)
Set the mandatory keys of a NVT.
Definition: nvti.c:1758
nvti_summary
gchar * nvti_summary(const nvti_t *n)
Get the summary.
Definition: nvti.c:677
nvti::prefs
GSList * prefs
Collection of NVT preferences.
Definition: nvti.c:427
nvti.h
Protos and data structures for NVT Information data sets.
nvti::refs
GSList * refs
Collection of VT references.
Definition: nvti.c:425
nvti_vtseverity
vtseverity_t * nvti_vtseverity(const nvti_t *n, guint p)
Get the n'th reference of the NVT.
Definition: nvti.c:893
nvti_add_excluded_keys
int nvti_add_excluded_keys(nvti_t *n, const gchar *key)
Add a excluded key of a NVT.
Definition: nvti.c:2122
vtref_id
const gchar * vtref_id(const vtref_t *r)
Get the id of a reference.
Definition: nvti.c:132
vtref::ref_id
gchar * ref_id
Actual reference ID ("CVE-2018-1234", etc)
Definition: nvti.c:60
nvti_required_keys
gchar * nvti_required_keys(const nvti_t *n)
Get the required keys list.
Definition: nvti.c:1084
nvtpref_new
nvtpref_t * nvtpref_new(int id, const gchar *name, const gchar *type, const gchar *dflt)
Create a new nvtpref structure filled with the given values.
Definition: nvti.c:500
vtseverity_free
void vtseverity_free(vtseverity_t *s)
Free memory of a vtseverity structure.
Definition: nvti.c:205
vtseverity::date
int date
Timestamp in seconds since epoch, defaults to VT creation date.
Definition: nvti.c:163