OpenVAS Libraries  9.0.3
nvti.h
Go to the documentation of this file.
1 /* openvas-libraries/base
2  * $Id$
3  * Description: API (structs and protos) for NVT Info datasets
4  *
5  * Authors:
6  * Jan-Oliver Wagner <jan-oliver.wagner@greenbone.net>
7  * Matthew Mundell <matthew.mundell@greenbone.net>
8  *
9  * Copyright:
10  * Copyright (C) 2009, 2011 Greenbone Networks GmbH
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25  */
26 
34 #ifndef _NVTI_H
35 #define _NVTI_H
36 
37 #include <glib.h>
38 
45 typedef struct nvtpref
46 {
47  gchar *type;
48  gchar *name;
49  gchar *dflt;
50 } nvtpref_t;
51 
52 nvtpref_t *nvtpref_new (gchar *, gchar *, gchar *);
53 void nvtpref_free (nvtpref_t *);
54 gchar *nvtpref_name (const nvtpref_t *);
55 gchar *nvtpref_type (const nvtpref_t *);
56 gchar *nvtpref_default (const nvtpref_t *);
57 
64 typedef struct nvti
65 {
66  gchar *oid;
67  gchar *version;
68  gchar *name;
69  gchar *copyright;
71  gchar *cve;
72  gchar *bid;
74  gchar *xref;
76  gchar *tag;
77  gchar *cvss_base;
79  gchar *dependencies;
80  gchar *required_keys;
81  gchar *mandatory_keys;
82  gchar *excluded_keys;
83  gchar *required_ports;
86  GSList *prefs;
88  // The following are not settled yet.
89  gint timeout;
90  gint category;
91  gchar *family;
92 } nvti_t;
93 
94 nvti_t *nvti_new (void);
95 void nvti_free (nvti_t *);
96 
97 gchar *nvti_oid (const nvti_t *);
98 gchar *nvti_version (const nvti_t *);
99 gchar *nvti_name (const nvti_t *);
100 gchar *nvti_copyright (const nvti_t *);
101 gchar *nvti_cve (const nvti_t *);
102 gchar *nvti_bid (const nvti_t *);
103 gchar *nvti_xref (const nvti_t *);
104 gchar *nvti_tag (const nvti_t *);
105 gchar *nvti_cvss_base (const nvti_t *);
106 gchar *nvti_dependencies (const nvti_t *);
107 gchar *nvti_required_keys (const nvti_t *);
108 gchar *nvti_mandatory_keys (const nvti_t *);
109 gchar *nvti_excluded_keys (const nvti_t *);
110 gchar *nvti_required_ports (const nvti_t *);
111 gchar *nvti_required_udp_ports (const nvti_t *);
112 gint nvti_timeout (const nvti_t *);
113 gint nvti_category (const nvti_t *);
114 gchar *nvti_family (const nvti_t *);
115 guint nvti_pref_len (const nvti_t *);
116 const nvtpref_t *nvti_pref (const nvti_t *, guint);
117 
118 int nvti_set_oid (nvti_t *, const gchar *);
119 int nvti_set_version (nvti_t *, const gchar *);
120 int nvti_set_name (nvti_t *, const gchar *);
121 int nvti_set_copyright (nvti_t *, const gchar *);
122 int nvti_set_cve (nvti_t *, const gchar *);
123 int nvti_set_bid (nvti_t *, const gchar *);
124 int nvti_set_xref (nvti_t *, const gchar *);
125 int nvti_set_tag (nvti_t *, const gchar *);
126 int nvti_set_cvss_base (nvti_t *, const gchar *);
127 int nvti_set_dependencies (nvti_t *, const gchar *);
128 int nvti_set_required_keys (nvti_t *, const gchar *);
129 int nvti_set_mandatory_keys (nvti_t *, const gchar *);
130 int nvti_set_excluded_keys (nvti_t *, const gchar *);
131 int nvti_set_required_ports (nvti_t *, const gchar *);
132 int nvti_set_required_udp_ports (nvti_t *, const gchar *);
133 int nvti_set_timeout (nvti_t *, const gint);
134 int nvti_set_category (nvti_t *, const gint);
135 int nvti_set_family (nvti_t *, const gchar *);
136 
137 int nvti_add_cve (nvti_t *, const gchar *);
138 int nvti_add_bid (nvti_t *, const gchar *);
139 int nvti_add_required_keys (nvti_t *, const gchar *);
140 int nvti_add_mandatory_keys (nvti_t *, const gchar *);
141 int nvti_add_excluded_keys (nvti_t *, const gchar *);
142 int nvti_add_required_ports (nvti_t *, const gchar *);
143 int nvti_add_required_udp_ports (nvti_t *, const gchar *);
144 int nvti_add_pref (nvti_t *, nvtpref_t *);
145 
146 /* Collections of NVT Infos. */
147 
151 typedef GHashTable nvtis_t;
152 
153 nvtis_t *
154 nvtis_new (void);
155 
156 void
157 nvtis_free (nvtis_t *);
158 
159 void
160 nvtis_add (nvtis_t *, nvti_t *);
161 
162 nvti_t *
163 nvtis_lookup (nvtis_t *, const char *);
164 
165 #endif /* not _NVTI_H */
nvti::mandatory_keys
gchar * mandatory_keys
List of mandatory KB keys of this NVT.
Definition: nvti.h:81
nvti_set_copyright
int nvti_set_copyright(nvti_t *, const gchar *)
Set the copyright of a NVT.
Definition: nvti.c:561
nvti::required_keys
gchar * required_keys
List of required KB keys of this NVT.
Definition: nvti.h:80
nvti_new
nvti_t * nvti_new(void)
Create a new (empty) nvti structure.
Definition: nvti.c:151
nvti::xref
gchar * xref
List of Cross-references, this NVT corresponds to.
Definition: nvti.h:74
nvtis_t
GHashTable nvtis_t
A collection of information records corresponding to NVTs.
Definition: nvti.h:151
nvti_set_family
int nvti_set_family(nvti_t *, const gchar *)
Set the family of a NVT.
Definition: nvti.c:840
nvti_oid
gchar * nvti_oid(const nvti_t *)
Get the OID string.
Definition: nvti.c:218
nvti_xref
gchar * nvti_xref(const nvti_t *)
Get the xref's.
Definition: nvti.c:302
nvti::copyright
gchar * copyright
Copyright for the NVT.
Definition: nvti.h:69
nvtpref_new
nvtpref_t * nvtpref_new(gchar *, gchar *, gchar *)
Create a new nvtpref structure filled with the given values.
Definition: nvti.c:63
nvti_set_mandatory_keys
int nvti_set_mandatory_keys(nvti_t *, const gchar *)
Set the mandatory keys of a NVT.
Definition: nvti.c:744
nvti::name
gchar * name
The name.
Definition: nvti.h:68
nvti::version
gchar * version
Version of the NVT.
Definition: nvti.h:67
nvtis_new
nvtis_t * nvtis_new(void)
Make a collection of NVT Infos.
Definition: nvti.c:1135
nvti_copyright
gchar * nvti_copyright(const nvti_t *)
Get the copyright notice.
Definition: nvti.c:260
nvti_set_dependencies
int nvti_set_dependencies(nvti_t *, const gchar *)
Set the dependencies of a NVT.
Definition: nvti.c:696
nvti::bid
gchar * bid
List of Bugtraq IDs, this NVT corresponds to.
Definition: nvti.h:72
nvti_add_pref
int nvti_add_pref(nvti_t *, nvtpref_t *)
Add a preference to the NVT Info.
Definition: nvti.c:1109
nvtpref::dflt
gchar * dflt
Default value of the preference.
Definition: nvti.h:49
nvti_set_required_udp_ports
int nvti_set_required_udp_ports(nvti_t *, const gchar *)
Set the required udp ports of a NVT.
Definition: nvti.c:816
nvtpref_free
void nvtpref_free(nvtpref_t *)
Free memory of a nvtpref structure.
Definition: nvti.c:86
nvtpref_t
struct nvtpref nvtpref_t
The structure for a preference of a NVT.
nvti_cve
gchar * nvti_cve(const nvti_t *)
Get the CVE references.
Definition: nvti.c:274
nvti_t
struct nvti nvti_t
The structure of a information record that corresponds to a NVT.
nvti::timeout
gint timeout
Default timeout time for this NVT.
Definition: nvti.h:89
nvti_pref_len
guint nvti_pref_len(const nvti_t *)
Get the number of preferences of the NVT.
Definition: nvti.c:441
nvti::cvss_base
gchar * cvss_base
CVSS base score for this NVT.
Definition: nvti.h:77
nvti_tag
gchar * nvti_tag(const nvti_t *)
Get the tag.
Definition: nvti.c:316
nvti::required_udp_ports
gchar * required_udp_ports
List of required UDP ports of this NVT.
Definition: nvti.h:84
nvti::category
gint category
The category, this NVT belongs to.
Definition: nvti.h:90
nvti
The structure of a information record that corresponds to a NVT.
Definition: nvti.h:64
nvtpref::name
gchar * name
Name of the preference.
Definition: nvti.h:48
nvti_timeout
gint nvti_timeout(const nvti_t *)
Get the timeout for this NVT.
Definition: nvti.c:470
nvti::oid
gchar * oid
Object ID.
Definition: nvti.h:66
nvti_set_name
int nvti_set_name(nvti_t *, const gchar *)
Set the name of a NVT.
Definition: nvti.c:540
nvti_dependencies
gchar * nvti_dependencies(const nvti_t *)
Get the dependencies list.
Definition: nvti.c:344
nvti::excluded_keys
gchar * excluded_keys
List of excluded KB keys of this NVT.
Definition: nvti.h:82
nvti_family
gchar * nvti_family(const nvti_t *)
Get the family name.
Definition: nvti.c:428
nvti_pref
const nvtpref_t * nvti_pref(const nvti_t *, guint)
Get the n'th preferences of the NVT.
Definition: nvti.c:456
nvti::cve
gchar * cve
List of CVEs, this NVT corresponds to.
Definition: nvti.h:71
nvtpref
The structure for a preference of a NVT.
Definition: nvti.h:45
nvti_add_excluded_keys
int nvti_add_excluded_keys(nvti_t *, const gchar *)
Add a excluded key of a NVT.
Definition: nvti.c:1019
nvti_set_oid
int nvti_set_oid(nvti_t *, const gchar *)
Set the OID of a NVT Info.
Definition: nvti.c:498
nvti_set_category
int nvti_set_category(nvti_t *, const gint)
Set the category type of a NVT Info.
Definition: nvti.c:880
nvti_name
gchar * nvti_name(const nvti_t *)
Get the name.
Definition: nvti.c:246
nvtpref_type
gchar * nvtpref_type(const nvtpref_t *)
Get the Type of a NVT Preference.
Definition: nvti.c:123
nvti_set_bid
int nvti_set_bid(nvti_t *, const gchar *)
Set the bid references of a NVT.
Definition: nvti.c:603
nvtpref::type
gchar * type
Preference type.
Definition: nvti.h:47
nvtpref_name
gchar * nvtpref_name(const nvtpref_t *)
Get the Name of a NVT Preference.
Definition: nvti.c:109
nvti_cvss_base
gchar * nvti_cvss_base(const nvti_t *)
Get the CVSS base.
Definition: nvti.c:330
nvti_required_ports
gchar * nvti_required_ports(const nvti_t *)
Get the required ports list.
Definition: nvti.c:400
nvti_required_keys
gchar * nvti_required_keys(const nvti_t *)
Get the required keys list.
Definition: nvti.c:358
nvti_add_required_udp_ports
int nvti_add_required_udp_ports(nvti_t *, const gchar *)
Add a required udp port of a NVT.
Definition: nvti.c:1079
nvti::family
gchar * family
Family the NVT belongs to.
Definition: nvti.h:91
nvti_set_cvss_base
int nvti_set_cvss_base(nvti_t *, const gchar *)
Set the CVSS base of an NVT.
Definition: nvti.c:672
nvti_add_cve
int nvti_add_cve(nvti_t *, const gchar *)
Add a single CVE ID of a NVT.
Definition: nvti.c:899
nvti_add_required_keys
int nvti_add_required_keys(nvti_t *, const gchar *)
Add a required key of a NVT.
Definition: nvti.c:959
nvti::dependencies
gchar * dependencies
List of dependencies of this NVT.
Definition: nvti.h:79
nvti_free
void nvti_free(nvti_t *)
Free memory of a nvti structure.
Definition: nvti.c:162
nvti_set_required_ports
int nvti_set_required_ports(nvti_t *, const gchar *)
Set the required ports of a NVT.
Definition: nvti.c:792
nvti_bid
gchar * nvti_bid(const nvti_t *)
Get the bid references.
Definition: nvti.c:288
nvtis_free
void nvtis_free(nvtis_t *)
Free a collection of NVT Infos.
Definition: nvti.c:1147
nvti::tag
gchar * tag
List of tags attached to this NVT.
Definition: nvti.h:76
nvti_set_version
int nvti_set_version(nvti_t *, const gchar *)
Set the version of a NVT.
Definition: nvti.c:519
nvtis_add
void nvtis_add(nvtis_t *, nvti_t *)
Add an NVT Info to a collection of NVT Infos.
Definition: nvti.c:1160
nvti_required_udp_ports
gchar * nvti_required_udp_ports(const nvti_t *)
Get the required udp ports list.
Definition: nvti.c:414
nvti::required_ports
gchar * required_ports
List of required ports of this NVT.
Definition: nvti.h:83
nvti_set_required_keys
int nvti_set_required_keys(nvti_t *, const gchar *)
Set the required keys of a NVT.
Definition: nvti.c:720
nvti_add_bid
int nvti_add_bid(nvti_t *, const gchar *)
Add a single BID ID of a NVT.
Definition: nvti.c:929
nvti_set_excluded_keys
int nvti_set_excluded_keys(nvti_t *, const gchar *)
Set the excluded keys of a NVT.
Definition: nvti.c:768
nvti_set_timeout
int nvti_set_timeout(nvti_t *, const gint)
Set the timout of a NVT Info.
Definition: nvti.c:861
nvti_category
gint nvti_category(const nvti_t *)
Get the category for this NVT.
Definition: nvti.c:483
nvti_add_required_ports
int nvti_add_required_ports(nvti_t *, const gchar *)
Add a required port of a NVT.
Definition: nvti.c:1049
nvtis_lookup
nvti_t * nvtis_lookup(nvtis_t *, const char *)
Add an NVT Info to a collection of NVT Infos.
Definition: nvti.c:1175
nvti_excluded_keys
gchar * nvti_excluded_keys(const nvti_t *)
Get the excluded keys list.
Definition: nvti.c:386
nvti_set_cve
int nvti_set_cve(nvti_t *, const gchar *)
Set the CVE references of a NVT.
Definition: nvti.c:582
nvtpref_default
gchar * nvtpref_default(const nvtpref_t *)
Get the Default of a NVT Preference.
Definition: nvti.c:137
nvti_set_tag
int nvti_set_tag(nvti_t *, const gchar *)
Set the tags of a NVT.
Definition: nvti.c:648
nvti_version
gchar * nvti_version(const nvti_t *)
Get the version.
Definition: nvti.c:232
nvti::prefs
GSList * prefs
Collection of NVT preferences.
Definition: nvti.h:86
nvti_mandatory_keys
gchar * nvti_mandatory_keys(const nvti_t *)
Get the mandatory keys list.
Definition: nvti.c:372
nvti_add_mandatory_keys
int nvti_add_mandatory_keys(nvti_t *, const gchar *)
Add a mandatory key of a NVT.
Definition: nvti.c:989
nvti_set_xref
int nvti_set_xref(nvti_t *, const gchar *)
Set the xrefs of a NVT.
Definition: nvti.c:624