diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2023-12-11 12:48:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-11 12:48:50 +0100 |
commit | adf8982d8ec8a1f84bdf48b0129f5fccbb12e51b (patch) | |
tree | 228d72dfcb917f90e544eb42326ece865179de44 /fuzz | |
parent | 59d476195cb3ac5cf6bd139f43698c3cdc1a8b7a (diff) |
fuzz: extend fuzzing coverage (#2205)
Diffstat (limited to 'fuzz')
-rw-r--r-- | fuzz/fuzz_alg_hw_rsi_outliers_da.cpp | 1 | ||||
-rw-r--r-- | fuzz/fuzz_alg_hw_rsi_outliers_da.options | 2 | ||||
-rw-r--r-- | fuzz/fuzz_common_code.c | 5 | ||||
-rw-r--r-- | fuzz/fuzz_gcrypt_aes.cpp | 2 | ||||
-rw-r--r-- | fuzz/fuzz_gcrypt_cipher.cpp | 4 | ||||
-rw-r--r-- | fuzz/fuzz_gcrypt_gcm.cpp | 6 | ||||
-rw-r--r-- | fuzz/fuzz_ndpi_reader.c | 7 |
7 files changed, 16 insertions, 11 deletions
diff --git a/fuzz/fuzz_alg_hw_rsi_outliers_da.cpp b/fuzz/fuzz_alg_hw_rsi_outliers_da.cpp index 6e4f2af17..9e55a22e5 100644 --- a/fuzz/fuzz_alg_hw_rsi_outliers_da.cpp +++ b/fuzz/fuzz_alg_hw_rsi_outliers_da.cpp @@ -74,6 +74,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { ndpi_predict_linear(values, num_values, predict_periods, &prediction); /* Data analysis stuff */ + ndpi_data_print_window_values(a); ndpi_data_average(a); ndpi_data_mean(a); ndpi_data_variance(a); diff --git a/fuzz/fuzz_alg_hw_rsi_outliers_da.options b/fuzz/fuzz_alg_hw_rsi_outliers_da.options new file mode 100644 index 000000000..1c815b33f --- /dev/null +++ b/fuzz/fuzz_alg_hw_rsi_outliers_da.options @@ -0,0 +1,2 @@ +[libfuzzer] +close_fd_mask=1 diff --git a/fuzz/fuzz_common_code.c b/fuzz/fuzz_common_code.c index d13b519ce..b48fa9133 100644 --- a/fuzz/fuzz_common_code.c +++ b/fuzz/fuzz_common_code.c @@ -42,8 +42,6 @@ void fuzz_init_detection_module(struct ndpi_detection_module_struct **ndpi_info_ if(*ndpi_info_mod == NULL) { *ndpi_info_mod = ndpi_init_detection_module(prefs); - NDPI_BITMASK_SET_ALL(all); - ndpi_set_protocol_detection_bitmask2(*ndpi_info_mod, &all); NDPI_BITMASK_SET_ALL(debug_bitmask); ndpi_set_log_level(*ndpi_info_mod, 4); @@ -56,6 +54,9 @@ void fuzz_init_detection_module(struct ndpi_detection_module_struct **ndpi_info_ ndpi_load_malicious_ja3_file(*ndpi_info_mod, "ja3_fingerprints.csv"); ndpi_load_malicious_sha1_file(*ndpi_info_mod, "sha1_fingerprints.csv"); + NDPI_BITMASK_SET_ALL(all); + ndpi_set_protocol_detection_bitmask2(*ndpi_info_mod, &all); + ndpi_finalize_initialization(*ndpi_info_mod); } } diff --git a/fuzz/fuzz_gcrypt_aes.cpp b/fuzz/fuzz_gcrypt_aes.cpp index 1469ab0ce..527a501f9 100644 --- a/fuzz/fuzz_gcrypt_aes.cpp +++ b/fuzz/fuzz_gcrypt_aes.cpp @@ -3,7 +3,7 @@ #include "fuzzer/FuzzedDataProvider.h" #define MBEDTLS_CHECK_RETURN_TYPICAL -#include "../src/lib/third_party/include/gcrypt/aes.h" +#include "gcrypt/aes.h" extern int force_no_aesni; diff --git a/fuzz/fuzz_gcrypt_cipher.cpp b/fuzz/fuzz_gcrypt_cipher.cpp index 270c583ea..703e480a7 100644 --- a/fuzz/fuzz_gcrypt_cipher.cpp +++ b/fuzz/fuzz_gcrypt_cipher.cpp @@ -5,8 +5,8 @@ #define MBEDTLS_CHECK_RETURN_TYPICAL #define MBEDTLS_INTERNAL_VALIDATE_RET( cond, ret ) do { } while( 0 ) -#include "../src/lib/third_party/include/gcrypt/cipher.h" -#include "../src/lib/third_party/include/gcrypt/aes.h" +#include "gcrypt/cipher.h" +#include "gcrypt/aes.h" extern int force_no_aesni; diff --git a/fuzz/fuzz_gcrypt_gcm.cpp b/fuzz/fuzz_gcrypt_gcm.cpp index 3e0b85cca..bf8311dd6 100644 --- a/fuzz/fuzz_gcrypt_gcm.cpp +++ b/fuzz/fuzz_gcrypt_gcm.cpp @@ -5,9 +5,9 @@ #define MBEDTLS_CHECK_RETURN_TYPICAL #define MBEDTLS_INTERNAL_VALIDATE_RET( cond, ret ) do { } while( 0 ) -#include "../src/lib/third_party/include/gcrypt/aes.h" -#include "../src/lib/third_party/include/gcrypt/cipher.h" -#include "../src/lib/third_party/include/gcrypt/gcm.h" +#include "gcrypt/aes.h" +#include "gcrypt/cipher.h" +#include "gcrypt/gcm.h" extern int force_no_aesni; diff --git a/fuzz/fuzz_ndpi_reader.c b/fuzz/fuzz_ndpi_reader.c index 9a3eec625..5f2d980c5 100644 --- a/fuzz/fuzz_ndpi_reader.c +++ b/fuzz/fuzz_ndpi_reader.c @@ -57,9 +57,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { #endif workflow = ndpi_workflow_init(prefs, NULL /* pcap handler will be set later */, 0, ndpi_serialization_format_json); - // enable all protocols - NDPI_BITMASK_SET_ALL(all); - ndpi_set_protocol_detection_bitmask2(workflow->ndpi_struct, &all); NDPI_BITMASK_SET_ALL(debug_bitmask); ndpi_set_log_level(workflow->ndpi_struct, 4); @@ -71,6 +68,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { ndpi_load_malicious_ja3_file(workflow->ndpi_struct, "ja3_fingerprints.csv"); ndpi_load_malicious_sha1_file(workflow->ndpi_struct, "sha1_fingerprints.csv"); + // enable all protocols + NDPI_BITMASK_SET_ALL(all); + ndpi_set_protocol_detection_bitmask2(workflow->ndpi_struct, &all); + ndpi_set_detection_preferences(workflow->ndpi_struct, ndpi_pref_enable_tls_block_dissection, 0 /* unused */); ndpi_set_monitoring_state(workflow->ndpi_struct, NDPI_PROTOCOL_STUN, |