Skip to content

Commit

Permalink
Merge branch 'main' into GEA-420_Log_to_stderror
Browse files Browse the repository at this point in the history
  • Loading branch information
jhelmold authored Oct 21, 2024
2 parents 3114cff + 3f92b09 commit dcfd2a7
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .docker/build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ARG GVM_LIBS_VERSION=oldstable

# We want gvm-libs to be ready so we use the build docker image of gvm-libs
FROM greenbone/gvm-libs:$GVM_LIBS_VERSION
FROM registry.community.greenbone.net/community/gvm-libs:${GVM_LIBS_VERSION}

# This will make apt-get install without question
ARG DEBIAN_FRONTEND=noninteractive
Expand Down
2 changes: 1 addition & 1 deletion .docker/prod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN mkdir /build \
&& cmake -DCMAKE_BUILD_TYPE=Release /source \
&& make DESTDIR=/install install

FROM greenbone/gvm-libs:${GVM_LIBS_VERSION}
FROM registry.community.greenbone.net/community/gvm-libs:${GVM_LIBS_VERSION}

ARG DEBIAN_FRONTEND=noninteractive

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cmake_minimum_required (VERSION 3.0)

message ("-- Configuring gsad")

project (gsad VERSION 22.11.1 LANGUAGES C)
project (gsad VERSION 24.0.1 LANGUAGES C)

if (NOT DEFINED PROJECT_VERSION_STRING)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
Expand Down
109 changes: 109 additions & 0 deletions src/gsad_gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -11984,6 +11984,7 @@ save_my_settings_gmp (gvm_connection_t *connection, credentials_t *credentials,
{
const char *lang, *text, *old_passwd, *passwd, *max;
const char *details_fname, *list_fname, *report_fname;
const char *time_format, *date_format;
gchar *lang_64, *text_64, *max_64, *fname_64;
GString *xml;
entity_t entity;
Expand All @@ -12004,6 +12005,8 @@ save_my_settings_gmp (gvm_connection_t *connection, credentials_t *credentials,
details_fname = params_value (params, "details_fname");
list_fname = params_value (params, "list_fname");
report_fname = params_value (params, "report_fname");
time_format = params_value (params, "time_format");
date_format = params_value (params, "date_format");

CHECK_VARIABLE_INVALID (text, "Save Settings")
CHECK_VARIABLE_INVALID (text, "Save Settings")
Expand All @@ -12013,6 +12016,8 @@ save_my_settings_gmp (gvm_connection_t *connection, credentials_t *credentials,
CHECK_VARIABLE_INVALID (details_fname, "Save Settings")
CHECK_VARIABLE_INVALID (list_fname, "Save Settings")
CHECK_VARIABLE_INVALID (report_fname, "Save Settings")
CHECK_VARIABLE_INVALID (time_format, "Save Settings")
CHECK_VARIABLE_INVALID (date_format, "Save Settings")

xml = g_string_new ("");

Expand Down Expand Up @@ -12638,6 +12643,110 @@ save_my_settings_gmp (gvm_connection_t *connection, credentials_t *credentials,
}
}

/* Send User Interface Time Format. */
changed_value = params_value (changed, "time_format");
if (changed_value == NULL
|| (strcmp (changed_value, "") && strcmp (changed_value, "0")))
{
gchar *time_format_64 =
g_base64_encode ((guchar *) time_format, strlen (time_format));

if (gvm_connection_sendf (connection,
"<modify_setting"
" setting_id"
"=\"11deb7ff-550b-4950-aacf-06faeb7c61b9\">"
"<value>%s</value>"
"</modify_setting>",
time_format_64 ? time_format_64 : "")
== -1)
{
g_free (time_format_64);
cmd_response_data_set_status_code (response_data,
MHD_HTTP_INTERNAL_SERVER_ERROR);
return gsad_message (
credentials, "Internal error", __func__, __LINE__,
"An internal error occurred while saving settings. "
"It is unclear whether all the settings were saved. "
"Diagnostics: Failure to send command to manager daemon.",
response_data);
}
g_free (time_format_64);

entity = NULL;
xml_string_append (xml, "<save_setting id=\"%s\">",
"11deb7ff-550b-4950-aacf-06faeb7c61b9");
if (read_entity_and_string_c (connection, &entity, &xml))
{
g_string_free (xml, TRUE);
cmd_response_data_set_status_code (response_data,
MHD_HTTP_INTERNAL_SERVER_ERROR);
return gsad_message (
credentials, "Internal error", __func__, __LINE__,
"An internal error occurred while saving settings. "
"It is unclear whether all the settings were saved. "
"Diagnostics: Failure to receive response from manager daemon.",
response_data);
}
xml_string_append (xml, "</save_setting>");
if (gmp_success (entity) != 1)
{
set_http_status_from_entity (entity, response_data);
modify_failed = 1;
}
}

/* Send User Interface Date Format. */
changed_value = params_value (changed, "date_format");
if (changed_value == NULL
|| (strcmp (changed_value, "") && strcmp (changed_value, "0")))
{
gchar *date_format_64 =
g_base64_encode ((guchar *) date_format, strlen (date_format));

if (gvm_connection_sendf (connection,
"<modify_setting"
" setting_id"
"=\"d9857b7c-1159-4193-9bc0-18fae5473a69\">"
"<value>%s</value>"
"</modify_setting>",
date_format_64 ? date_format_64 : "")
== -1)
{
g_free (date_format_64);
cmd_response_data_set_status_code (response_data,
MHD_HTTP_INTERNAL_SERVER_ERROR);
return gsad_message (
credentials, "Internal error", __func__, __LINE__,
"An internal error occurred while saving settings. "
"It is unclear whether all the settings were saved. "
"Diagnostics: Failure to send command to manager daemon.",
response_data);
}
g_free (date_format_64);

entity = NULL;
xml_string_append (xml, "<save_setting id=\"%s\">",
"d9857b7c-1159-4193-9bc0-18fae5473a69");
if (read_entity_and_string_c (connection, &entity, &xml))
{
g_string_free (xml, TRUE);
cmd_response_data_set_status_code (response_data,
MHD_HTTP_INTERNAL_SERVER_ERROR);
return gsad_message (
credentials, "Internal error", __func__, __LINE__,
"An internal error occurred while saving settings. "
"It is unclear whether all the settings were saved. "
"Diagnostics: Failure to receive response from manager daemon.",
response_data);
}
xml_string_append (xml, "</save_setting>");
if (gmp_success (entity) != 1)
{
set_http_status_from_entity (entity, response_data);
modify_failed = 1;
}
}

if (user_changed)
{
session_add_user (user_get_token (user), user);
Expand Down
2 changes: 2 additions & 0 deletions src/gsad_validator.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,8 @@ init_validator ()
"^(second|minute|hour|day|week|month|year|decade)$");
gvm_validator_add (validator, "chart_title", "(?s)^.*$");
gvm_validator_add (validator, "icalendar", "(?s)^BEGIN:VCALENDAR.+$");
gvm_validator_add (validator, "time_format", "^(12|24|system_default)$");
gvm_validator_add (validator, "date_format", "^(wmdy|wdmy|system_default)$");

/* Binary data params that should not use no UTF-8 validation */
gvm_validator_add_binary (validator, "certificate_bin");
Expand Down

0 comments on commit dcfd2a7

Please sign in to comment.