config: move debug/log configuration to the new API
This commit is contained in:
@@ -37,14 +37,12 @@ void fuzz_set_alloc_callbacks_and_seed(int seed)
|
||||
void fuzz_init_detection_module(struct ndpi_detection_module_struct **ndpi_info_mod)
|
||||
{
|
||||
NDPI_PROTOCOL_BITMASK all;
|
||||
NDPI_PROTOCOL_BITMASK debug_bitmask;
|
||||
|
||||
if(*ndpi_info_mod == NULL) {
|
||||
*ndpi_info_mod = ndpi_init_detection_module();
|
||||
|
||||
NDPI_BITMASK_SET_ALL(debug_bitmask);
|
||||
ndpi_set_log_level(*ndpi_info_mod, 4);
|
||||
ndpi_set_debug_bitmask(*ndpi_info_mod, debug_bitmask);
|
||||
ndpi_set_config(*ndpi_info_mod, NULL, "log.level", "3");
|
||||
ndpi_set_config(*ndpi_info_mod, "all", "log.enable", "1");
|
||||
|
||||
ndpi_load_categories_dir(*ndpi_info_mod, "./lists/");
|
||||
ndpi_load_protocols_file(*ndpi_info_mod, "protos.txt");
|
||||
|
||||
@@ -137,6 +137,20 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
sprintf(cfg_value, "%d", value);
|
||||
ndpi_set_config(ndpi_info_mod, "ookla", "aggressiveness", cfg_value);
|
||||
}
|
||||
if(fuzzed_data.ConsumeBool()) {
|
||||
value = fuzzed_data.ConsumeIntegralInRange(0, 1 + 1);
|
||||
sprintf(cfg_value, "%d", value);
|
||||
ndpi_set_config(ndpi_info_mod, "any", "log.enable", cfg_value);
|
||||
}
|
||||
for(i = 0; i < NDPI_MAX_SUPPORTED_PROTOCOLS; i++) {
|
||||
if(fuzzed_data.ConsumeBool()) {
|
||||
value = fuzzed_data.ConsumeIntegralInRange(0, 1 + 1);
|
||||
sprintf(cfg_value, "%d", value);
|
||||
sprintf(cfg_proto, "%d", i);
|
||||
/* TODO: we should try to map integer into name */
|
||||
ndpi_set_config(ndpi_info_mod, cfg_proto, "log.enable", cfg_value);
|
||||
}
|
||||
}
|
||||
if(fuzzed_data.ConsumeBool()) {
|
||||
value = fuzzed_data.ConsumeIntegralInRange(0, 1 + 1);
|
||||
sprintf(cfg_value, "%d", value);
|
||||
|
||||
@@ -6,7 +6,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
struct ndpi_detection_module_struct *ndpi_struct;
|
||||
FILE *fd;
|
||||
NDPI_PROTOCOL_BITMASK all;
|
||||
NDPI_PROTOCOL_BITMASK debug_bitmask;
|
||||
|
||||
/* To allow memory allocation failures */
|
||||
fuzz_set_alloc_callbacks_and_seed(size);
|
||||
@@ -15,17 +14,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
NDPI_BITMASK_SET_ALL(all);
|
||||
ndpi_set_protocol_detection_bitmask2(ndpi_struct, &all);
|
||||
|
||||
NDPI_BITMASK_SET_ALL(debug_bitmask);
|
||||
ndpi_set_log_level(ndpi_struct, 4);
|
||||
ndpi_set_debug_bitmask(ndpi_struct, debug_bitmask);
|
||||
ndpi_set_config(ndpi_struct, NULL, "log.level", "3");
|
||||
ndpi_set_config(ndpi_struct, "all", "log.enable", "1");
|
||||
|
||||
fd = buffer_to_file(data, size);
|
||||
load_categories_file_fd(ndpi_struct, fd, NULL);
|
||||
if(fd)
|
||||
fclose(fd);
|
||||
|
||||
/* We don't really need to call ndpi_finalize_initialization */
|
||||
|
||||
ndpi_exit_detection_module(ndpi_struct);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
struct ndpi_detection_module_struct *ndpi_struct;
|
||||
FILE *fd;
|
||||
NDPI_PROTOCOL_BITMASK all;
|
||||
NDPI_PROTOCOL_BITMASK debug_bitmask;
|
||||
|
||||
/* To allow memory allocation failures */
|
||||
fuzz_set_alloc_callbacks_and_seed(size);
|
||||
@@ -15,17 +14,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
NDPI_BITMASK_SET_ALL(all);
|
||||
ndpi_set_protocol_detection_bitmask2(ndpi_struct, &all);
|
||||
|
||||
NDPI_BITMASK_SET_ALL(debug_bitmask);
|
||||
ndpi_set_log_level(ndpi_struct, 4);
|
||||
ndpi_set_debug_bitmask(ndpi_struct, debug_bitmask);
|
||||
ndpi_set_config(ndpi_struct, NULL, "log.level", "3");
|
||||
ndpi_set_config(ndpi_struct, "all", "log.enable", "1");
|
||||
|
||||
fd = buffer_to_file(data, size);
|
||||
load_malicious_ja3_file_fd(ndpi_struct, fd);
|
||||
if(fd)
|
||||
fclose(fd);
|
||||
|
||||
/* We don't really need to call ndpi_finalize_initialization */
|
||||
|
||||
ndpi_exit_detection_module(ndpi_struct);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
struct ndpi_detection_module_struct *ndpi_struct;
|
||||
FILE *fd;
|
||||
NDPI_PROTOCOL_BITMASK all;
|
||||
NDPI_PROTOCOL_BITMASK debug_bitmask;
|
||||
|
||||
/* To allow memory allocation failures */
|
||||
fuzz_set_alloc_callbacks_and_seed(size);
|
||||
@@ -15,17 +14,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
NDPI_BITMASK_SET_ALL(all);
|
||||
ndpi_set_protocol_detection_bitmask2(ndpi_struct, &all);
|
||||
|
||||
NDPI_BITMASK_SET_ALL(debug_bitmask);
|
||||
ndpi_set_log_level(ndpi_struct, 4);
|
||||
ndpi_set_debug_bitmask(ndpi_struct, debug_bitmask);
|
||||
ndpi_set_config(ndpi_struct, NULL, "log.level", "3");
|
||||
ndpi_set_config(ndpi_struct, "all", "log.enable", "1");
|
||||
|
||||
fd = buffer_to_file(data, size);
|
||||
load_malicious_sha1_file_fd(ndpi_struct, fd);
|
||||
if(fd)
|
||||
fclose(fd);
|
||||
|
||||
/* We don't really need to call ndpi_finalize_initialization */
|
||||
|
||||
ndpi_exit_detection_module(ndpi_struct);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
struct ndpi_detection_module_struct *ndpi_struct;
|
||||
FILE *fd;
|
||||
NDPI_PROTOCOL_BITMASK all;
|
||||
NDPI_PROTOCOL_BITMASK debug_bitmask;
|
||||
|
||||
/* To allow memory allocation failures */
|
||||
fuzz_set_alloc_callbacks_and_seed(size);
|
||||
@@ -15,17 +14,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
NDPI_BITMASK_SET_ALL(all);
|
||||
ndpi_set_protocol_detection_bitmask2(ndpi_struct, &all);
|
||||
|
||||
NDPI_BITMASK_SET_ALL(debug_bitmask);
|
||||
ndpi_set_log_level(ndpi_struct, 4);
|
||||
ndpi_set_debug_bitmask(ndpi_struct, debug_bitmask);
|
||||
ndpi_set_config(ndpi_struct, NULL, "log.level", "3");
|
||||
ndpi_set_config(ndpi_struct, "all", "log.enable", "1");
|
||||
|
||||
fd = buffer_to_file(data, size);
|
||||
load_protocols_file_fd(ndpi_struct, fd);
|
||||
if(fd)
|
||||
fclose(fd);
|
||||
|
||||
/* We don't really need to call ndpi_finalize_initialization */
|
||||
|
||||
ndpi_exit_detection_module(ndpi_struct);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
struct ndpi_detection_module_struct *ndpi_struct;
|
||||
FILE *fd;
|
||||
NDPI_PROTOCOL_BITMASK all;
|
||||
NDPI_PROTOCOL_BITMASK debug_bitmask;
|
||||
|
||||
/* To allow memory allocation failures */
|
||||
fuzz_set_alloc_callbacks_and_seed(size);
|
||||
@@ -15,17 +14,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
NDPI_BITMASK_SET_ALL(all);
|
||||
ndpi_set_protocol_detection_bitmask2(ndpi_struct, &all);
|
||||
|
||||
NDPI_BITMASK_SET_ALL(debug_bitmask);
|
||||
ndpi_set_log_level(ndpi_struct, 4);
|
||||
ndpi_set_debug_bitmask(ndpi_struct, debug_bitmask);
|
||||
ndpi_set_config(ndpi_struct, NULL, "log.level", "3");
|
||||
ndpi_set_config(ndpi_struct, "all", "log.enable", "1");
|
||||
|
||||
fd = buffer_to_file(data, size);
|
||||
load_risk_domain_file_fd(ndpi_struct, fd);
|
||||
if(fd)
|
||||
fclose(fd);
|
||||
|
||||
/* We don't really need to call ndpi_finalize_initialization */
|
||||
|
||||
ndpi_exit_detection_module(ndpi_struct);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
struct ndpi_workflow_prefs *prefs = NULL;
|
||||
struct ndpi_workflow *workflow = NULL;
|
||||
|
||||
int nDPI_LogLevel = 0;
|
||||
char *_debug_protocols = NULL;
|
||||
u_int32_t current_ndpi_memory = 0, max_ndpi_memory = 0;
|
||||
u_int8_t enable_protocol_guess = 1, enable_payload_analyzer = 0;
|
||||
u_int8_t enable_flow_stats = 1;
|
||||
@@ -36,7 +34,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
int r;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
NDPI_PROTOCOL_BITMASK all;
|
||||
NDPI_PROTOCOL_BITMASK debug_bitmask;
|
||||
u_int i;
|
||||
FILE *fd;
|
||||
|
||||
@@ -57,9 +54,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
|
||||
workflow = ndpi_workflow_init(prefs, NULL /* pcap handler will be set later */, 0, ndpi_serialization_format_json);
|
||||
|
||||
NDPI_BITMASK_SET_ALL(debug_bitmask);
|
||||
ndpi_set_log_level(workflow->ndpi_struct, 4);
|
||||
ndpi_set_debug_bitmask(workflow->ndpi_struct, debug_bitmask);
|
||||
ndpi_set_config(workflow->ndpi_struct, NULL, "log.level", "3");
|
||||
ndpi_set_config(workflow->ndpi_struct, "all", "log.enable", "1");
|
||||
|
||||
ndpi_load_protocols_file(workflow->ndpi_struct, "protos.txt");
|
||||
ndpi_load_categories_file(workflow->ndpi_struct, "categories.txt", NULL);
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
extern u_int8_t enable_doh_dot_detection;
|
||||
|
||||
char *_debug_protocols;
|
||||
int nDPI_LogLevel = 0;
|
||||
u_int32_t current_ndpi_memory = 0, max_ndpi_memory = 0;
|
||||
u_int8_t enable_protocol_guess = 1, enable_payload_analyzer = 0;
|
||||
u_int8_t enable_flow_stats = 0;
|
||||
@@ -34,6 +32,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
FILE *fd;
|
||||
u_int8_t debug_protos_index;
|
||||
char *_debug_protocols;
|
||||
const char *strs[] = { "all",
|
||||
"dns,quic",
|
||||
"+dns:-quic",
|
||||
|
||||
Reference in New Issue
Block a user