Skip to content

Commit

Permalink
output/http: log invalid status as a string
Browse files Browse the repository at this point in the history
Ticket: 7311

If response_status_number is not a valid poisitive integer,
we should not try to parse it again, and fail again,
but just log the raw string.
  • Loading branch information
catenacyber committed Oct 8, 2024
1 parent fd44983 commit 4177221
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 3 additions & 0 deletions etc/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,9 @@
"status": {
"type": "integer"
},
"status_str": {
"type": "string"
},
"true_client_ip": {
"type": "string"
},
Expand Down
8 changes: 2 additions & 6 deletions src/output-json-http.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,8 @@ static void EveHttpLogJSONExtended(JsonBuilder *js, htp_tx_t *tx)
if (resp > 0) {
jb_set_uint(js, "status", (uint32_t)resp);
} else if (tx->response_status != NULL) {
const size_t status_size = bstr_len(tx->response_status) * 2 + 1;
char status_string[status_size];
BytesToStringBuffer(bstr_ptr(tx->response_status), bstr_len(tx->response_status),
status_string, status_size);
unsigned int val = strtoul(status_string, NULL, 10);
jb_set_uint(js, "status", val);
jb_set_string_from_bytes(js, "status_str", bstr_ptr(tx->response_status),
(uint32_t)bstr_len(tx->response_status));
}

htp_header_t *h_location = htp_table_get_c(tx->response_headers, "location");
Expand Down

0 comments on commit 4177221

Please sign in to comment.