Greenbone Vulnerability Management Libraries  10.0.0
nvti.h
Go to the documentation of this file.
1 /* Copyright (C) 2009-2019 Greenbone Networks GmbH
2  *
3  * SPDX-License-Identifier: GPL-2.0-or-later
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
27 #ifndef _NVTI_H
28 #define _NVTI_H
29 
30 #include <glib.h>
31 
38 typedef struct nvtpref
39 {
40  gchar *type;
41  gchar *name;
42  gchar *dflt;
43 } nvtpref_t;
44 
45 nvtpref_t *
46 nvtpref_new (gchar *, gchar *, gchar *);
47 void
49 gchar *
50 nvtpref_name (const nvtpref_t *);
51 gchar *
52 nvtpref_type (const nvtpref_t *);
53 gchar *
54 nvtpref_default (const nvtpref_t *);
55 
62 typedef struct nvti
63 {
64  gchar *oid;
65  gchar *name;
67  gchar *cve;
68  gchar *bid;
70  gchar *xref;
72  gchar *tag;
73  gchar *cvss_base;
75  gchar *dependencies;
76  gchar *required_keys;
77  gchar *mandatory_keys;
78  gchar *excluded_keys;
79  gchar *required_ports;
80  gchar
83  GSList *prefs;
85  // The following are not settled yet.
86  gint timeout;
87  gint category;
88  gchar *family;
89 } nvti_t;
90 
91 nvti_t *
92 nvti_new (void);
93 void
94 nvti_free (nvti_t *);
95 
96 gchar *
97 nvti_oid (const nvti_t *);
98 gchar *
99 nvti_name (const nvti_t *);
100 gchar *
101 nvti_cve (const nvti_t *);
102 gchar *
103 nvti_bid (const nvti_t *);
104 gchar *
105 nvti_xref (const nvti_t *);
106 gchar *
107 nvti_tag (const nvti_t *);
108 gchar *
109 nvti_cvss_base (const nvti_t *);
110 gchar *
111 nvti_dependencies (const nvti_t *);
112 gchar *
113 nvti_required_keys (const nvti_t *);
114 gchar *
115 nvti_mandatory_keys (const nvti_t *);
116 gchar *
117 nvti_excluded_keys (const nvti_t *);
118 gchar *
119 nvti_required_ports (const nvti_t *);
120 gchar *
122 gint
123 nvti_timeout (const nvti_t *);
124 gint
125 nvti_category (const nvti_t *);
126 gchar *
127 nvti_family (const nvti_t *);
128 guint
129 nvti_pref_len (const nvti_t *);
130 const nvtpref_t *
131 nvti_pref (const nvti_t *, guint);
132 
133 int
134 nvti_set_oid (nvti_t *, const gchar *);
135 int
136 nvti_set_name (nvti_t *, const gchar *);
137 int
138 nvti_set_cve (nvti_t *, const gchar *);
139 int
140 nvti_set_bid (nvti_t *, const gchar *);
141 int
142 nvti_set_xref (nvti_t *, const gchar *);
143 int
144 nvti_set_tag (nvti_t *, const gchar *);
145 int
146 nvti_set_cvss_base (nvti_t *, const gchar *);
147 int
148 nvti_set_dependencies (nvti_t *, const gchar *);
149 int
150 nvti_set_required_keys (nvti_t *, const gchar *);
151 int
152 nvti_set_mandatory_keys (nvti_t *, const gchar *);
153 int
154 nvti_set_excluded_keys (nvti_t *, const gchar *);
155 int
156 nvti_set_required_ports (nvti_t *, const gchar *);
157 int
158 nvti_set_required_udp_ports (nvti_t *, const gchar *);
159 int
160 nvti_set_timeout (nvti_t *, const gint);
161 int
162 nvti_set_category (nvti_t *, const gint);
163 int
164 nvti_set_family (nvti_t *, const gchar *);
165 
166 int
167 nvti_add_cve (nvti_t *, const gchar *);
168 int
169 nvti_add_bid (nvti_t *, const gchar *);
170 int
171 nvti_add_required_keys (nvti_t *, const gchar *);
172 int
173 nvti_add_mandatory_keys (nvti_t *, const gchar *);
174 int
175 nvti_add_excluded_keys (nvti_t *, const gchar *);
176 int
177 nvti_add_required_ports (nvti_t *, const gchar *);
178 int
179 nvti_add_required_udp_ports (nvti_t *, const gchar *);
180 int
182 
183 /* Collections of NVT Infos. */
184 
188 typedef GHashTable nvtis_t;
189 
190 nvtis_t *
191 nvtis_new (void);
192 
193 void
194 nvtis_free (nvtis_t *);
195 
196 void
197 nvtis_add (nvtis_t *, nvti_t *);
198 
199 nvti_t *
200 nvtis_lookup (nvtis_t *, const char *);
201 
202 #endif /* not _NVTI_H */
nvtpref_t * nvtpref_new(gchar *, gchar *, gchar *)
Create a new nvtpref structure filled with the given values.
Definition: nvti.c:68
int nvti_set_cve(nvti_t *, const gchar *)
Set the CVE references of a NVT.
Definition: nvti.c:513
struct nvtpref nvtpref_t
The structure for a preference of a NVT.
void nvti_free(nvti_t *)
Free memory of a nvti structure.
Definition: nvti.c:167
const nvtpref_t * nvti_pref(const nvti_t *, guint)
Get the n'th preferences of the NVT.
Definition: nvti.c:429
int nvti_set_excluded_keys(nvti_t *, const gchar *)
Set the excluded keys of a NVT.
Definition: nvti.c:703
gchar * nvti_tag(const nvti_t *)
Get the tag.
Definition: nvti.c:289
gchar * required_keys
List of required KB keys of this NVT.
Definition: nvti.h:76
int nvti_add_pref(nvti_t *, nvtpref_t *)
Add a preference to the NVT Info.
Definition: nvti.c:1060
int nvti_set_required_keys(nvti_t *, const gchar *)
Set the required keys of a NVT.
Definition: nvti.c:653
nvti_t * nvtis_lookup(nvtis_t *, const char *)
Add an NVT Info to a collection of NVT Infos.
Definition: nvti.c:1128
gchar * cvss_base
CVSS base score for this NVT.
Definition: nvti.h:73
gchar * name
Name of the preference.
Definition: nvti.h:41
The structure of a information record that corresponds to a NVT.
Definition: nvti.h:62
gint timeout
Default timeout time for this NVT.
Definition: nvti.h:86
gchar * nvti_family(const nvti_t *)
Get the family name.
Definition: nvti.c:401
gchar * bid
List of Bugtraq IDs, this NVT corresponds to.
Definition: nvti.h:68
int nvti_set_tag(nvti_t *, const gchar *)
Set the tags of a NVT.
Definition: nvti.c:579
gint nvti_category(const nvti_t *)
Get the category for this NVT.
Definition: nvti.c:456
int nvti_set_oid(nvti_t *, const gchar *)
Set the OID of a NVT Info.
Definition: nvti.c:471
gchar * name
The name.
Definition: nvti.h:65
int nvti_set_category(nvti_t *, const gint)
Set the category type of a NVT Info.
Definition: nvti.c:817
gchar * oid
Object ID.
Definition: nvti.h:64
int nvti_set_name(nvti_t *, const gchar *)
Set the name of a NVT.
Definition: nvti.c:492
gchar * nvtpref_type(const nvtpref_t *)
Get the Type of a NVT Preference.
Definition: nvti.c:128
gint category
The category, this NVT belongs to.
Definition: nvti.h:87
int nvti_add_excluded_keys(nvti_t *, const gchar *)
Add a excluded key of a NVT.
Definition: nvti.c:964
void nvtis_free(nvtis_t *)
Free a collection of NVT Infos.
Definition: nvti.c:1100
gchar * nvti_mandatory_keys(const nvti_t *)
Get the mandatory keys list.
Definition: nvti.c:345
gchar * nvtpref_name(const nvtpref_t *)
Get the Name of a NVT Preference.
Definition: nvti.c:114
nvti_t * nvti_new(void)
Create a new (empty) nvti structure.
Definition: nvti.c:156
gchar * nvti_cvss_base(const nvti_t *)
Get the CVSS base.
Definition: nvti.c:303
int nvti_add_mandatory_keys(nvti_t *, const gchar *)
Add a mandatory key of a NVT.
Definition: nvti.c:932
int nvti_set_family(nvti_t *, const gchar *)
Set the family of a NVT.
Definition: nvti.c:777
gchar * nvti_bid(const nvti_t *)
Get the bid references.
Definition: nvti.c:261
gchar * type
Preference type.
Definition: nvti.h:40
int nvti_add_cve(nvti_t *, const gchar *)
Add a single CVE ID of a NVT.
Definition: nvti.c:836
int nvti_add_required_keys(nvti_t *, const gchar *)
Add a required key of a NVT.
Definition: nvti.c:900
gchar * nvti_oid(const nvti_t *)
Get the OID string.
Definition: nvti.c:219
int nvti_add_bid(nvti_t *, const gchar *)
Add a single BID ID of a NVT.
Definition: nvti.c:868
int nvti_set_required_ports(nvti_t *, const gchar *)
Set the required ports of a NVT.
Definition: nvti.c:728
void nvtis_add(nvtis_t *, nvti_t *)
Add an NVT Info to a collection of NVT Infos.
Definition: nvti.c:1113
gchar * required_udp_ports
List of required UDP ports of this NVT.
Definition: nvti.h:81
int nvti_set_dependencies(nvti_t *, const gchar *)
Set the dependencies of a NVT.
Definition: nvti.c:628
gchar * nvtpref_default(const nvtpref_t *)
Get the Default of a NVT Preference.
Definition: nvti.c:142
gchar * cve
List of CVEs, this NVT corresponds to.
Definition: nvti.h:67
nvtis_t * nvtis_new(void)
Make a collection of NVT Infos.
Definition: nvti.c:1088
gchar * nvti_cve(const nvti_t *)
Get the CVE references.
Definition: nvti.c:247
gchar * excluded_keys
List of excluded KB keys of this NVT.
Definition: nvti.h:78
gchar * nvti_excluded_keys(const nvti_t *)
Get the excluded keys list.
Definition: nvti.c:359
gchar * dependencies
List of dependencies of this NVT.
Definition: nvti.h:75
gchar * dflt
Default value of the preference.
Definition: nvti.h:42
gchar * nvti_name(const nvti_t *)
Get the name.
Definition: nvti.c:233
int nvti_add_required_ports(nvti_t *, const gchar *)
Add a required port of a NVT.
Definition: nvti.c:996
guint nvti_pref_len(const nvti_t *)
Get the number of preferences of the NVT.
Definition: nvti.c:414
int nvti_set_xref(nvti_t *, const gchar *)
Set the xrefs of a NVT.
Definition: nvti.c:555
gchar * nvti_required_ports(const nvti_t *)
Get the required ports list.
Definition: nvti.c:373
gchar * required_ports
List of required ports of this NVT.
Definition: nvti.h:79
gint nvti_timeout(const nvti_t *)
Get the timeout for this NVT.
Definition: nvti.c:443
gchar * family
Family the NVT belongs to.
Definition: nvti.h:88
int nvti_set_cvss_base(nvti_t *, const gchar *)
Set the CVSS base of an NVT.
Definition: nvti.c:603
int nvti_set_bid(nvti_t *, const gchar *)
Set the bid references of a NVT.
Definition: nvti.c:534
The structure for a preference of a NVT.
Definition: nvti.h:38
gchar * nvti_dependencies(const nvti_t *)
Get the dependencies list.
Definition: nvti.c:317
gchar * mandatory_keys
List of mandatory KB keys of this NVT.
Definition: nvti.h:77
gchar * tag
List of tags attached to this NVT.
Definition: nvti.h:72
struct nvti nvti_t
The structure of a information record that corresponds to a NVT.
gchar * nvti_xref(const nvti_t *)
Get the xref's.
Definition: nvti.c:275
gchar * nvti_required_keys(const nvti_t *)
Get the required keys list.
Definition: nvti.c:331
int nvti_add_required_udp_ports(nvti_t *, const gchar *)
Add a required udp port of a NVT.
Definition: nvti.c:1028
GHashTable nvtis_t
A collection of information records corresponding to NVTs.
Definition: nvti.h:188
int nvti_set_mandatory_keys(nvti_t *, const gchar *)
Set the mandatory keys of a NVT.
Definition: nvti.c:678
gchar * xref
List of Cross-references, this NVT corresponds to.
Definition: nvti.h:70
int nvti_set_required_udp_ports(nvti_t *, const gchar *)
Set the required udp ports of a NVT.
Definition: nvti.c:753
gchar * nvti_required_udp_ports(const nvti_t *)
Get the required udp ports list.
Definition: nvti.c:387
int nvti_set_timeout(nvti_t *, const gint)
Set the timeout of a NVT Info.
Definition: nvti.c:798
GSList * prefs
Collection of NVT preferences.
Definition: nvti.h:83
void nvtpref_free(nvtpref_t *)
Free memory of a nvtpref structure.
Definition: nvti.c:91