diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2023-11-01 22:24:09 +0100 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2023-11-01 22:31:56 +0100 |
commit | c4a03693521c80c28b02da8580c970635656a17b (patch) | |
tree | 955c2cc0a682b76d8381f22e5a7a2a3ba2dcaebd /example/ndpiReader.c | |
parent | d5c9a16a489081c0b5bd396241c7e08649a60a4c (diff) |
Added malicious sites from the polish cert.add/malicious-sites
* added handling of parsing errors
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r-- | example/ndpiReader.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index aea2c4878..27f300775 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -2680,8 +2680,13 @@ static void setupDetection(u_int16_t thread_id, pcap_t * pcap_handle) { exit(-1); } - if(_categoriesDirPath) - ndpi_load_categories_dir(ndpi_thread_info[thread_id].workflow->ndpi_struct, _categoriesDirPath); + if(_categoriesDirPath) { + int failed_files = ndpi_load_categories_dir(ndpi_thread_info[thread_id].workflow->ndpi_struct, _categoriesDirPath); + if (failed_files < 0) { + fprintf(stderr, "Failed to parse all *.list files in: %s\n", _categoriesDirPath); + exit(-1); + } + } if(_riskyDomainFilePath) ndpi_load_risk_domain_file(ndpi_thread_info[thread_id].workflow->ndpi_struct, _riskyDomainFilePath); @@ -2700,7 +2705,11 @@ static void setupDetection(u_int16_t thread_id, pcap_t * pcap_handle) { else label = _customCategoryFilePath; - ndpi_load_categories_file(ndpi_thread_info[thread_id].workflow->ndpi_struct, _customCategoryFilePath, label); + int failed_lines = ndpi_load_categories_file(ndpi_thread_info[thread_id].workflow->ndpi_struct, _customCategoryFilePath, label); + if (failed_lines < 0) { + fprintf(stderr, "Failed to parse custom categories file: %s\n", _customCategoryFilePath); + exit(-1); + } } /* Make sure to load lists before finalizing the initialization */ @@ -5505,18 +5514,6 @@ void domainSearchUnitTest() { assert(ndpi_domain_classify_contains(sc, &class_id, "123vc.club")); assert(class_id == NDPI_PROTOCOL_CATEGORY_GAMBLING); -#if 0 - { - const char *fname = NDPI_BASE_DIR "/lists/gambling.list"; - u_int32_t num_domains; - - num_domains = ndpi_domain_classify_add_domains(sc, NDPI_PROTOCOL_GAMBLING, (char*)fname); - assert(num_domains == 35370); - - assert(ndpi_domain_classify_contains(sc, "0grand-casino.com") == NDPI_PROTOCOL_GAMBLING); - } -#endif - /* Subdomain check */ assert(ndpi_domain_classify_contains(sc, &class_id, "blog.ntop.org")); assert(class_id == NDPI_PROTOCOL_NTOP); |