修复FQDN_engine.cpp中后缀匹配不能多命中的bug。
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
* All rights reserved
|
* All rights reserved
|
||||||
*
|
*
|
||||||
* Written by: LIU YANBING (liuyanbing@iie.ac.cn)
|
* 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.
|
* This code is the exclusive and proprietary property of IIE-CAS and NELIST.
|
||||||
* Usage for direct or indirect commercial advantage is not allowed without
|
* Usage for direct or indirect commercial advantage is not allowed without
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
|
|
||||||
//#include <nmmintrin.h>
|
//#include <nmmintrin.h>
|
||||||
//#define popcnt_u64 _mm_popcnt_u64
|
//#define popcnt_u64 _mm_popcnt_u64
|
||||||
//Use gcc builtin function to replace SSE4.2 instruction for portability
|
//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]);
|
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;
|
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;
|
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;
|
const unsigned char * pb=(unsigned char *)FQDN;
|
||||||
unsigned long long HASH[16]; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>16*/
|
unsigned long long HASH[16]; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>16*/
|
||||||
unsigned int P[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(P[t]!=0 && pt->suf_match==0) continue;
|
||||||
if(pt->len+P[t]==FQDN_len && pt->hash==HASH[t])
|
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].id=pt->id;
|
||||||
results[match_num].offset=P[t];
|
results[match_num].offset=P[t];
|
||||||
results[match_num].user_tag=pt->utag;
|
results[match_num].user_tag=pt->utag;
|
||||||
|
|||||||
@@ -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_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);
|
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);
|
fqdn_rule->FQDN=ALLOC(char, fqdn_len+1);
|
||||||
memcpy(fqdn_rule->FQDN, fqdn, fqdn_len);
|
memcpy(fqdn_rule->FQDN, fqdn, fqdn_len);
|
||||||
fqdn_rule->len=fqdn_len;
|
fqdn_rule->len=fqdn_len;
|
||||||
|
|||||||
@@ -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);
|
ret=Maat_fqdn_plugin_get_EX_data(g_feather, table_id, "r3---sn-i3belne6.example2.com", (void**)result, 4);
|
||||||
ASSERT_EQ(ret, 2);
|
ASSERT_EQ(ret, 2);
|
||||||
EXPECT_EQ(result[0]->rule_id, 204);
|
|
||||||
EXPECT_EQ(result[1]->rule_id, 205);
|
|
||||||
for(i=0; i<ret; i++)
|
for(i=0; i<ret; i++)
|
||||||
{
|
{
|
||||||
fqdn_plugin_EX_free_cb(0, (void**)&(result[i]), 0, NULL);
|
fqdn_plugin_EX_free_cb(0, (void**)&(result[i]), 0, NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user