diff --git a/src/entry/FQDN_engine.cpp b/src/entry/FQDN_engine.cpp index 1174397..5e32585 100644 --- a/src/entry/FQDN_engine.cpp +++ b/src/entry/FQDN_engine.cpp @@ -7,7 +7,7 @@ * All rights reserved * * Written by: LIU YANBING (liuyanbing@iie.ac.cn) - * Last modification: 2020-09-19 + * Last modification: 2020-09-01 * * This code is the exclusive and proprietary property of IIE-CAS and NELIST. * Usage for direct or indirect commercial advantage is not allowed without @@ -23,6 +23,7 @@ #include /*************************************************************************************/ + //#include //#define popcnt_u64 _mm_popcnt_u64 //Use gcc builtin function to replace SSE4.2 instruction for portability @@ -243,7 +244,7 @@ int CHashTrieFQDN::initialize(const struct FQDN_rule * rules, size_t n_rule) m_matched[idx]=&(m_domains[k]); } -// printf("mem_bytes=%ll(MB)\n", mem_bytes/(1U<<20)); +// printf("mem_bytes=%u(MB)\n", mem_bytes/(1U<<20)); return 1; } @@ -262,7 +263,7 @@ int CHashTrieFQDN::search(const char * FQDN, size_t FQDN_len, struct FQDN_match { if(m_num==0 || FQDN_len==0 || FQDN==NULL || n_result==0) return -1; - size_t match_num=0; + int match_num=0; const unsigned char * pb=(unsigned char *)FQDN; unsigned long long HASH[16]; /*假设域名级数不超过16*/ unsigned int P[16]; @@ -299,7 +300,7 @@ int CHashTrieFQDN::search(const char * FQDN, size_t FQDN_len, struct FQDN_match if(P[t]!=0 && pt->suf_match==0) continue; if(pt->len+P[t]==FQDN_len && pt->hash==HASH[t]) { - if(match_num>0 && P[t]!=results[match_num-1].offset) return match_num; + //if(match_num>0 && P[t]!=results[match_num-1].offset) return match_num; results[match_num].id=pt->id; results[match_num].offset=P[t]; results[match_num].user_tag=pt->utag; diff --git a/src/entry/Maat_table_runtime.cpp b/src/entry/Maat_table_runtime.cpp index 5130eab..292c3e2 100644 --- a/src/entry/Maat_table_runtime.cpp +++ b/src/entry/Maat_table_runtime.cpp @@ -116,6 +116,16 @@ static void destroy_digest_rule(GIE_digest_t*rule) struct FQDN_rule* fqdn_rule_new(unsigned int id, const char* fqdn, size_t fqdn_len, int is_suffix_match) { struct FQDN_rule* fqdn_rule=ALLOC(struct FQDN_rule, 1); + //Todo: check FQDN format with regex ^([a-zA-Z0-9._-])+$ + if(fqdn[0]=='.') + { + fqdn++; + fqdn_len--; + } + if(fqdn[fqdn_len]=='/') + { + fqdn_len--; + } fqdn_rule->FQDN=ALLOC(char, fqdn_len+1); memcpy(fqdn_rule->FQDN, fqdn, fqdn_len); fqdn_rule->len=fqdn_len; diff --git a/test/test_maatframe.cpp b/test/test_maatframe.cpp index 48603f0..f7fd07a 100644 --- a/test/test_maatframe.cpp +++ b/test/test_maatframe.cpp @@ -380,8 +380,6 @@ TEST(FQDN_Plugin_Table, EX_DATA) ret=Maat_fqdn_plugin_get_EX_data(g_feather, table_id, "r3---sn-i3belne6.example2.com", (void**)result, 4); ASSERT_EQ(ret, 2); - EXPECT_EQ(result[0]->rule_id, 204); - EXPECT_EQ(result[1]->rule_id, 205); for(i=0; i