1 /* Copyright (C) 2019-2020 Greenbone Networks GmbH
2  *
3  * SPDX-License-Identifier: AGPL-3.0-or-later
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as
7  * published by the Free Software Foundation, either version 3 of the
8  * 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 Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef _GVMD_MANAGE_SQL_CONFIGS_H
20 #define _GVMD_MANAGE_SQL_CONFIGS_H
21 
22 #include "manage.h"
23 
24 /**
25  * @brief Filter columns for scan configs iterator.
26  */
27 #define CONFIG_ITERATOR_FILTER_COLUMNS                                        \
28  { GET_ITERATOR_FILTER_COLUMNS, "nvt_selector", "families_total",             \
29    "nvts_total", "families_trend", "nvts_trend", "type", "usage_type",        \
30    "predefined", NULL }
31 
32 /**
33  * @brief Scan config iterator columns.
34  */
35 #define CONFIG_ITERATOR_COLUMNS                                               \
36  {                                                                            \
37    GET_ITERATOR_COLUMNS (configs),                                            \
38    { "nvt_selector", NULL, KEYWORD_TYPE_STRING },                             \
39    { "family_count", "families_total", KEYWORD_TYPE_INTEGER },                \
40    { "nvt_count", "nvts_total", KEYWORD_TYPE_INTEGER},                        \
41    { "families_growing", "families_trend", KEYWORD_TYPE_INTEGER},             \
42    { "nvts_growing", "nvts_trend", KEYWORD_TYPE_INTEGER },                    \
43    { "type", NULL, KEYWORD_TYPE_INTEGER },                                    \
44    { "scanner", NULL, KEYWORD_TYPE_INTEGER },                                 \
45    { "0", NULL, KEYWORD_TYPE_INTEGER },                                       \
46    { "usage_type", NULL, KEYWORD_TYPE_STRING },                               \
47    { "predefined", NULL, KEYWORD_TYPE_INTEGER },                              \
48    { NULL, NULL, KEYWORD_TYPE_UNKNOWN }                                       \
49  }
50 
51 /**
52  * @brief Scan config iterator columns for trash case.
53  */
54 #define CONFIG_ITERATOR_TRASH_COLUMNS                                         \
55  {                                                                            \
56    GET_ITERATOR_COLUMNS (configs_trash),                                      \
57    { "nvt_selector", NULL, KEYWORD_TYPE_STRING },                             \
58    { "family_count", "families_total", KEYWORD_TYPE_INTEGER },                \
59    { "nvt_count", "nvts_total", KEYWORD_TYPE_INTEGER},                        \
60    { "families_growing", "families_trend", KEYWORD_TYPE_INTEGER},             \
61    { "nvts_growing", "nvts_trend", KEYWORD_TYPE_INTEGER },                    \
62    { "type", NULL, KEYWORD_TYPE_INTEGER },                                    \
63    { "scanner", NULL, KEYWORD_TYPE_INTEGER },                                 \
64    { "scanner_location", NULL, KEYWORD_TYPE_INTEGER },                        \
65    { "usage_type", NULL, KEYWORD_TYPE_STRING },                               \
66    { "predefined", NULL, KEYWORD_TYPE_INTEGER },                              \
67    { NULL, NULL, KEYWORD_TYPE_UNKNOWN }                                       \
68  }
69 
70 gchar *
71 configs_extra_where (const char *);
72 
73 int
74 create_config_no_acl (const char *, const char *, int, const char *,
75                       int, const array_t *, const array_t *, const char *,
76                       const char *, config_t *, char **);
77 
78 gboolean
79 find_config_no_acl (const char *, config_t *);
80 
81 gboolean
82 find_trash_config_no_acl (const char *, config_t *);
83 
84 int
85 config_predefined (config_t config);
86 
87 int
88 trash_config_predefined (config_t);
89 
90 void
91 migrate_predefined_configs ();
92 
93 int
94 config_updated_in_feed (config_t, const gchar *);
95 
96 void
97 update_config (config_t, const gchar *, const gchar *, const gchar *,
98                const gchar *, int, const array_t*, const array_t*);
99 
100 void
101 check_db_configs ();
102 
103 void
104 check_whole_only_in_configs ();
105 
106 #endif /* not _GVMD_MANAGE_SQL_CONFIGS_H */
107