Skip to content

Commit 2d1c99d

Browse files
bjoernricksgreenbonebot
authored andcommitted
Fix: Return error responses if scan config related GMP requests fail
Convert GMP responses with errors into HTTP error responses for scan config editing commands. Otherwise GSA can't handle the errors correctly and the user will have no indication about an error occurred.
1 parent 72ba8a7 commit 2d1c99d

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

src/gsad_gmp.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8503,6 +8503,7 @@ get_config_family (gvm_connection_t *connection, credentials_t *credentials,
85038503
{
85048504
GString *xml;
85058505
const char *config_id, *family, *sort_field, *sort_order;
8506+
entity_t entity;
85068507

85078508
config_id = params_value (params, "config_id");
85088509
family = params_value (params, "family");
@@ -8539,7 +8540,7 @@ get_config_family (gvm_connection_t *connection, credentials_t *credentials,
85398540
response_data);
85408541
}
85418542

8542-
if (read_string_c (connection, &xml))
8543+
if (read_entity_and_string_c (connection, &entity, &xml))
85438544
{
85448545
g_string_free (xml, TRUE);
85458546
cmd_response_data_set_status_code (response_data,
@@ -8551,8 +8552,14 @@ get_config_family (gvm_connection_t *connection, credentials_t *credentials,
85518552
"Diagnostics: Failure to receive response from manager daemon.",
85528553
response_data);
85538554
}
8554-
85558555
g_string_append (xml, "</get_config_family_response>");
8556+
8557+
if (gmp_success (entity) != 1)
8558+
{
8559+
set_http_status_from_entity (entity, response_data);
8560+
}
8561+
free_entity (entity);
8562+
85568563
return envelope_gmp (connection, credentials, params,
85578564
g_string_free (xml, FALSE), response_data);
85588565
}
@@ -8609,6 +8616,7 @@ edit_config_family_all_gmp (gvm_connection_t *connection,
86098616
{
86108617
GString *xml;
86118618
const char *config_id, *family, *sort_field, *sort_order;
8619+
entity_t entity;
86128620

86138621
config_id = params_value (params, "config_id");
86148622
family = params_value (params, "family");
@@ -8651,7 +8659,7 @@ edit_config_family_all_gmp (gvm_connection_t *connection,
86518659
response_data);
86528660
}
86538661

8654-
if (read_string_c (connection, &xml))
8662+
if (read_entity_and_string_c (connection, &entity, &xml))
86558663
{
86568664
g_string_free (xml, TRUE);
86578665
cmd_response_data_set_status_code (response_data,
@@ -8663,8 +8671,15 @@ edit_config_family_all_gmp (gvm_connection_t *connection,
86638671
"Diagnostics: Failure to receive response from manager daemon.",
86648672
response_data);
86658673
}
8666-
86678674
g_string_append (xml, "</get_config_family_response>");
8675+
8676+
if (gmp_success (entity) != 1)
8677+
{
8678+
set_http_status_from_entity (entity, response_data);
8679+
}
8680+
8681+
free_entity (entity);
8682+
86688683
return envelope_gmp (connection, credentials, params,
86698684
g_string_free (xml, FALSE), response_data);
86708685
}
@@ -8772,6 +8787,7 @@ get_config_nvt_gmp (gvm_connection_t *connection, credentials_t *credentials,
87728787
{
87738788
GString *xml;
87748789
const char *config_id, *sort_field, *sort_order, *nvt;
8790+
entity_t entity;
87758791

87768792
config_id = params_value (params, "config_id");
87778793
nvt = params_value (params, "oid");
@@ -8804,7 +8820,7 @@ get_config_nvt_gmp (gvm_connection_t *connection, credentials_t *credentials,
88048820
response_data);
88058821
}
88068822

8807-
if (read_string_c (connection, &xml))
8823+
if (read_entity_and_string_c (connection, &entity, &xml))
88088824
{
88098825
g_string_free (xml, TRUE);
88108826
cmd_response_data_set_status_code (response_data,
@@ -8816,9 +8832,14 @@ get_config_nvt_gmp (gvm_connection_t *connection, credentials_t *credentials,
88168832
"Diagnostics: Failure to receive response from manager daemon.",
88178833
response_data);
88188834
}
8819-
88208835
g_string_append (xml, "</get_config_nvt_response>");
88218836

8837+
if (gmp_success (entity) != 1)
8838+
{
8839+
set_http_status_from_entity (entity, response_data);
8840+
}
8841+
free_entity (entity);
8842+
88228843
return envelope_gmp (connection, credentials, params,
88238844
g_string_free (xml, FALSE), response_data);
88248845
}

0 commit comments

Comments
 (0)