Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: internal: fuzzers: add timeout checks and add license. #3560

Merged
merged 1 commit into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions tests/internal/fuzzers/flb_fuzz_header.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
/* Fluent Bit
* ==========
* Copyright (C) 2019-2021 The Fluent Bit Authors
* Copyright (C) 2015-2018 Treasure Data Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <stdint.h>
#include <string.h>

#define GET_MOD_EQ(max, idx) (data[0] % max) == idx
#define MOVE_INPUT(offset) data += offset; size -= offset;

#define TIMEOUT_GUARD if (size > 32768) return 0;

char *get_null_terminated(size_t size, const uint8_t **data,
size_t *total_data_size)
{
Expand Down
5 changes: 4 additions & 1 deletion tests/internal/fuzzers/flb_json_fuzzer.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Fluent Bit
* ==========
* Copyright (C) 2019-2020 The Fluent Bit Authors
* Copyright (C) 2019-2021 The Fluent Bit Authors
* Copyright (C) 2015-2018 Treasure Data Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,9 +19,12 @@
#include <stdint.h>
#include <fluent-bit/flb_pack.h>
#include <fluent-bit/flb_str.h>
#include "flb_fuzz_header.h"

int LLVMFuzzerTestOneInput(unsigned char *data, size_t size)
{
TIMEOUT_GUARD

/* json packer */
char *out_buf = NULL;
size_t out_size;
Expand Down
20 changes: 20 additions & 0 deletions tests/internal/fuzzers/parse_json_fuzzer.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
/* Fluent Bit
* ==========
* Copyright (C) 2019-2021 The Fluent Bit Authors
* Copyright (C) 2015-2018 Treasure Data Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <fluent-bit/flb_time.h>
#include <fluent-bit/flb_parser.h>
#include "flb_fuzz_header.h"

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size){
TIMEOUT_GUARD

void *out_buf = NULL;
size_t out_size = 0;
struct flb_time out_time;
Expand Down
19 changes: 19 additions & 0 deletions tests/internal/fuzzers/parser_fuzzer.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/* Fluent Bit
* ==========
* Copyright (C) 2019-2021 The Fluent Bit Authors
* Copyright (C) 2015-2018 Treasure Data Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
Expand All @@ -12,6 +29,8 @@

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
TIMEOUT_GUARD

char *format = NULL;
char *time_fmt = NULL;
char *time_key = NULL;
Expand Down
22 changes: 21 additions & 1 deletion tests/internal/fuzzers/utils_fuzzer.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/* Fluent Bit
* ==========
* Copyright (C) 2019-2021 The Fluent Bit Authors
* Copyright (C) 2015-2018 Treasure Data Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <stdint.h>
#include <string.h>
#include <stdlib.h>
Expand All @@ -9,10 +27,12 @@
#include <fluent-bit/flb_uri.h>
#include <fluent-bit/flb_sha512.h>
#include <fluent-bit/flb_regex.h>
#include "flb_fuzz_header.h"

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* We need a bit of data in this fuzzer */
TIMEOUT_GUARD

if (size < 600) {
return 0;
}
Expand Down