Skip to content

Commit

Permalink
in_splunk: Process Content-Type strictly
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 authored and edsiper committed Jul 16, 2024
1 parent b1af4a1 commit c0d9184
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions plugins/in_splunk/splunk_prot.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ static int process_hec_payload(struct flb_splunk *ctx, struct splunk_conn *conn,
header = &session->parser.headers[MK_HEADER_CONTENT_TYPE];
if (header->key.data == NULL) {
send_response(conn, 400, "error: header 'Content-Type' is not set\n");
return -1;
return -2;
}

if (header->val.len == 16 &&
Expand All @@ -595,7 +595,7 @@ static int process_hec_payload(struct flb_splunk *ctx, struct splunk_conn *conn,

if (request->data.len <= 0) {
send_response(conn, 400, "error: no payload found\n");
return -1;
return -2;
}

header_auth = &session->parser.headers[MK_HEADER_AUTHORIZATION];
Expand Down Expand Up @@ -846,6 +846,13 @@ int splunk_prot_handle(struct flb_splunk *ctx, struct splunk_conn *conn,
strcasecmp(uri, "/services/collector") == 0) {
ret = process_hec_payload(ctx, conn, tag, session, request);

if (ret == -2) {
flb_sds_destroy(tag);
mk_mem_free(uri);

return -1;
}

if (!ret) {
send_json_message_response(conn, 400, "{\"text\":\"Invalid data format\",\"code\":6}");
}
Expand Down Expand Up @@ -1162,6 +1169,8 @@ int splunk_prot_handle_ng(struct flb_http_request *request,

if (ret != 0) {
send_json_message_response_ng(response, 400, "{\"text\":\"Invalid data format\",\"code\":6}");

ret = -1;
}
else {
send_json_message_response_ng(response, 200, "{\"text\":\"Success\",\"code\":0}");
Expand Down

0 comments on commit c0d9184

Please sign in to comment.