完成“非”运算规则的解析。

This commit is contained in:
zhengchao
2019-01-05 15:51:08 +08:00
parent af262502e9
commit 475c93093a
4 changed files with 397 additions and 25 deletions

View File

@@ -108,6 +108,7 @@ struct db_group_rule_t
int group_id;
int compile_id;
int is_valid;
int not_flag;
};
struct op_expr_t
{
@@ -144,7 +145,8 @@ struct _Maat_group_inner_t
struct _Maat_compile_inner_t
{
struct db_compile_rule_t *db_c_rule;
dynamic_array_t *groups;
dynamic_array_t *groups; //element is struct _Maat_group_inner_t*
char not_flag[MAX_ITEMS_PER_BOOL_EXPR];
int is_valid;
int compile_id;//equal to db_c_rule->m_rule.config_id
const struct Maat_table_desc* ref_table;
@@ -234,6 +236,10 @@ struct ip_runtime
long long ipv6_rule_cnt;
};
struct group_runtime
{
long long not_flag_group;
};
struct Maat_table_runtime
{
enum MAAT_TABLE_TYPE table_type;
@@ -244,6 +250,7 @@ struct Maat_table_runtime
struct plugin_runtime plugin;
struct expr_runtime expr;
struct ip_runtime ip;
struct group_runtime group;
void * other;
};
mcore_long_t scan_cnt;
@@ -266,10 +273,7 @@ struct _Maat_scanner_t
long gie_total_q_size;
struct Maat_table_runtime* table_rt[MAX_TABLE_NUM];
/*
struct similar_runtime gie_aux[MAX_TABLE_NUM];
struct plugin_runtime plugin_aux[MAX_TABLE_NUM];
*/
MESA_htable_handle region_hash;
MESA_htable_handle group_hash;
MESA_htable_handle compile_hash;
@@ -283,7 +287,7 @@ struct _Maat_scanner_t
void * bool_macher_expr_compiler;
scan_result_t *region_rslt_buff;
MESA_lqueue_head tomb_ref;//reference of g_feather->garbage_q
// struct _region_stat_t region_counter[MAX_TABLE_NUM];
int max_thread_num;
iconv_t iconv_handle[MAX_CHARSET_NUM][MAX_CHARSET_NUM];//iconv_handle[to][from]
};
@@ -374,7 +378,7 @@ struct _Maat_feather_t
int active_plugin_table_num;
int is_last_plugin_table_updating;
//for stat>>>>
//for scanner independent stat>>>>
int backgroud_update_enabled;
screen_stat_handle_t stat_handle;
int total_stat_id;

View File

@@ -0,0 +1,56 @@
/*
*
* Copyright (c) 2018
* String Algorithms Research Group
* Institute of Information Engineering, Chinese Academy of Sciences (IIE-CAS)
* National Engineering Laboratory for Information Security Technologies (NELIST)
* All rights reserved
*
* Written by: LIU YANBING (liuyanbing@iie.ac.cn)
* Last modification: 2018-12-31
*
* This code is the exclusive and proprietary property of IIE-CAS and NELIST.
* Usage for direct or indirect commercial advantage is not allowed without
* written permission from the authors.
*
*/
#ifndef INCLUDE_BOOL_MATCHER_H
#define INCLUDE_BOOL_MATCHER_H
#include <stddef.h>
#ifdef __cplusplus
extern "C"
{
#endif
#define MAX_ITEMS_PER_BOOL_EXPR 8
/*not_flag=0表示布尔项item_id必须出现not_flag=1表示布尔项item_id不能出现*/
struct bool_item
{
unsigned long long item_id;
unsigned char not_flag;
};
/*注意:不支持布尔项全“非”的情形*/
struct bool_expr
{
void * user_tag;
size_t item_num;
struct bool_item items[MAX_ITEMS_PER_BOOL_EXPR];
};
struct bool_matcher;
/*注意本函数调用会交换bool_exprs中元素的位置*/
struct bool_matcher * bool_matcher_new(struct bool_expr * exprs, size_t expr_num, unsigned int max_thread_num, size_t * mem_size);
int bool_matcher_match(struct bool_matcher * matcher, unsigned int thread_id, unsigned long long * item_ids, size_t item_num, void ** result, size_t size);
void bool_matcher_free(struct bool_matcher * matcher);
#ifdef __cplusplus
}
#endif
#endif