OpenVAS Manager  7.0.3~git
manage_config_system_discovery.c File Reference
#include "manage.h"
#include "manage_sql.h"
#include "sql.h"
#include <assert.h>
Include dependency graph for manage_config_system_discovery.c:

Go to the source code of this file.

Macros

#define G_LOG_DOMAIN   "md main"
 GLib log domain. More...
 

Functions

void make_config_system_discovery (char *const uuid, char *const selector_name)
 Make System Discovery Scan Config. More...
 
int check_config_system_discovery (const char *uuid)
 Ensure the Discovery config is up to date. More...
 

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "md main"

GLib log domain.

Definition at line 36 of file manage_config_system_discovery.c.

Function Documentation

◆ check_config_system_discovery()

int check_config_system_discovery ( const char *  uuid)

Ensure the Discovery config is up to date.

Parameters
[in]uuidUUID of config.
Returns
0 success, -1 error.

Definition at line 202 of file manage_config_system_discovery.c.

203 {
204  int update;
205 
206  update = 0;
207 
208  /* Check new NVT. */
209 
210  if (sql_int ("SELECT count (*) FROM nvt_selectors"
211  " WHERE name = (SELECT nvt_selector FROM configs"
212  " WHERE uuid = '%s')"
213  " AND family_or_nvt = '1.3.6.1.4.1.25623.1.0.51662';",
214  uuid)
215  == 0)
216  {
217  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
218  " VALUES ((SELECT nvt_selector FROM configs WHERE uuid = '%s'), 0,"
219  " " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
220  " '1.3.6.1.4.1.25623.1.0.51662', 'General');",
221  uuid);
222  update = 1;
223  }
224 
225  if (update)
227 
228  return 0;
229 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
#define NVT_SELECTOR_TYPE_NVT
NVT selector type for "NVT" rule.
Definition: manage.h:2001
void update_config_cache_init(const char *)

References NVT_SELECTOR_TYPE_NVT, sql(), sql_int(), and update_config_cache_init().

Here is the call graph for this function:

◆ make_config_system_discovery()

void make_config_system_discovery ( char *const  uuid,
char *const  selector_name 
)

Make System Discovery Scan Config.

Caller must lock the db.

Parameters
[in]uuidUUID for new scan config.
[in]selector_nameName of NVT selector to use.

Definition at line 47 of file manage_config_system_discovery.c.

48 {
49  config_t config;
50 
51  /* Create the System Discovery config. */
52 
53  sql ("INSERT into configs (uuid, name, owner, nvt_selector, comment,"
54  " family_count, nvt_count, nvts_growing, families_growing,"
55  " type, creation_time, modification_time)"
56  " VALUES ('%s', 'System Discovery', NULL,"
57  " '%s', 'Network System Discovery scan configuration.',"
58  " 0, 0, 0, 0, 0, m_now (), m_now ());",
59  uuid,
60  selector_name);
61 
62  config = sql_last_insert_id ();
63 
64  /* Add NVTs to the config. */
65 
66  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
67  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
68  " '1.3.6.1.4.1.25623.1.0.100315', 'Port scanners');",
69  selector_name);
70  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
71  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
72  " '1.3.6.1.4.1.25623.1.0.14259', 'Port scanners');",
73  selector_name);
74  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
75  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
76  " '1.3.6.1.4.1.25623.1.0.50282', 'General');",
77  selector_name);
78  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
79  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
80  " '1.3.6.1.4.1.25623.1.0.51662', 'General');",
81  selector_name);
82  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
83  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
84  " '1.3.6.1.4.1.25623.1.0.96207', 'Windows');",
85  selector_name);
86  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
87  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
88  " '1.3.6.1.4.1.25623.1.0.103621', 'Windows');",
89  selector_name);
90  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
91  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
92  " '1.3.6.1.4.1.25623.1.0.103220', 'Product detection');",
93  selector_name);
94  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
95  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
96  " '1.3.6.1.4.1.25623.1.0.102002', 'Product detection');",
97  selector_name);
98  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
99  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
100  " '1.3.6.1.4.1.25623.1.0.103633', 'Product detection');",
101  selector_name);
102  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
103  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
104  " '1.3.6.1.4.1.25623.1.0.103804', 'Product detection');",
105  selector_name);
106  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
107  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
108  " '1.3.6.1.4.1.25623.1.0.96200', 'Product detection');",
109  selector_name);
110  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
111  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
112  " '1.3.6.1.4.1.25623.1.0.103675', 'Product detection');",
113  selector_name);
114  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
115  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
116  " '1.3.6.1.4.1.25623.1.0.103817', 'Product detection');",
117  selector_name);
118  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
119  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
120  " '1.3.6.1.4.1.25623.1.0.103628', 'Product detection');",
121  selector_name);
122  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
123  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
124  " '1.3.6.1.4.1.25623.1.0.803719', 'Product detection');",
125  selector_name);
126  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
127  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
128  " '1.3.6.1.4.1.25623.1.0.103799', 'Product detection');",
129  selector_name);
130  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
131  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
132  " '1.3.6.1.4.1.25623.1.0.103685', 'Product detection');",
133  selector_name);
134  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
135  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
136  " '1.3.6.1.4.1.25623.1.0.103809', 'Product detection');",
137  selector_name);
138  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
139  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
140  " '1.3.6.1.4.1.25623.1.0.103707', 'Product detection');",
141  selector_name);
142  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
143  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
144  " '1.3.6.1.4.1.25623.1.0.103418', 'Product detection');",
145  selector_name);
146  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
147  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
148  " '1.3.6.1.4.1.25623.1.0.10267', 'Product detection');",
149  selector_name);
150  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
151  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
152  " '1.3.6.1.4.1.25623.1.0.103417', 'Product detection');",
153  selector_name);
154  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
155  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
156  " '1.3.6.1.4.1.25623.1.0.103648', 'Product detection');",
157  selector_name);
158  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
159  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
160  " '1.3.6.1.4.1.25623.1.0.103779', 'Product detection');",
161  selector_name);
162  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
163  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
164  " '1.3.6.1.4.1.25623.1.0.103997', 'Service detection');",
165  selector_name);
166  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
167  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
168  " '1.3.6.1.4.1.25623.1.0.10884', 'Service detection');",
169  selector_name);
170  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
171  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
172  " '1.3.6.1.4.1.25623.1.0.102011', 'Service detection');",
173  selector_name);
174  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
175  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
176  " '1.3.6.1.4.1.25623.1.0.101013', 'Service detection');",
177  selector_name);
178  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
179  " VALUES ('%s', 0, " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
180  " '1.3.6.1.4.1.25623.1.0.103416', 'SNMP');",
181  selector_name);
182 
183  /* Update number of families and nvts. */
184 
185  sql ("UPDATE configs"
186  " SET family_count = %i, nvt_count = %i,"
187  " modification_time = m_now ()"
188  " WHERE id = %llu;",
189  nvt_selector_family_count (selector_name, 0),
190  nvt_selector_nvt_count (selector_name, NULL, 0),
191  config);
192 }
long long int config_t
Definition: manage.h:278
resource_t sql_last_insert_id()
Get the ID of the last inserted row.
Definition: sql_pg.c:395
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
#define NVT_SELECTOR_TYPE_NVT
NVT selector type for "NVT" rule.
Definition: manage.h:2001
int nvt_selector_nvt_count(const char *, const char *, int)
int nvt_selector_family_count(const char *, int)

References nvt_selector_family_count(), nvt_selector_nvt_count(), NVT_SELECTOR_TYPE_NVT, sql(), and sql_last_insert_id().

Here is the call graph for this function: