Greenbone Security Assistant  8.0.0
gsad_settings.c
Go to the documentation of this file.
1 /* Copyright (C) 2016-2018 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 
25 #include "gsad_settings.h"
26 
30 gchar *vendor_version = NULL;
31 
32 gchar *label_name = NULL;
33 
37 gchar *guest_username = NULL;
38 
42 gchar *guest_password = NULL;
43 
48 
52 const gchar *http_x_frame_options;
53 
58 
63 
68 
73 
77 const gchar *http_cors_origin;
78 
83 
88 
92 int unix_socket = 0;
93 
100 
106 void
107 vendor_version_set (const gchar *version)
108 {
109  g_free (vendor_version);
110  vendor_version = g_strdup (version);
111 }
112 
118 const gchar *
120 {
121  return vendor_version ? vendor_version : "";
122 }
123 
131 int
132 label_name_set (const gchar *name)
133 {
134  if (!g_regex_match_simple ("^[a-zA-Z0-9\\-_\\.\\:]+$", name, 0, 0))
135  return -1;
136 
137  g_free (label_name);
138  label_name = g_strdup (name);
139  return 0;
140 }
141 
142 void
143 set_guest_username (const gchar *username)
144 {
145  guest_username = g_strdup (username);
146 }
147 
148 const gchar *
150 {
151  return guest_username;
152 }
153 
154 void
155 set_guest_password (const gchar *password)
156 {
157  guest_password = g_strdup (password);
158 }
159 
160 const gchar *
162 {
163  return guest_password;
164 }
165 
166 void
167 set_session_timeout (int timeout)
168 {
169  session_timeout = timeout;
170 }
171 
172 int
174 {
175  return session_timeout;
176 }
177 
178 void
180 {
181  use_secure_cookie = secure;
182 }
183 
184 gboolean
186 {
187  return use_secure_cookie;
188 }
189 
190 void
191 set_http_content_security_policy (const gchar *policy)
192 {
194 }
195 
196 const gchar *
198 {
200 }
201 
202 void
203 set_http_x_frame_options (const gchar *options)
204 {
205  http_x_frame_options = options;
206 }
207 
208 const gchar *
210 {
211  return http_x_frame_options;
212 }
213 
214 void
215 set_http_cors_origin (const gchar *origin)
216 {
217  http_cors_origin = origin;
218 }
219 
220 const gchar *
222 {
223  return http_cors_origin;
224 }
225 
226 void
228 {
230 }
231 
232 const gchar *
234 {
236 }
237 
238 void
240 {
242 }
243 
244 const gchar *
246 {
248 }
249 
250 void
252 {
254 }
255 
256 const gchar *
258 {
260 }
261 
262 void
263 set_ignore_http_x_real_ip (gboolean ignore)
264 {
265  ignore_http_x_real_ip = ignore;
266 }
267 
268 gboolean
270 {
271  return ignore_http_x_real_ip;
272 }
273 
274 void
276 {
277  if (limit >= 0)
278  per_ip_connection_limit = limit;
279  else
281 }
282 
283 int
285 {
287 }
288 
289 void
290 set_unix_socket (int socket)
291 {
292  unix_socket = socket;
293 }
294 
295 gboolean
297 {
298  return unix_socket > 0;
299 }
void set_use_secure_cookie(int secure)
gchar * guest_password
Guest password.
Definition: gsad_settings.c:42
void vendor_version_set(const gchar *version)
Set the vendor version.
void set_http_cors_origin(const gchar *origin)
const gchar * get_http_strict_transport_security()
const gchar * vendor_version_get()
Get the vendor version.
gboolean ignore_http_x_real_ip
Current preference for using X_Real_IP from HTTP header.
Definition: gsad_settings.c:82
int label_name_set(const gchar *name)
Set the login label.
const gchar * get_guest_password()
const gchar * get_http_cors_origin()
gboolean is_unix_socket()
const gchar * get_http_x_frame_options()
gchar * vendor_version
Version from vendor, or NULL.
Definition: gsad_settings.c:30
int get_session_timeout()
const gchar * http_guest_chart_content_security_policy
Current guest chart value for HTTP header "Content-Security-Policy".
Definition: gsad_settings.c:67
Global settings for GSA.
void set_guest_username(const gchar *username)
void set_http_strict_transport_security(const gchar *policy)
void set_http_content_security_policy(const gchar *policy)
void set_ignore_http_x_real_ip(gboolean ignore)
gboolean is_ignore_http_x_real_ip()
void set_http_guest_chart_content_security_policy(const gchar *policy)
const gchar * get_guest_username()
void set_unix_socket(int socket)
const gchar * http_strict_transport_security
Current value of for HTTP header "Strict-Transport-Security".
Definition: gsad_settings.c:72
const gchar * http_x_frame_options
Current value for HTTP header "X-Frame-Options".
Definition: gsad_settings.c:52
int per_ip_connection_limit
Current maximum number of connection per IP address.
Definition: gsad_settings.c:87
const gchar * http_content_security_policy
Current value for HTTP header "Content-Security-Policy".
Definition: gsad_settings.c:57
const gchar * get_http_content_security_policy()
const gchar * get_http_guest_chart_content_security_policy()
const gchar * get_http_guest_chart_x_frame_options()
gboolean is_use_secure_cookie()
int get_per_ip_connection_limit()
int unix_socket
Unix socket to listen on.
Definition: gsad_settings.c:92
const gchar * http_guest_chart_x_frame_options
Current guest chart specific value for HTTP header "X-Frame-Options".
Definition: gsad_settings.c:62
int session_timeout
Maximum number of minutes of user idle time.
Definition: gsad_settings.c:47
void set_http_guest_chart_x_frame_options(const gchar *options)
const gchar * http_cors_origin
Current value of for HTTP header "Access-Control-Allow-Origin".
Definition: gsad_settings.c:77
gchar * label_name
Definition: gsad_settings.c:32
int use_secure_cookie
Whether to use a secure cookie.
Definition: gsad_settings.c:99
gchar * guest_username
Guest username.
Definition: gsad_settings.c:37
void set_session_timeout(int timeout)
void set_http_x_frame_options(const gchar *options)
void set_guest_password(const gchar *password)
void set_per_ip_connection_limit(int limit)