Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
701ebf8
utils: Add option for esacape_unicode for choices raw utf-8 or not
cosmo0920 Jul 31, 2025
81e1ddf
config: Introduce new config for determine whether escaping unicode o…
cosmo0920 Jul 31, 2025
89c8751
pack: Handle escape_unicode arguments
cosmo0920 Jul 31, 2025
acb0bb9
sds: Follow the argument increase
cosmo0920 Jul 31, 2025
4a2c644
help: Follow the argument increase
cosmo0920 Jul 31, 2025
aecd6dc
record_accessor: Follow the argument change
cosmo0920 Jul 31, 2025
e18405f
bin: Follow the argument change
cosmo0920 Jul 31, 2025
0529b3b
http_server: Follow to use escape_unicode argument
cosmo0920 Jul 31, 2025
2d6fb64
filter_expect: Follow to use escape_unicode argument
cosmo0920 Jul 31, 2025
54ffb04
filter_nightfall: Follow to use escape_unicode argument
cosmo0920 Jul 31, 2025
0904ab5
filter_wasm: Refer the config whether escaping unicode characters or not
cosmo0920 Jul 31, 2025
a01f35b
out_azure: Refer the config whether esacaping unicode or not in JSON
cosmo0920 Jul 31, 2025
98c3030
out_azure_logs_ingestion: Refer to use a config whether escaping unic…
cosmo0920 Jul 31, 2025
70e25f8
out_bigquery: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
8187dd6
out_calyptia: Use a flag always to escape unicode
cosmo0920 Jul 31, 2025
37b0292
out_chronicle: Refer to use a config whether escaping unicode or not …
cosmo0920 Jul 31, 2025
4cf8872
out_cloudwatch: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
62e042e
out_datadog: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
79d0ce1
out_es: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
1c0e411
out_http: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
f264680
out_influxdb: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
5b617c6
out_kafka: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
0b74022
out_kafka_rest: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
94825c5
out_kinesis_firehose: Refer a config whether escaping unicode or not …
cosmo0920 Jul 31, 2025
3d1029d
out_kinesis_streams: Refer a config whether escaping unicode or not i…
cosmo0920 Jul 31, 2025
4934537
out_lib: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
0e11002
out_logdna: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
224e344
out_loki: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
1c5cb40
out_nats: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
570d3c5
out_nrlogs: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
53a75b1
out_null: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
5e9c7f6
out_opensearch: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
b2e8c67
out_oracle_log_ayalysis: Refer a config whether escaping unicode or n…
cosmo0920 Jul 31, 2025
75789d0
out_s3: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
d5b49fb
out_skywalking: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
38c39fc
out_slack: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
b5a69f1
out_splunk: Refer a config whether escaping or not in JSON
cosmo0920 Jul 31, 2025
b452691
out_stackdriver: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
147c7a2
out_stdout: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
91ba6e1
out_tcp: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
ea459c8
out_udp: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
44a0d29
out_vivo: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
d8bc307
out_websocket: Refer a config whether escaping unicode or not in JSON
cosmo0920 Jul 31, 2025
f335009
processor_content_modifier: Follow the argument increase
cosmo0920 Jul 31, 2025
5bd0af2
tests: log_event_decoder: Follow an increase of argument
cosmo0920 Jul 31, 2025
cd402ee
tests: mp: Follow an increase of argument
cosmo0920 Jul 31, 2025
246945a
tests: msgpack_append_message: Follow an increase of argument
cosmo0920 Jul 31, 2025
f2beec0
tests: opnentelemetry: Follow an increase of argument
cosmo0920 Jul 31, 2025
ed29fdb
tests: pack: Follow an increase of argument
cosmo0920 Jul 31, 2025
d700219
tests: stream_processor: Follow an increase of argument
cosmo0920 Jul 31, 2025
46c7207
tests: filter_lua: Follow an increase of argument
cosmo0920 Jul 31, 2025
35eba05
tests: in_opentelemetry: Follow an increase of argument
cosmo0920 Jul 31, 2025
e362186
utils: Optimize raw string function with SIMD
cosmo0920 Jul 31, 2025
fc3b9c9
tests: utils: Add test case for encoding raw UTF-8 strings
cosmo0920 Jul 31, 2025
8e59ec7
in_systemd: Follow an increase of argument
cosmo0920 Jul 31, 2025
10308d2
pack: Avoid to use hard-coded value for escaping strings
cosmo0920 Jul 31, 2025
171f174
out_pqsql: Follow an increase of argument
cosmo0920 Jul 31, 2025
594cf85
tests: fuzzer: Follow an increase of argument
cosmo0920 Jul 31, 2025
2747779
tests: fuzzer: Follow an increase of argument
cosmo0920 Jul 31, 2025
2d490b9
tests: fuzzer: Follow an increase of argument
cosmo0920 Jul 31, 2025
abf6cb3
config: Use bool type to handle On and True as FLB_TRUE
cosmo0920 Sep 18, 2025
3420877
utils: Validate invalid code points inside the unescaped code path
cosmo0920 Sep 18, 2025
c1dfe9a
utils: tests: Add a test case for addressing invalid code points
cosmo0920 Sep 18, 2025
4510a2a
workflows: Use gcc 14 and clang 14 on ubuntu noble(24.04)
cosmo0920 Sep 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ jobs:
FLB_OPT: ${{ matrix.flb_option }}

run-aarch64-unit-tests:
runs-on: ${{(github.repository == 'fluent/fluent-bit') && 'ubuntu-22.04-arm' || 'ubuntu-latest' }}
runs-on: ${{(github.repository == 'fluent/fluent-bit') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
permissions:
contents: read
needs:
Expand All @@ -183,8 +183,8 @@ jobs:
- name: Setup environment
run: |
sudo apt-get update
sudo apt-get install -y gcc-9 g++-9 clang-12 flex bison libsystemd-dev gcovr libyaml-dev libbpf-dev linux-tools-common curl tar gzip
sudo ln -s /usr/bin/llvm-symbolizer-12 /usr/bin/llvm-symbolizer || true
sudo apt-get install -y gcc-14 g++-14 clang-14 flex bison libsystemd-dev gcovr libyaml-dev libbpf-dev linux-tools-common curl tar gzip
sudo ln -s /usr/bin/llvm-symbolizer-14 /usr/bin/llvm-symbolizer || true
sudo mkdir -p "${CMAKE_HOME}"
cmake_url="https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-$(uname -m).tar.gz"
cmake_dist="$(mktemp --suffix ".tar.gz")"
Expand All @@ -199,9 +199,9 @@ jobs:

- name: Build and test with arm runners
run: |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 90
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 90
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 90
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 90
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-14 90

export nparallel=$(( $(getconf _NPROCESSORS_ONLN) > 8 ? 8 : $(getconf _NPROCESSORS_ONLN) ))
export FLB_OPTION="${{ matrix.config.flb_option }}"
Expand Down
5 changes: 5 additions & 0 deletions include/fluent-bit/flb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ struct flb_config {
struct flb_task_map *task_map;
size_t task_map_size;

int json_escape_unicode;

int dry_run;
};

Expand Down Expand Up @@ -416,4 +418,7 @@ enum conf_type {
#define FLB_CONF_STR_SCHED_CAP "scheduler.cap"
#define FLB_CONF_STR_SCHED_BASE "scheduler.base"

/* json escape */
#define FLB_CONF_UNICODE_STR_JSON_ESCAPE "json.escape_unicode"

#endif
10 changes: 6 additions & 4 deletions include/fluent-bit/flb_pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,17 @@ int flb_pack_json_valid(const char *json, size_t len);

flb_sds_t flb_pack_msgpack_to_json_format(const char *data, uint64_t bytes,
int json_format, int date_format,
flb_sds_t date_key);
flb_sds_t date_key, int escape_unicode);
int flb_pack_to_json_format_type(const char *str);
int flb_pack_to_json_date_type(const char *str);

void flb_pack_print(const char *data, size_t bytes);
int flb_msgpack_to_json(char *json_str, size_t str_len,
const msgpack_object *obj);
char* flb_msgpack_to_json_str(size_t size, const msgpack_object *obj);
flb_sds_t flb_msgpack_raw_to_json_sds(const void *in_buf, size_t in_size);
const msgpack_object *obj,
int escape_unicode);
char* flb_msgpack_to_json_str(size_t size, const msgpack_object *obj,
int escape_unicode);
flb_sds_t flb_msgpack_raw_to_json_sds(const void *in_buf, size_t in_size, int escape_unicode);

int flb_pack_time_now(msgpack_packer *pck);
int flb_msgpack_expand_map(char *map_data, size_t map_size,
Expand Down
4 changes: 2 additions & 2 deletions include/fluent-bit/flb_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ void flb_utils_bytes_to_human_readable_size(size_t bytes,
char *out_buf, size_t size);
int flb_utils_time_split(const char *time, int *sec, long *nsec);
int flb_utils_write_str(char *buf, int *off, size_t size,
const char *str, size_t str_len);
const char *str, size_t str_len, int escape_unicode);
int flb_utils_write_str_buf(const char *str, size_t str_len,
char **out, size_t *out_size);
char **out, size_t *out_size, int escape_unicode);

int flb_utils_url_split(const char *in_url, char **out_protocol,
char **out_host, char **out_port, char **out_uri);
Expand Down
20 changes: 10 additions & 10 deletions plugins/filter_expect/expect.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ static char *ra_value_type_to_str(struct flb_ra_value *val)
return "UNKNOWN";
}

static int rule_apply(struct flb_expect *ctx, msgpack_object map)
static int rule_apply(struct flb_expect *ctx, msgpack_object map, struct flb_config *config)
{
int n = 0;
char *json;
Expand All @@ -292,7 +292,7 @@ static int rule_apply(struct flb_expect *ctx, msgpack_object map)
continue;
}

json = flb_msgpack_to_json_str(size, &map);
json = flb_msgpack_to_json_str(size, &map, config->json_escape_unicode);
flb_plg_error(ctx->ins,
"exception on rule #%i 'key_exists', key '%s' "
"not found. Record content:\n%s",
Expand All @@ -305,7 +305,7 @@ static int rule_apply(struct flb_expect *ctx, msgpack_object map)
n++;
continue;
}
json = flb_msgpack_to_json_str(size, &map);
json = flb_msgpack_to_json_str(size, &map, config->json_escape_unicode);
flb_plg_error(ctx->ins,
"exception on rule #%i 'key_not_exists', key '%s' "
"exists. Record content:\n%s",
Expand All @@ -316,7 +316,7 @@ static int rule_apply(struct flb_expect *ctx, msgpack_object map)
}
else if (rule->type == FLB_EXP_KEY_VAL_NULL) {
if (!val) {
json = flb_msgpack_to_json_str(size, &map);
json = flb_msgpack_to_json_str(size, &map, config->json_escape_unicode);
flb_plg_error(ctx->ins,
"exception on rule #%i 'key_val_is_null', "
"key '%s' not found. Record content:\n%s",
Expand All @@ -325,7 +325,7 @@ static int rule_apply(struct flb_expect *ctx, msgpack_object map)
return FLB_FALSE;
}
if (val->type != FLB_RA_NULL) {
json = flb_msgpack_to_json_str(size, &map);
json = flb_msgpack_to_json_str(size, &map, config->json_escape_unicode);
flb_plg_error(ctx->ins,
"exception on rule #%i 'key_val_is_null', "
"key '%s' contains a value type '%s'. "
Expand All @@ -340,7 +340,7 @@ static int rule_apply(struct flb_expect *ctx, msgpack_object map)
}
else if (rule->type == FLB_EXP_KEY_VAL_NOT_NULL) {
if (!val) {
json = flb_msgpack_to_json_str(size, &map);
json = flb_msgpack_to_json_str(size, &map, config->json_escape_unicode);
flb_plg_error(ctx->ins,
"exception on rule #%i 'key_val_is_not_null', "
"key '%s' not found. Record content:\n%s",
Expand All @@ -349,7 +349,7 @@ static int rule_apply(struct flb_expect *ctx, msgpack_object map)
return FLB_FALSE;
}
if (val->type == FLB_RA_NULL) {
json = flb_msgpack_to_json_str(size, &map);
json = flb_msgpack_to_json_str(size, &map, config->json_escape_unicode);
flb_plg_error(ctx->ins,
"exception on rule #%i 'key_val_is_not_null', "
"key '%s' contains a value type '%s'. "
Expand All @@ -364,7 +364,7 @@ static int rule_apply(struct flb_expect *ctx, msgpack_object map)
}
else if (rule->type == FLB_EXP_KEY_VAL_EQ) {
if (!val) {
json = flb_msgpack_to_json_str(size, &map);
json = flb_msgpack_to_json_str(size, &map, config->json_escape_unicode);
flb_plg_error(ctx->ins,
"exception on rule #%i 'key_val_is_null', "
"key '%s' not found. Record content:\n%s",
Expand All @@ -376,7 +376,7 @@ static int rule_apply(struct flb_expect *ctx, msgpack_object map)
if (val->type == FLB_RA_STRING) {
if (flb_sds_cmp(val->val.string, rule->expect,
flb_sds_len(rule->expect)) != 0) {
json = flb_msgpack_to_json_str(size, &map);
json = flb_msgpack_to_json_str(size, &map, config->json_escape_unicode);
flb_plg_error(ctx->ins,
"exception on rule #%i 'key_val_eq', "
"key value '%s' is different than "
Expand Down Expand Up @@ -430,7 +430,7 @@ static int cb_expect_filter(const void *data, size_t bytes,
while ((ret = flb_log_event_decoder_next(
&log_decoder,
&log_event)) == FLB_EVENT_DECODER_SUCCESS) {
ret = rule_apply(ctx, *log_event.body);
ret = rule_apply(ctx, *log_event.body, config);
if (ret == FLB_TRUE) {
/* rule matches, we are good */
continue;
Expand Down
4 changes: 2 additions & 2 deletions plugins/filter_nightfall/nightfall_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ static flb_sds_t build_request_body(struct flb_filter_nightfall *ctx,
msgpack_pack_str_with_body(&req_pk, "policyUUIDs", 11);
msgpack_pack_array(&req_pk, 1);
msgpack_pack_str_with_body(&req_pk, ctx->policy_id, 36);
request_body = flb_msgpack_raw_to_json_sds(req_sbuf.data, req_sbuf.size);

request_body = flb_msgpack_raw_to_json_sds(req_sbuf.data, req_sbuf.size, FLB_TRUE);

msgpack_sbuffer_destroy(&req_sbuf);
flb_sds_destroy(num_str);
Expand Down
2 changes: 1 addition & 1 deletion plugins/filter_wasm/filter_wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static int cb_wasm_filter(const void *data, size_t bytes,
switch(ctx->event_format) {
case FLB_FILTER_WASM_FMT_JSON:
/* Encode as JSON from msgpack */
buf = flb_msgpack_to_json_str(alloc_size, log_event.body);
buf = flb_msgpack_to_json_str(alloc_size, log_event.body, config->json_escape_unicode);

if (buf) {
/* Execute WASM program */
Expand Down
9 changes: 6 additions & 3 deletions plugins/out_azure/azure.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ static int cb_azure_init(struct flb_output_instance *ins,
static int azure_format(const void *in_buf, size_t in_bytes,
flb_sds_t tag, flb_sds_t *tag_val_out,
char **out_buf, size_t *out_size,
struct flb_azure *ctx)
struct flb_azure *ctx,
struct flb_config *config)
{
int i;
int array_size = 0;
Expand Down Expand Up @@ -160,7 +161,8 @@ static int azure_format(const void *in_buf, size_t in_bytes,
msgpack_sbuffer_destroy(&tmp_sbuf);
}

record = flb_msgpack_raw_to_json_sds(mp_sbuf.data, mp_sbuf.size);
record = flb_msgpack_raw_to_json_sds(mp_sbuf.data, mp_sbuf.size,
config->json_escape_unicode);
if (!record) {
flb_errno();

Expand Down Expand Up @@ -317,7 +319,8 @@ static void cb_azure_flush(struct flb_event_chunk *event_chunk,

/* Convert binary logs into a JSON payload */
ret = azure_format(event_chunk->data, event_chunk->size,
event_chunk->tag, &final_log_type, &buf_data, &buf_size, ctx);
event_chunk->tag, &final_log_type, &buf_data, &buf_size, ctx,
config);
/* If cannot get matching record using log_type_prefix, use log_type directly */
if (!final_log_type) {
final_log_type = ctx->log_type;
Expand Down
3 changes: 2 additions & 1 deletion plugins/out_azure_blob/azure_blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ static int azure_blob_format(struct flb_config *config,
out_buf = flb_pack_msgpack_to_json_format(data, bytes,
FLB_PACK_JSON_FORMAT_LINES,
FLB_PACK_JSON_DATE_ISO8601,
ctx->date_key);
ctx->date_key,
config->json_escape_unicode);
if (!out_buf) {
return -1;
}
Expand Down
12 changes: 8 additions & 4 deletions plugins/out_azure_kusto/azure_kusto.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,8 @@ static int cb_azure_kusto_init(struct flb_output_instance *ins, struct flb_confi
*/
static int azure_kusto_format(struct flb_azure_kusto *ctx, const char *tag, int tag_len,
const void *data, size_t bytes, void **out_data,
size_t *out_size)
size_t *out_size,
struct flb_config *config)
{
int index;
int records = 0;
Expand Down Expand Up @@ -1086,7 +1087,8 @@ static int azure_kusto_format(struct flb_azure_kusto *ctx, const char *tag, int
msgpack_pack_str_body(&mp_pck, "log_attribute_missing", 20);
}

flb_sds_t json_record = flb_msgpack_raw_to_json_sds(mp_sbuf.data, mp_sbuf.size);
flb_sds_t json_record = flb_msgpack_raw_to_json_sds(mp_sbuf.data, mp_sbuf.size,
config->json_escape_unicode);
if (!json_record) {
flb_plg_error(ctx->ins, "error converting msgpack to JSON");
flb_sds_destroy(out_buf);
Expand Down Expand Up @@ -1256,7 +1258,8 @@ static void cb_azure_kusto_flush(struct flb_event_chunk *event_chunk,

/* Reformat msgpack to JSON payload */
ret = azure_kusto_format(ctx, tag_name, tag_name_len, event_chunk->data,
event_chunk->size, (void **)&json, &json_size);
event_chunk->size, (void **)&json, &json_size,
config);
if (ret != 0) {
flb_plg_error(ctx->ins, "cannot reformat data into json");
ret = FLB_RETRY;
Expand Down Expand Up @@ -1367,7 +1370,8 @@ static void cb_azure_kusto_flush(struct flb_event_chunk *event_chunk,

/* Reformat msgpack data to JSON payload */
ret = azure_kusto_format(ctx, event_chunk->tag, tag_len, event_chunk->data,
event_chunk->size, (void **)&json, &json_size);
event_chunk->size, (void **)&json, &json_size,
config);
if (ret != 0) {
flb_plg_error(ctx->ins, "cannot reformat data into json");
ret = FLB_RETRY;
Expand Down
9 changes: 6 additions & 3 deletions plugins/out_azure_logs_ingestion/azure_logs_ingestion.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ static int cb_azure_logs_ingestion_init(struct flb_output_instance *ins,
allocates sds string */
static int az_li_format(const void *in_buf, size_t in_bytes,
char **out_buf, size_t *out_size,
struct flb_az_li *ctx)
struct flb_az_li *ctx,
struct flb_config *config)
{
int i;
int array_size = 0;
Expand Down Expand Up @@ -141,7 +142,8 @@ static int az_li_format(const void *in_buf, size_t in_bytes,
msgpack_sbuffer_destroy(&tmp_sbuf);
}

record = flb_msgpack_raw_to_json_sds(mp_sbuf.data, mp_sbuf.size);
record = flb_msgpack_raw_to_json_sds(mp_sbuf.data, mp_sbuf.size,
config->json_escape_unicode);
if (!record) {
flb_errno();
msgpack_sbuffer_destroy(&mp_sbuf);
Expand Down Expand Up @@ -266,7 +268,8 @@ static void cb_azure_logs_ingestion_flush(struct flb_event_chunk *event_chunk,

/* Convert binary logs into a JSON payload */
ret = az_li_format(event_chunk->data, event_chunk->size,
&json_payload, &json_payload_size, ctx);
&json_payload, &json_payload_size, ctx,
config);
if (ret == -1) {
flb_upstream_conn_release(u_conn);
FLB_OUTPUT_RETURN(FLB_ERROR);
Expand Down
8 changes: 5 additions & 3 deletions plugins/out_bigquery/bigquery.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,8 @@ static int cb_bigquery_init(struct flb_output_instance *ins,
static int bigquery_format(const void *data, size_t bytes,
const char *tag, size_t tag_len,
char **out_data, size_t *out_size,
struct flb_bigquery *ctx)
struct flb_bigquery *ctx,
struct flb_config *config)
{
int array_size = 0;
flb_sds_t out_buf;
Expand Down Expand Up @@ -937,7 +938,8 @@ static int bigquery_format(const void *data, size_t bytes,
}

/* Convert from msgpack to JSON */
out_buf = flb_msgpack_raw_to_json_sds(mp_sbuf.data, mp_sbuf.size);
out_buf = flb_msgpack_raw_to_json_sds(mp_sbuf.data, mp_sbuf.size,
config->json_escape_unicode);

Comment on lines +941 to 943
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing NULL-check before dereferencing config

config is assumed non-NULL when accessing config->json_escape_unicode. The engine passes a valid pointer in normal paths, but defensive code would make the function robust to accidental NULLs or future refactors.

-    out_buf = flb_msgpack_raw_to_json_sds(mp_sbuf.data, mp_sbuf.size,
-                                          config->json_escape_unicode);
+    if (!config) {
+        flb_plg_error(ctx->ins, "NULL config passed to bigquery_format()");
+        return -1;
+    }
+    out_buf = flb_msgpack_raw_to_json_sds(mp_sbuf.data, mp_sbuf.size,
+                                          config->json_escape_unicode);

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In plugins/out_bigquery/bigquery.c around lines 941 to 943, the code
dereferences the config pointer without checking if it is NULL, which can cause
crashes if config is NULL. Add a NULL check for config before accessing
config->json_escape_unicode, and handle the NULL case appropriately, such as
using a default value or returning an error, to make the function more robust.

flb_log_event_decoder_destroy(&log_decoder);
msgpack_sbuffer_destroy(&mp_sbuf);
Expand Down Expand Up @@ -996,7 +998,7 @@ static void cb_bigquery_flush(struct flb_event_chunk *event_chunk,
/* Reformat msgpack to bigquery JSON payload */
ret = bigquery_format(event_chunk->data, event_chunk->size,
event_chunk->tag, flb_sds_len(event_chunk->tag),
&payload_buf, &payload_size, ctx);
&payload_buf, &payload_size, ctx, config);
if (ret != 0) {
flb_upstream_conn_release(u_conn);
flb_sds_destroy(token);
Expand Down
7 changes: 4 additions & 3 deletions plugins/out_calyptia/calyptia.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ static flb_sds_t get_agent_metadata(struct flb_calyptia *ctx)
flb_mp_map_header_end(&mh);

/* convert to json */
meta = flb_msgpack_raw_to_json_sds(mp_sbuf.data, mp_sbuf.size);
meta = flb_msgpack_raw_to_json_sds(mp_sbuf.data, mp_sbuf.size, FLB_TRUE); /* could be ASCII */
msgpack_sbuffer_destroy(&mp_sbuf);

return meta;
Expand Down Expand Up @@ -532,7 +532,7 @@ static int store_session_get(struct flb_calyptia *ctx,
}

/* decode */
json = flb_msgpack_raw_to_json_sds(buf, size);
json = flb_msgpack_raw_to_json_sds(buf, size, FLB_TRUE); /* TODO: could be ASCII? */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we resolve this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure but the current pattern of usages do not have multibytes between the dedicated service and this plugin.

flb_free(buf);
if (!json) {
return -1;
Expand Down Expand Up @@ -1029,7 +1029,8 @@ static void cb_calyptia_flush(struct flb_event_chunk *event_chunk,
event_chunk->size,
FLB_PACK_JSON_FORMAT_STREAM,
FLB_PACK_JSON_DATE_DOUBLE,
NULL);
NULL,
FLB_TRUE); /* Trace is ASCII */
if (json == NULL) {
flb_upstream_conn_release(u_conn);
FLB_OUTPUT_RETURN(FLB_RETRY);
Expand Down
Loading
Loading