Skip to content

Commit 46ea2bd

Browse files
braydonkedsiper
authored andcommitted
out_stackdriver: check for proper http request key
Signed-off-by: Braydon Kains <[email protected]>
1 parent 4e0b2ba commit 46ea2bd

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

plugins/out_stackdriver/stackdriver.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,8 +1980,10 @@ static int stackdriver_format(struct flb_config *config,
19801980
/* Extract httpRequest */
19811981
init_http_request(&http_request);
19821982
http_request_extra_size = 0;
1983-
http_request_extracted = extract_http_request(&http_request, obj,
1984-
&http_request_extra_size);
1983+
http_request_extracted = extract_http_request(&http_request,
1984+
ctx->http_request_key,
1985+
ctx->http_request_key_size,
1986+
obj, &http_request_extra_size);
19851987
if (http_request_extracted == FLB_TRUE) {
19861988
entry_size += 1;
19871989
}

plugins/out_stackdriver/stackdriver_http_request.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ static void validate_latency(msgpack_object_str latency_in_payload,
231231

232232
/* Return true if httpRequest extracted */
233233
int extract_http_request(struct http_request_field *http_request,
234+
flb_sds_t http_request_key,
235+
int http_request_key_size,
234236
msgpack_object *obj, int *extra_subfields)
235237
{
236238
http_request_status op_status = NO_HTTPREQUEST;
@@ -249,8 +251,8 @@ int extract_http_request(struct http_request_field *http_request,
249251
for (; p < pend && op_status == NO_HTTPREQUEST; ++p) {
250252

251253
if (p->val.type != MSGPACK_OBJECT_MAP
252-
|| !validate_key(p->key, HTTPREQUEST_FIELD_IN_JSON,
253-
HTTP_REQUEST_KEY_SIZE)) {
254+
|| !validate_key(p->key, http_request_key,
255+
http_request_key_size)) {
254256

255257
continue;
256258
}

plugins/out_stackdriver/stackdriver_http_request.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ void add_http_request_field(struct http_request_field *http_request,
9191
* If the httpRequest field exists, return TRUE and store the subfields.
9292
* If there are extra subfields, count the number.
9393
*/
94-
int extract_http_request(struct http_request_field *http_request,
94+
int extract_http_request(struct http_request_field *http_request,
95+
flb_sds_t http_request_key,
96+
int http_request_key_size,
9597
msgpack_object *obj, int *extra_subfields);
9698

9799
/*

0 commit comments

Comments
 (0)