diff --git a/docs/api_reference.md b/docs/api_reference.md
index 0086064..c21d138 100644
--- a/docs/api_reference.md
+++ b/docs/api_reference.md
@@ -14,7 +14,7 @@ After that, call maat_new to create a maat instance. Next, for the two main usag
* Call maat_state_new to create a maat_state structure to save the intermediate state of the scan.
- * Call the maat_scan_xx interface to perform the scan task and return the hit compile_id.
+ * Call the maat_scan_xx interface to perform the scan task and return the hit rule_id.
* If you are interested in the hit item, group, or path information, you can call the maat_state_get_xx interface as needed.
@@ -68,9 +68,9 @@ After that, call maat_new to create a maat instance. Next, for the two main usag
* [maat_state_reset](#maat_state_reset)
* [maat_state_free](#maat_state_free)
* [maat_state_set_scan_district](#maat_state_set_scan_district)
-* [maat_state_set_scan_compile_table](#maat_state_set_scan_compile_table)
+* [maat_state_set_scan_rule_table](#maat_state_set_scan_rule_table)
* [maat_state_get_hit_paths](#maat_state_get_hit_paths)
-* [maat_state_get_compile_table_ids](#maat_state_get_compile_table_ids)
+* [maat_state_get_rule_table_ids](#maat_state_get_rule_table_ids)
* [maat_state_get_scan_count](#maat_state_get_scan_count)
* [maat_state_get_direct_hit_groups](#maat_state_get_direct_hit_groups)
* [maat_state_get_direct_hit_group_cnt](#maat_state_get_direct_hit_group_cnt)
@@ -602,18 +602,18 @@ To set the field to be matched in the next scan, for example: if you want to mat
**Returns**: success(0) failure(-1)
-### maat_state_set_scan_compile_table
+### maat_state_set_scan_rule_table
```c
-int maat_state_set_scan_compile_table(struct maat_state *state,
- int compile_table_id);
+int maat_state_set_scan_rule_table(struct maat_state *state,
+ int rule_table_id);
```
-Maat supports loading multiple compile tables and building their respective runtime. Within the table schema, there is a compile table that has a `default_compile_table` field, indicating that maat will use the runtime of this table to calculate which compile_id will be hit by the hit group_id. If the caller wants to use another compile table runtime for the above calculation, this interface can be invoked to set it up.
+Maat supports loading multiple rule tables and building their respective runtime. Within the table schema, there is a rule table that has a `default_rule_table` field, indicating that maat will use the runtime of this table to calculate which rule_id will be hit by the hit group_id. If the caller wants to use another rule table runtime for the above calculation, this interface can be invoked to set it up.
**Parameters**:
* state - Pointer to the maat state structure.
-* compile_table_id - The compile table ID.
+* rule_table_id - The rule table ID.
**Returns**: success(0) failure(-1)
@@ -636,24 +636,24 @@ Gets all hit paths since maat state was created.
**Returns**: The number of hit paths is returned on success, and -1 is returned on failure.
-### maat_state_get_compile_table_ids
+### maat_state_get_rule_table_ids
```c
-int maat_state_get_compile_table_ids(struct maat_state *state,
- long long *compile_ids,
- size_t n_compile_ids,
- int *compile_table_ids);
+int maat_state_get_rule_table_ids(struct maat_state *state,
+ long long *rule_ids,
+ size_t n_rule_ids,
+ int *rule_table_ids);
```
-Get the ID of the table that compile_id belongs to.
+Get the ID of the table that rule_id belongs to.
**Parameters**:
* state - Pointer to the maat state structure.
-* compile_ids - Array of compile_ids.
-* n_compild_ids - The number of compile_ids.
-* compile_table_ids - The array of id of the tables to which each compile id belongs.
+* rule_ids - Array of rule_ids.
+* n_compild_ids - The number of rule_ids.
+* rule_table_ids - The array of id of the tables to which each rule id belongs.
-**Returns**: The number of compile table ids is return on success, and -1 is returned on failure.
+**Returns**: The number of rule table ids is return on success, and -1 is returned on failure.
### maat_state_get_scan_count
@@ -780,15 +780,15 @@ int maat_scan_flag(struct maat *instance, int table_id, long long flag,
struct maat_state *state);
```
-Check if the `flag` in the scan input hits the rules in the effective compile table. If there is a hit, put the compile_id of the rules into the results array and put the number of hit compile_ids into n_hit_result.
+Check if the `flag` in the scan input hits the rules in the effective rule table. If there is a hit, put the rule_id of the rules into the results array and put the number of hit rule_ids into n_hit_result.
**Parameters**:
* instance - Maat instance created by maat_new().
* table_id - ID of the table to be scanned.
* flag - Data to be scanned.
-* results - Array to store hit compile_ids.
+* results - Array to store hit rule_ids.
* n_result - Size of the results array.
-* n_hit_result - The number of hit compile_ids.
+* n_hit_result - The number of hit rule_ids.
* state - Used to store the intermediate state of the scan.
**Returns**:
@@ -850,7 +850,7 @@ int maat_scan_group(struct maat *instance, int table_id,
size_t *n_hit_result, struct maat_state *state);
```
-Different from the above interface, the input to this interface is the hit item_id and group_id. Therefore, there is no need to execute the underlying scanning engine. It only needs to calculate the hit compile_id based on the hit group_id.
+Different from the above interface, the input to this interface is the hit item_id and group_id. Therefore, there is no need to execute the underlying scanning engine. It only needs to calculate the hit rule_id based on the hit group_id.
### maat_scan_not_logic
@@ -861,7 +861,7 @@ int maat_scan_not_logic(struct maat *instance, int table_id,
size_t *n_hit_result, struct maat_state *state);
```
-If the compile configuration contains NOT-clauses, this interface needs to be called to activate the calculation of compile_id involving NOT-clauses. This means that other scanning interfaces will not activate NOT-clauses except for calling this interface. When to call this interface is determined by the caller. For example, on a session, four packets were scanned with maat_scan_string and three compile_id were hit. The NOT-clause was expected to be activated, so this interface was called and two new compile_id were hit.
+If the rule configuration contains NOT-clauses, this interface needs to be called to activate the calculation of rule_id involving NOT-clauses. This means that other scanning interfaces will not activate NOT-clauses except for calling this interface. When to call this interface is determined by the caller. For example, on a session, four packets were scanned with maat_scan_string and three rule_id were hit. The NOT-clause was expected to be activated, so this interface was called and two new rule_id were hit.
Since this interface only activates non-clauses and does not call the underlying scanning engine to perform actual scanning tasks, there is no data to be scanned.
@@ -894,15 +894,15 @@ int maat_stream_scan(struct maat_stream *stream, const char *data, int data_len,
struct maat_state *state);
```
-This interface is used to perform streaming scanning tasks, for example: in a session, consecutively scanning multiple packets and providing the hit compile_ids.
+This interface is used to perform streaming scanning tasks, for example: in a session, consecutively scanning multiple packets and providing the hit rule_ids.
**Parameters**:
* stream - Maat_stream handle created by maat_stream_new().
* data - Data to be scanned.
* data_len - The length of the data.
-* results - Array to store hit compile_ids.
+* results - Array to store hit rule_ids.
* n_result - Size of the results array.
-* n_hit_result - The number of hit compile_ids.
+* n_hit_result - The number of hit rule_ids.
* state - Used to store the intermediate state of the scan.
**Returns**:
diff --git a/docs/configuration_management.md b/docs/configuration_management.md
index 340990e..513adb7 100644
--- a/docs/configuration_management.md
+++ b/docs/configuration_management.md
@@ -9,7 +9,7 @@ Maat supports three configuration loading modes:
## 1. Redis mode
-As shown in the diagram below, the data source is stored in the relational database `MariaDB`. An adapter writes this data into the `leader redis`, which is then distributed through redis's `leader-follower synchronization` mechanism. The storage structure design in redis for configurations does not need to consider the logical relationships between compile, group, and item. Maat will construct these logical relationships internally after loading the configurations from redis.
+As shown in the diagram below, the data source is stored in the relational database `MariaDB`. An adapter writes this data into the `leader redis`, which is then distributed through redis's `leader-follower synchronization` mechanism. The storage structure design in redis for configurations does not need to consider the logical relationships between rule, group, and item. Maat will construct these logical relationships internally after loading the configurations from redis.
@@ -23,7 +23,7 @@ As shown in the diagram below, the data source is stored in the relational datab
| MAAT_UPDATE_STATUS | Configuration status | sorted set, where the member is a configuration rule and the score is the version number | MAAT reads this using ZRANGEBYSCORE command. |
| MAAT_RULE_TIMER | Main configuration timeout information | Sorted Set, where the member is a configuration rule and the score is the timeout | MAAT configuration update thread periodically checks timeout status and sets timeout state. |
| MAAT_VERSION_TIMER | Version creation time | Sorted Set | Stores the creation time of each version, where the score is the version creation time and the member is the version, used to keep MAAT_UPDATE_STATUS within a smaller scale. |
-| MAAT_LABEL_INDEX | Label index | Sorted Set, where the element is the configuration table name, compile_id, and the score is the label_id | |
+| MAAT_LABEL_INDEX | Label index | Sorted Set, where the element is the configuration table name, rule_id, and the score is the label_id | |
| EFFECTIVE_RULE:TableName,ID OBSOLETE_RULE:TableName,ID | Main configuration | string | Active configurations, loaded one by one by MAAT. |
| SEQUENCE_REGION | Region ID generation sequence | INTEGER | Used by producers to generate unique region_id(item_id) |
| SEQUENCE_GROUP | Group ID generation sequence | INTEGER | Used by producers to generate unique group_id |
@@ -161,6 +161,6 @@ To manually add an existing table configuration, the following files need to be
* Append a new line to the table file that needs modification. The region_id should not conflict with any existing domain tables, and update the first line of the file with the new number of rows.
-* Add the summary information of the new configuration to the configuration summary table. Ensure it matches the compile_id in the table file and does not conflict with any existing compile_id. Update the first line of the file with the new number of rows.
+* Add the summary information of the new configuration to the configuration summary table. Ensure it matches the rule_id in the table file and does not conflict with any existing rule_id. Update the first line of the file with the new number of rows.
* Modify the row counts for the configuration summary table and domain tables in the table index file.
\ No newline at end of file
diff --git a/docs/getting_started.md b/docs/getting_started.md
index 9993fe0..bef190b 100644
--- a/docs/getting_started.md
+++ b/docs/getting_started.md
@@ -31,7 +31,7 @@ A complete use case consists of three parts:
### Case1
-In the scanning scenario, it is necessary to configure the schema of multiple tables, including the item table, group2compile table, and compile table. If there is also group nesting involved, the schema of the group2group table needs to be configured.
+In the scanning scenario, it is necessary to configure the schema of multiple tables, including the item table, group2rule table, and rule table. If there is also group nesting involved, the schema of the group2group table needs to be configured.
**(1) table schema**
@@ -41,25 +41,25 @@ Table schema is stored in a json file(such as table_info.conf), which is loaded
[
{
"table_id":0,
- "table_name":"COMPILE",
- "table_type":"compile",
- "default_compile_table":0, /* key:indicate this is the default compile table, value:can be anything(not care) */
+ "table_name":"RULE",
+ "table_type":"rule",
+ "default_rule_table":0, /* key:indicate this is the default rule table, value:can be anything(not care) */
"valid_column":8,
"custom": {
- "compile_id":1,
+ "rule_id":1,
"tags":6,
"clause_num":9
}
},
{
"table_id":1,
- "table_name":"GROUP2COMPILE",
- "table_type":"group2compile",
- "associated_compile_table_id":0, /* associate compile table_id, group2compile table shares the same runtime with the corresponding compile table, so it needs to be mapped to the corresponding compile table. */
+ "table_name":"GROUP2RULE",
+ "table_type":"group2rule",
+ "associated_rule_table_id":0, /* associate rule table_id, group2rule table shares the same runtime with the corresponding rule table, so it needs to be mapped to the corresponding rule table. */
"valid_column":3,
"custom": {
"group_id":1,
- "compile_id":2,
+ "rule_id":2,
"not_flag":4,
"virtual_table_name":5,
"clause_index":6
@@ -98,12 +98,12 @@ Table schema is stored in a json file(such as table_info.conf), which is loaded
Configurations are stored in a json file(such as maat_json.json), which is loaded when maat instance is created.
```json
{
- "compile_table": "COMPILE",
- "group2compile_table": "GROUP2COMPILE",
+ "rule_table": "RULE",
+ "group2rule_table": "GROUP2RULE",
"group2group_table": "GROUP2GROUP",
"rules": [
{
- "compile_id": 123,
+ "rule_id": 123,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -172,7 +172,7 @@ int main()
/**
* Becase maat instance has loaded rule in table_info.conf which keywords is "Hello Maat",
- so maat_scan_string should return hit flag and rule's compile_id stored in results array.
+ so maat_scan_string should return hit flag and rule's rule_id stored in results array.
*/
int ret = maat_scan_string(maat_instance, table_id, scan_data, strlen(scan_data),
results, ARRAY_SIZE, &n_hit_result, state);
@@ -215,8 +215,8 @@ In the callback scenario, only the schema of the corresponding table needs to be
```json
{
- "compile_table": "COMPILE",
- "group2compile_table": "GROUP2COMPILE",
+ "rule_table": "RULE",
+ "group2rule_table": "GROUP2RULE",
"group2group_table": "GROUP2GROUP",
"plugin_table": {
"table_name": "TEST_IP_PLUGIN_WITH_EXDATA",
diff --git a/docs/logical_combinations.md b/docs/logical_combinations.md
index 7ab9a66..7653a40 100644
--- a/docs/logical_combinations.md
+++ b/docs/logical_combinations.md
@@ -33,7 +33,7 @@ Before showing how to configure the specific rules, we need some raw materials (
## AND logic
-`Note`: Each compile supports a maximum of 8 clauses, which are connected by the logical 'AND' relationship, with clause index ranging from 0 to 7.
+`Note`: Each rule supports a maximum of 8 clauses, which are connected by the logical 'AND' relationship, with clause index ranging from 0 to 7.
* case1: Deny hosts with source IP addresses in the range of 192.168.1.11 to 192.168.1.20 from accessing the website www.baidu.com.
@@ -41,7 +41,7 @@ Before showing how to configure the specific rules, we need some raw materials (
* www.baidu.com => group_id(201)
```bash
-compile(rule) = clause1 & clause2
+rule(rule) = clause1 & clause2
= {vtable1, group1, clause_index1} & {vtable2, group2, clause_index2}
= {2, 211, 1} & {1, 201, 2}
```
@@ -52,14 +52,14 @@ compile(rule) = clause1 & clause2
* 端口80 ~ 80 => group_id(221)
```bash
-compile(rule) = clause1 & clause2
+rule(rule) = clause1 & clause2
= {vtable1, group1, clause_index1} & {vtable2, group2, clause_index2}
= {2, 211, 1} & {3, 221, 2}
```
-The JSON configuration for the logical `AND` can be referenced at [unit_test Json configuration](../test/maat_json.json) with compile_id=152.
+The JSON configuration for the logical `AND` can be referenced at [unit_test Json configuration](../test/maat_json.json) with rule_id=152.
-group_name: "152_mail_addr" and group_name: "interval_group_refered" are two clauses of this compile, with a logical `AND` relationship between them.
+group_name: "152_mail_addr" and group_name: "interval_group_refered" are two clauses of this rule, with a logical `AND` relationship between them.
## OR logic
@@ -73,7 +73,7 @@ group_name: "152_mail_addr" and group_name: "interval_group_refered" are two cla
* www.baidu.com => group_id(201)
```bash
-compile(rule) = clause1 & clause2
+rule(rule) = clause1 & clause2
= {vtable1, (group1 | group2), clause_index1} & {vtable2, group3, clause_index2}
= {2, (211 | 212), 1} & {1, 201, 2}
```
@@ -85,12 +85,12 @@ compile(rule) = clause1 & clause2
* port 443 ~ 443 => group_id(222)
```bash
-compile(rule) = clause1 & clause2
+rule(rule) = clause1 & clause2
= {vtable1, group1, clause_index1} & {vtable2, (group2 | group3), clause_index2}
= {2, 211, 1} & {3, (221 | 222), 2}
```
-The JSON configuration for the logical `OR` can be referenced at [unit_test Json configuration](../test/maat_json.json) with compile_id=152.
+The JSON configuration for the logical `OR` can be referenced at [unit_test Json configuration](../test/maat_json.json) with rule_id=152.
group_name: "152_mail_addr" contains two regions(items) with a logical `OR` relationship between them.
@@ -105,7 +105,7 @@ group_name: "152_mail_addr" contains two regions(items) with a logical `OR` rela
* www.baidu.com => group_id(201)
```bash
-compile(rule) = clause1 & !clause2
+rule(rule) = clause1 & !clause2
= {vtable1, group1, clause_index1} & !{vtable2, group2, clause_index2}
= {2, 211, 1} & !{1, 201, 2}
```
@@ -117,14 +117,14 @@ compile(rule) = clause1 & !clause2
* port 443 ~ 443 => group_id(222)
```bash
-compile(rule) = clause1 & !clause2
+rule(rule) = clause1 & !clause2
= {vtable1, group1, clause_index1} & !{vtable2, (group2 | group3), clause_index2}
= {2, 211, 1} & !{3, (221 | 222), 2}
```
-The JSON configuration for the logical `OR` can be referenced at [unit_test Json configuration](../test/maat_json.json) with compile_id=145.
+The JSON configuration for the logical `OR` can be referenced at [unit_test Json configuration](../test/maat_json.json) with rule_id=145.
-The group_name: "123_IP_group" is a NOT clause of this compile.
+The group_name: "123_IP_group" is a NOT clause of this rule.
## Group exclude
@@ -145,9 +145,9 @@ super_group1 = group1 exclude group2
= 210 exclude 211
```
-And then configure the compile.
+And then configure the rule.
```bash
-compile(rule) = clause1 & clause2
+rule(rule) = clause1 & clause2
= {vtable1, super_group1, clause_index1} & {vtable2, group2, clause_index2}
= {2, (210 exclude 211), 1} & {1, 201, 2}
```
@@ -164,13 +164,13 @@ super_group2 = group2 exclude group3
= 202 exclude 201
```
-And then configure the compile.
+And then configure the rule.
```bash
-compile(rule) = clause1 & clause2
+rule(rule) = clause1 & clause2
= {vtable1, group1, clause_index1} & {vtable2, super_group2, clause_index2}
= {2, 211, 1} & {1, (202 exclude 201), 2}
```
-The JSON configuration for the logical `OR` can be referenced at [unit_test Json configuration](../test/maat_json.json) with compile_id=200.
+The JSON configuration for the logical `OR` can be referenced at [unit_test Json configuration](../test/maat_json.json) with rule_id=200.
The group_name: "ExcludeLogicGroup200" is a super group that includes an include group "ExcludeLogicGroup200_1" and an exclude group "ExcludeLogicGroup200_2".
\ No newline at end of file
diff --git a/docs/maat_table.md b/docs/maat_table.md
index bb1216a..8018afe 100644
--- a/docs/maat_table.md
+++ b/docs/maat_table.md
@@ -11,8 +11,8 @@ Maat tables are divided into two categories: physical tables that actually exist
The types of physical tables are as follows:
- [item table](#11-item-table)
-- [compile table](#12-compile-table)
-- [group2compile table](#13-group2compile-table)
+- [rule table](#12-rule-table)
+- [group2rule table](#13-group2rule-table)
- [group2group table](#14-group2group-table)
- [plugin table](#15-plugin-table)
- [ip_plugin table](#16-ip_plugin-table)
@@ -43,7 +43,7 @@ Each item table must has the following columns:
- is_valid: In incremental updates, 1(valid means add) 0(invalid means del)
-The range of item_id(group_id, compile_id) is 0~2^63,which is 8 bytes.
+The range of item_id(group_id, rule_id) is 0~2^63,which is 8 bytes.
#### 1.1.1 expr item table
@@ -52,7 +52,7 @@ Describe matching rules for strings.
| **FieldName** | **type** | **constraint** |
| ---------------- | -------------- | ------- |
| **item_id** | LONG LONG | primary key |
-| **group_id** | LONG LONG | leaf group id, can be referenced by group2group & group2compile table |
+| **group_id** | LONG LONG | leaf group id, can be referenced by group2group & group2rule table |
| **keywords** | VARCHAR2(1024) | field to match during scanning |
| **expr_type** | INT | 0(keywords), 1(AND expr), 2(regular expr), 3(substring with offset)
| **match_method** | INT | only useful when expr_type is 0. 0(sub), 1(suffix), 2(prefix), 3(exactly) |
@@ -158,7 +158,7 @@ Describe extended matching rules for strings by adding the district column.
| **FieldName** | **type** | **constraint** |
| ---------------- | -------------- | ------- |
| **item_id** | LONG LONG | primary key |
-| **group_id** | LONG LONG | leaf group id, can be referenced by group2group & group2compile table |
+| **group_id** | LONG LONG | leaf group id, can be referenced by group2group & group2rule table |
| **district** | VARCHAR2(1024) | describe the effective position of the keywords |
| **keywords** | VARCHAR2(1024) | field to match during scanning |
| **expr_type** | INT | 0(keywords), 1(AND expr), 2(regular expr), 3(substring with offset)
@@ -183,7 +183,7 @@ Describe matching rules for IP address. Both the address and port are represente
| **FieldName** | **type** | **constraint** |
| -------------- | ------------ | -------------- |
| **item_id** | LONG LONG | primary key |
-| **group_id** | LONG LONG | leaf group id, can be referenced by group2group & group2compile table |
+| **group_id** | LONG LONG | leaf group id, can be referenced by group2group & group2rule table |
| **addr_type** | INT | Ipv4 = 4 Ipv6 = 6 |
| **addr_format**| VARCHAR2(40) | ip addr format, single/range/CIDR/mask |
| **ip1** | VARCHAR2(40) | start ip |
@@ -197,7 +197,7 @@ Determine whether an integer is within a certain numerical range.
| **FieldName** | **type** | **constraint** |
| ---------------- | -------- | -------------- |
| **item_id** | INT | primary key |
-| **group_id** | INT | leaf group id, can be referenced by group2group & group2compile table |
+| **group_id** | INT | leaf group id, can be referenced by group2group & group2rule table |
| **low_boundary** | INT | lower bound of the numerical range(including lb), 0 ~ (2^32 - 1)|
| **up_boundary** | INT | upper bound of the numerical range(including ub), 0 ~ (2^32 - 1)|
| **is_valid** | INT | 0(invalid), 1(valid) |
@@ -209,7 +209,7 @@ Describe extended matching rules for integer by adding the district column.
| **FieldName** | **type** | **constraint** |
| ---------------- | -------- | -------------- |
| **item_id** | INT | primary key |
-| **group_id** | INT | leaf group id, can be referenced by group2group & group2compile table |
+| **group_id** | INT | leaf group id, can be referenced by group2group & group2rule table |
| **district** | VARCHAR2(1024)| describe the effective position of the keywords |
| **low_boundary** | INT | lower bound of the numerical range(including lb), 0 ~ (2^32 - 1)|
| **up_boundary** | INT | upper bound of the numerical range(including ub), 0 ~ (2^32 - 1)|
@@ -220,7 +220,7 @@ Describe extended matching rules for integer by adding the district column.
| **FieldName** | **type** | **constraint** |
| ------------- | -------- | -------------- |
| **item_id** | INT | primary key |
-| **group_id** | INT | leaf group id, can be referenced by group2group & group2compile table |
+| **group_id** | INT | leaf group id, can be referenced by group2group & group2rule table |
| **flag** | INT | flag, 0 ~ (2^32 - 1)|
| **flag_mask** | INT | flag_mask, 0 ~ (2^32 - 1)|
| **is_valid** | INT | 0(invalid), 1(valid) |
@@ -230,31 +230,31 @@ Describe extended matching rules for integer by adding the district column.
| **FieldName** | **type** | **constraint** |
| ------------- | -------- | -------------- |
| **item_id** | INT | primary key |
-| **group_id** | INT | leaf group id, can be referenced by group2group & group2compile table |
+| **group_id** | INT | leaf group id, can be referenced by group2group & group2rule table |
| **district** | INT | describe the effective position of the flag |
| **flag** | INT | flag, 0 ~ (2^32 - 1)|
| **flag_mask** | INT | flag_mask, 0 ~ (2^32 - 1)|
| **is_valid** | INT | 0(invalid), 1(valid) |
-### 1.2 compile table
+### 1.2 rule table
-Describe the specific policy, one maat instance can has multiple compile tables with different names.
+Describe the specific policy, one maat instance can has multiple rule tables with different names.
| **FieldName** | **type** | **constraint** |
| -------------- | -------------- | --------------- |
-| **compile_id** | LONG LONG | primary key, compile id |
+| **rule_id** | LONG LONG | primary key, rule id |
| **tags** | VARCHAR2(1024) | default 0,means no tag |
| **is_valid** | INT | 0(invalid),1(valid) |
| **clause_num** | INT | no more than 8 clauses |
-### 1.3 group2compile table
+### 1.3 group2rule table
-Describe the relationship between group and compile.
+Describe the relationship between group and rule.
| **FieldName** | **type** | **constraint** |
| ----------------- | ------------- | -------------- |
| **group_ids** | VARCHAR(256) | group ids are separated by commas(g1,g2,g3) |
-| **compile_id** | LONG LONG | compile id |
+| **rule_id** | LONG LONG | rule id |
| **is_valid** | INT | 0(invalid), 1(valid) |
| **not_flag** | INT | logical 'NOT', identify a NOT clause, 0(no) 1(yes) |
| **virtual_table** | VARCHAR2(256) | virtual table name, NOT NULL |
@@ -402,7 +402,7 @@ Configuration tags are tags stored on compilation configurations or group config
Maat loads the configuration of different types of tables into memory to form the corresponding runtime for each table. We can see all table types from the table schema, and the runtime for the item table is similar, as it is an abstraction of the scanning engine. When we provide the data to be scanned and call the corresponding scanning interface, we can return whether the item is hit or not, and if it is hit, we can return the corresponding item’s group_id.
-From the [configuration relationship](./overview.md#12-configuration-relationship) diagram, we can see how the hit group is referenced by other groups or compiles. If a hit group is referenced by other groups or compiles, there will be one or more hit paths that follow the `item_id -> group_id` {-> super group_id} `-> compile_id`. This requires two special runtimes: group2group_runtime and compile_runtime.
+From the [configuration relationship](./overview.md#12-configuration-relationship) diagram, we can see how the hit group is referenced by other groups or rules. If a hit group is referenced by other groups or rules, there will be one or more hit paths that follow the `item_id -> group_id` {-> super group_id} `-> rule_id`. This requires two special runtimes: group2group_runtime and rule_runtime.
Based on this, we can divide the runtime into the following three categories:
@@ -412,9 +412,9 @@ Based on this, we can divide the runtime into the following three categories:
* flag_runtime
* interval_runtime
-2. group & compile table runtime
+2. group & rule table runtime
* group2group_runtime
- * compile_runtime
+ * rule_runtime
3. xx_plugin table runtime
* plugin_runtime
@@ -431,47 +431,47 @@ Among the four types of runtimes mentioned above, `expr_runtime` is relatively u
**Note**: Due to the inability to unify the native rulescan usage with hyperscan, a partial refactoring has been done on rulescan. The refactored rulescan follows the same interface and usage as hyperscan, making it compatible with the design of the expr_matcher abstraction layer.
-### 2.2 group & compile table runtime
+### 2.2 group & rule table runtime
#### 2.2.1 group2group runtime
The `group2group_runtime` is a runtime that is built based on the reference relationships between groups, which are stored in the [group2group table](#14-group2group-table). From the [group hierarchy](./group_hierarchy.md), we can understand that if a hit occurs in a leaf group that is referenced by other groups, there may be certain super groups that are also hit. This is exactly the functionality provided by this runtime.
-#### 2.2.2 compile runtime
+#### 2.2.2 rule runtime
-In addition to the compile table, there is also the group2compile table in the table schema. However, from a runtime perspective, the configurations of these two tables together constitute compile_runtime. This means that there is no standalone group2compile_runtime. Compile_runtime is the most complex among all runtime types because it serves multiple functions.
+In addition to the rule table, there is also the group2rule table in the table schema. However, from a runtime perspective, the configurations of these two tables together constitute rule_runtime. This means that there is no standalone group2rule_runtime. Rule_runtime is the most complex among all runtime types because it serves multiple functions.
**Note:** This will involve the terminology of [clause](./terminology.md#clause).
-1. For expressions without NOT-clauses, returning the matched compile_id:
+1. For expressions without NOT-clauses, returning the matched rule_id:
- * compile1 = clause1 & clause2 = {vtable1, g1} & {vtable2, g2}
+ * rule1 = clause1 & clause2 = {vtable1, g1} & {vtable2, g2}
- * compile2 = clause1 & clause2 = {vtable1, g2} & {vtable2, g3}
+ * rule2 = clause1 & clause2 = {vtable1, g2} & {vtable2, g3}
- Given the matched vtable_id and group_id, all matching compile_ids can be provided. For example, if scanning vtable1 matches g2 and vtable2 matches g3, compile_runtime will return the matched compile_id 2.
+ Given the matched vtable_id and group_id, all matching rule_ids can be provided. For example, if scanning vtable1 matches g2 and vtable2 matches g3, rule_runtime will return the matched rule_id 2.
-2. For expressions with NOT-clauses, returning the matched compile_id:
+2. For expressions with NOT-clauses, returning the matched rule_id:
- * compile3 = clause1 & !clause2 = {vtable1, g1} & !{vtable2, g2}
+ * rule3 = clause1 & !clause2 = {vtable1, g1} & !{vtable2, g2}
- * compile4 = !clause1 & clause2 = !{vtable1, g2} & {vtable2, g3}
+ * rule4 = !clause1 & clause2 = !{vtable1, g2} & {vtable2, g3}
- If scanning vtable1 matches g1 and vtable2 matches g3, compile_runtime will return the matched compile_id 4.
+ If scanning vtable1 matches g1 and vtable2 matches g3, rule_runtime will return the matched rule_id 4.
-3. If a compile_id is matched, the full hit path can be obtained: **item_id -> group_id ->** {super_group_id} -> clause{**vtable_id, not_flag, clause_index} -> compile_id**. If the matched group is not referenced by a compile, a half hit path can be obtained: **item_id -> group_id** -> {super_group_id}.
+3. If a rule_id is matched, the full hit path can be obtained: **item_id -> group_id ->** {super_group_id} -> clause{**vtable_id, not_flag, clause_index} -> rule_id**. If the matched group is not referenced by a rule, a half hit path can be obtained: **item_id -> group_id** -> {super_group_id}.
4. Getting the matched group_ids and the count of hit groups.
-The internal structure of compile_runtime is as follows, including the control plane for configuration loading and the data plane for external calls.
+The internal structure of rule_runtime is as follows, including the control plane for configuration loading and the data plane for external calls.
-
+
* **Control plane**
-Compile runtime loads the compile table and group2compile table configurations into memory, assigning a unique clause_id to all clauses of each compile. The following three parts are constructed based on the clause_id:
+Rule runtime loads the rule table and group2rule table configurations into memory, assigning a unique clause_id to all clauses of each rule. The following three parts are constructed based on the clause_id:
-1. All clause_ids under the same compile are used to construct AND expressions, and all compile AND expressions are used to build a bool_matcher.
+1. All clause_ids under the same rule are used to construct AND expressions, and all rule AND expressions are used to build a bool_matcher.
2. For not_flag=0 (clauses), a `clause_id hash` is built, key:{group_id, vtable_id, not_flag}, value:clause_id.
@@ -491,12 +491,12 @@ On the data plane, services are provided externally through the maat API, primar
* Identify the group_ids in vtable_id table that appear in the NOT_clause and add them to the `NOT_clause_group` set. Ensure that this set does not contain any group_id that was hit during scanning. If any such group_id is present, remove it from the set to form the final `NOT_clause_group` for the vtable_id table.
-* Use the hit clause_ids to determine if there are any hit compile_ids. If there are, populate the half-hit path which will become full-hit path.
+* Use the hit clause_ids to determine if there are any hit rule_ids. If there are, populate the half-hit path which will become full-hit path.
2. **maat_scan_not_logic**: This interface is used to activate NOT-clause logic.
* Traverse the `NOT_clause_group` of `vtable_id`. For each `group_id`, form a key `{group_id, vtable_id, 1}` to obtain the `NOT_clause_id`. If it is in the `exclude clause_ids` set, ignore it; otherwise, add it to the `all hit clause_ids` set as a hit `NOT_clause_id`, and record the half-hit path of the NOT-clause.
-* Use the `all hit clause_ids` to calculate if there are any newly hit compile_ids. If there are, populate the half-hit path of the NOT-clause which will become full-hit path.
+* Use the `all hit clause_ids` to calculate if there are any newly hit rule_ids. If there are, populate the half-hit path of the NOT-clause which will become full-hit path.
3. **xx_get_hit_path**: This interface is used to retrieve the hit path.
\ No newline at end of file
diff --git a/docs/monitor_tools.md b/docs/monitor_tools.md
index d35c92c..f64865a 100644
--- a/docs/monitor_tools.md
+++ b/docs/monitor_tools.md
@@ -28,13 +28,13 @@ The statistical information in the above figure is divided into two parts, part1
- garbage_queue_len: number of elements in the garbage queue
-- hit_compile_num: total number of hits on compile
+- hit_rule_num: total number of hits on rule
- state_num: total number of current maat_state
- per_state_num: number of bytes occupied by each maat_state on average
-- compile_state_num: total number of current compile_state created within maat_state during partial hits or hits
+- rule_state_num: total number of current rule_state created within maat_state during partial hits or hits
- stream_num: total number of scanned streams
diff --git a/docs/overview.md b/docs/overview.md
index 8c5e142..b102b1d 100644
--- a/docs/overview.md
+++ b/docs/overview.md
@@ -7,7 +7,7 @@ Before proceeding, please make sure you are familiar with the [terminology](./te
As mentioned in the readme, maat has two typical usage patterns:
**Pattern 1**
-* Update rules in the item table, group2compile table, and compile table
+* Update rules in the item table, group2rule table, and rule table
* Call the maat scanning api to determine if the actual traffic hits the effective rules
* If a rule is hit, maat can provide detailed information about the hit rule
@@ -20,15 +20,15 @@ As mentioned in the readme, maat has two typical usage patterns:
Different types of configurations are stored in different tables. For all configuration types, please refer to the [table schema](./maat_table.md#1-table-schema).
-The physical tables are mainly divided into three categories: the item table, group compile relationship table (compile table, group2compile table, group2group table), and xx_plugin table. The first two types of tables are used for maat traffic scanning, while the xx_plugin table is used as a callback table, which can obtain the detailed configuration information for a specific key.
+The physical tables are mainly divided into three categories: the item table, group rule relationship table (rule table, group2rule table, group2group table), and xx_plugin table. The first two types of tables are used for maat traffic scanning, while the xx_plugin table is used as a callback table, which can obtain the detailed configuration information for a specific key.
### 1.2 Configuration relationship
-As shown in the diagram below, maat organizes and abstracts configurations using terms such as item, group, literal, clause, compile, etc., allowing users to flexibly configure various policies. The term "literal" is an internal concept in maat and is not visible to external users.
+As shown in the diagram below, maat organizes and abstracts configurations using terms such as item, group, literal, clause, rule, etc., allowing users to flexibly configure various policies. The term "literal" is an internal concept in maat and is not visible to external users.
In addition, groups support nesting. For more detailed information, please refer to [group hierarchy](./group_hierarchy.md).
-If we define literal_id = {virtual_table_id, group_id}, then a literal is composed of one or more literal_ids. The multiple literal_ids that form the same clause have a logical “OR” relationship. The multiple clauses that form the same compile have a logical “AND” relationship, and there can be a maximum of 8 clauses within the same compile. In addition, the clause itself supports logical "NOT".
+If we define literal_id = {virtual_table_id, group_id}, then a literal is composed of one or more literal_ids. The multiple literal_ids that form the same clause have a logical “OR” relationship. The multiple clauses that form the same rule have a logical “AND” relationship, and there can be a maximum of 8 clauses within the same rule. In addition, the clause itself supports logical "NOT".
@@ -56,7 +56,7 @@ The diagram illustrates the overall architecture of maat, including the control
* **Data Plane**
- When calling the maat scanning interface, it subsequently calls the table runtime of the corresponding table, then proceeds to the scanning engine. Upon the scanning engine returning a hit group, it further searches for the matching `compile_id` through group2group runtime, group2compile runtime, and compile runtime, which is then returned to the caller. In addition, if the caller is interested in the hit path, they can also retrieve it through the interfaces provided by maat.
+ When calling the maat scanning interface, it subsequently calls the table runtime of the corresponding table, then proceeds to the scanning engine. Upon the scanning engine returning a hit group, it further searches for the matching `rule_id` through group2group runtime, group2rule runtime, and rule runtime, which is then returned to the caller. In addition, if the caller is interested in the hit path, they can also retrieve it through the interfaces provided by maat.
The scanning mentioned above all uses the `effective runtime`. If there are configuration changes, it will trigger the construction of `updating runtime`. Once this construction is completed, it will become effective runtime, and the original effective runtime will be put into the garbage collection queue waiting to be recycled.
@@ -117,7 +117,7 @@ All of the benchmarks are run on the same TSG-X device. Here are the details of
```bash
scan consume: The time consumption of a single scan, calculated as the average of 1,000,000 scans for each of the 5 threads.
-In scenarios with different numbers of rules, each rule hits only one item → one compile.
+In scenarios with different numbers of rules, each rule hits only one item → one rule.
Configuration capacity:
diff --git a/docs/terminology.md b/docs/terminology.md
index 8144986..6d695fa 100644
--- a/docs/terminology.md
+++ b/docs/terminology.md
@@ -2,7 +2,7 @@
* [Item](#item)
* [Group(Object)](#groupobject)
-* [Compile(Policy)](#compilepolicy)
+* [Rule(Policy)](#rulepolicy)
* [Clause(Condition)](#clause)
* [Literal](#literal)
* [Physical table](#physical-table)
@@ -42,17 +42,17 @@ A group defines a set that can contain different types of items and can also ref
- Group supports multi-level nesting, see [group hierarchy](./overview.md#groupobject-nesting-and-hierarchies)
-- A Group can be referenced by different compiles.
+- A Group can be referenced by different rules.
The relationship between group and group is stored in the [group2group table](./maat_table.md#14-group2group-table).
-## Compile(Policy)
+## Rule(Policy)
A conjunctive normal form(CNF) consisting of multiple groups and virtual tables.
-`Note`: A compile can contain up to 8 clauses and multiple clauses in the same compile can be logical 'AND' and logical 'NOT' relationships.
+`Note`: A rule can contain up to 8 clauses and multiple clauses in the same rule can be logical 'AND' and logical 'NOT' relationships.
-The relationship between group and compile is stored in the [group2compile table](./maat_table.md#13-group2compile-table).
+The relationship between group and rule is stored in the [group2rule table](./maat_table.md#13-group2rule-table).
@@ -68,7 +68,7 @@ A Literal consists of `vtable_id(virtual table id)` and `group_id`. During the r
## Physical table
-Different rules are stored in different tables in the actual database, including [item table](./maat_table.md#11-item-table), [compile table](./maat_table.md#12-compile-table), [group2compile table](./maat_table.md#13-group2compile-table), [group2group table](./maat_table.md#14-group2group-table), and [xx_plugin table](./maat_table.md#15-plugin-table), and so on.
+Different rules are stored in different tables in the actual database, including [item table](./maat_table.md#11-item-table), [rule table](./maat_table.md#12-rule-table), [group2rule table](./maat_table.md#13-group2rule-table), [group2group table](./maat_table.md#14-group2group-table), and [xx_plugin table](./maat_table.md#15-plugin-table), and so on.
## Virtual table
@@ -86,7 +86,7 @@ Defines the type of table and the configuration format, determining the specific
## Table runtime
-The runtime generated by loading the configuration in the table into memory. Different tables have different runtimes. The group2compile table is merged with the corresponding compile table to generate a compile runtime, meaning there is no separate group2compile runtime.
+The runtime generated by loading the configuration in the table into memory. Different tables have different runtimes. The group2rule table is merged with the corresponding rule table to generate a rule runtime, meaning there is no separate group2rule runtime.
Different scanning api use runtimes of different tables. For example, the HTTP_URL table is of type expr, and its corresponding scanning interface is maat_scan_string. Therefore, when calling this scanning interface, the API internally uses the runtime of the HTTP_URL table to perform the actual scanning task.
@@ -112,11 +112,11 @@ Maat supports not only block-based scanning but also stream-based scanning. For
## Half/Full hit
-From the diagram of [configuration relationship](./overview.md#12-configuration-relationship), it can be seen that if the group that is hit is not referenced by compile, or even if referenced by compile, but after logical operations no compile is hit, then this hit is called a half hit; if a compile is hit, then this hit is called a full hit.
+From the diagram of [configuration relationship](./overview.md#12-configuration-relationship), it can be seen that if the group that is hit is not referenced by rule, or even if referenced by rule, but after logical operations no rule is hit, then this hit is called a half hit; if a rule is hit, then this hit is called a full hit.
## Hit path
-From the relationship of item, group, and compile mentioned above, if a scan hits a certain compile, there must be a logical path composed of item_id -> group_id -> compile_id. Maat names this path the hit path. If a group has nested references, the hit path should be item_id -> sub_group_id -> group_id -> compile_id.
+From the relationship of item, group, and rule mentioned above, if a scan hits a certain rule, there must be a logical path composed of item_id -> group_id -> rule_id. Maat names this path the hit path. If a group has nested references, the hit path should be item_id -> sub_group_id -> group_id -> rule_id.
## Redis
diff --git a/include/maat.h b/include/maat.h
index bb9b97f..df1ac6e 100644
--- a/include/maat.h
+++ b/include/maat.h
@@ -35,7 +35,7 @@ struct maat_hit_path {
long long item_id;
long long sub_group_id;
long long top_group_id;
- long long compile_id;
+ long long rule_id;
};
struct maat_hit_group {
@@ -46,9 +46,9 @@ struct maat_hit_group {
enum maat_scan_status {
MAAT_SCAN_ERR = -1, //scan error
- MAAT_SCAN_OK, //scan but not hit(group or compile)
- MAAT_SCAN_HALF_HIT, //half hit: hit group, not hit compile
- MAAT_SCAN_HIT //scan hit compile
+ MAAT_SCAN_OK, //scan but not hit(group or rule)
+ MAAT_SCAN_HALF_HIT, //half hit: hit group, not hit rule
+ MAAT_SCAN_HIT //scan hit rule
};
enum maat_update_type {
@@ -245,9 +245,9 @@ struct maat_state;
* @param instance: maat instance created by maat_new()
* @param table_id: the id of table which to be scanned
* @param thread_id: thread index
- * @param results: array to store hit compile id
+ * @param results: array to store hit rule id
* @param n_result: the array size
- * @param n_hit_result: the number of hit compile id
+ * @param n_hit_result: the number of hit rule id
* @param state: scan mid status
*
* @retval MAAT_SCAN_ERR
@@ -316,13 +316,13 @@ void maat_state_free(struct maat_state *state);
int maat_state_set_scan_district(struct maat_state *state, int table_id,
const char *district, size_t district_len);
-int maat_state_set_scan_compile_table(struct maat_state *state, int compile_table_id);
+int maat_state_set_scan_rule_table(struct maat_state *state, int rule_table_id);
int maat_state_get_hit_paths(struct maat_state *state, struct maat_hit_path *path_array,
size_t array_size);
-int maat_state_get_compile_table_ids(struct maat_state *state, long long *compile_ids,
- size_t n_compile_ids, int *compile_table_ids);
+int maat_state_get_rule_table_ids(struct maat_state *state, long long *rule_ids,
+ size_t n_rule_ids, int *rule_table_ids);
/**
* @brief get the total number of scans after maat_state_new
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fbb0b8d..f2b284d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -13,7 +13,7 @@ add_definitions(-D_GNU_SOURCE)
add_definitions(-fPIC)
set(MAAT_SRC alignment.c json2iris.c maat_api.c rcu_hash.c maat_garbage_collection.c maat_config_monitor.c
maat_core.c maat_kv.c maat_ex_data.c maat_utils.c maat_command.c maat_redis_monitor.c maat_table.c
- maat_compile.c maat_group.c maat_ip.c maat_flag.c maat_interval.c maat_expr.c maat_plugin.c
+ maat_rule.c maat_group.c maat_ip.c maat_flag.c maat_interval.c maat_expr.c maat_plugin.c
maat_ip_plugin.c maat_ipport_plugin.c maat_bool_plugin.c maat_fqdn_plugin.c maat_virtual.c maat_stat.c)
set(LIB_SOURCE_FILES
diff --git a/src/inc_internal/maat_compile.h b/src/inc_internal/maat_compile.h
deleted file mode 100644
index e370eb8..0000000
--- a/src/inc_internal/maat_compile.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
-**********************************************************************************************
-* File: maat_compile.h
-* Description:
-* Authors: Liu wentan
-* Date: 2022-10-31
-* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved.
-***********************************************************************************************
-*/
-
-#ifndef _MAAT_COMPILE_H_
-#define _MAAT_COMPILE_H_
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "cJSON/cJSON.h"
-#include "rcu_hash.h"
-#include "maat.h"
-#include "maat_kv.h"
-#include "maat_core.h"
-
-struct compile_schema;
-struct compile_runtime;
-struct compile_state;
-struct group2group_runtime;
-
-/* compile schema API */
-void *compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
- const char *table_name, struct log_handle *logger);
-void compile_schema_free(void *compile_schema);
-
-void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
- const char *table_name, struct log_handle *logger);
-void group2compile_schema_free(void *g2c_schema);
-int group2compile_associated_compile_table_id(void *g2c_schema);
-
-/* compile runtime API */
-void *compile_runtime_new(void *compile_schema, size_t max_thread_num,
- struct maat_garbage_bin *garbage_bin,
- struct log_handle *logger);
-void compile_runtime_free(void *compile_runtime);
-
-void compile_runtime_init(void *compile_runtime, struct maat_runtime *maat_rt);
-
-int compile_runtime_update(void *compile_runtime, void *compile_schema,
- const char *table_name, const char *line,
- int valid_column);
-
-int compile_runtime_commit(void *compile_runtime, const char *table_name,
- long long maat_rt_version);
-
-long long compile_runtime_rule_count(void *compile_runtime);
-
-long long compile_runtime_update_err_count(void *compile_runtime);
-
-int compile_runtime_match(struct compile_runtime *compile_rt, long long *compile_ids,
- size_t compile_ids_size, struct maat_state *state);
-
-size_t compile_runtime_get_hit_paths(struct compile_runtime *compile_rt, int thread_id,
- struct compile_state *compile_state,
- struct maat_hit_path *hit_path_array,
- size_t array_size, size_t n_hit_path);
-
-/* group2compile runtime API */
-void *group2compile_runtime_new(void *g2c_schema, size_t max_thread_num,
- struct maat_garbage_bin *garbage_bin,
- struct log_handle *logger);
-
-void group2compile_runtime_init(void *g2c_runtime, void *compile_runtime);
-
-void group2compile_runtime_free(void *g2c_runtime);
-
-int group2compile_runtime_update(void *g2c_runtime, void *g2c_schema,
- const char *table_name, const char *line,
- int valid_column);
-
-long long group2compile_runtime_not_clause_count(void *g2c_runtime);
-
-long long group2compile_runtime_rule_count(void *g2c_runtime);
-
-long long group2compile_runtime_update_err_count(void *g2c_runtime);
-
-/* maat compile state API */
-struct compile_state;
-struct compile_state *compile_state_new(void);
-
-void compile_state_reset(struct compile_state *compile_state);
-
-void compile_state_free(struct compile_state *compile_state,
- struct maat *maat_instance, int thread_id);
-
-int compile_state_update(struct compile_state *compile_state, struct maat *maat_inst,
- int vtable_id, int custom_compile_tbl_id, int Nth_scan,
- struct maat_item *hit_items, size_t n_hit_item);
-
-void compile_state_clear_last_hit_group(struct compile_state *compile_state);
-
-void compile_state_not_logic_update(struct compile_state *compile_state,
- struct compile_runtime *compile_rt,
- struct maat *maat_inst, int vtable_id,
- int Nth_scan);
-
-size_t compile_state_get_internal_hit_paths(struct compile_state *compile_state,
- struct compile_runtime *compile_rt,
- struct group2group_runtime *g2g_rt,
- struct maat_hit_path *hit_path_array,
- size_t array_size);
-
-size_t compile_state_get_direct_hit_groups(struct compile_state *compile_state,
- struct maat_hit_group *group_array,
- size_t array_size);
-
-size_t compile_state_get_direct_hit_group_cnt(struct compile_state *compile_state);
-
-size_t compile_state_get_indirect_hit_groups(struct compile_state *compile_state,
- struct maat_hit_group *group_array,
- size_t array_size);
-
-size_t compile_state_get_indirect_hit_group_cnt(struct compile_state *compile_state);
-
-size_t compile_state_get_last_hit_groups(struct compile_state *compile_state,
- struct maat_hit_group *group_arary,
- size_t array_size);
-
-size_t compile_state_get_last_hit_group_cnt(struct compile_state *compile_state);
-
-int compile_state_get_compile_table_id(struct compile_state *compile_state,
- long long compile_id);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
\ No newline at end of file
diff --git a/src/inc_internal/maat_core.h b/src/inc_internal/maat_core.h
index bdd42f7..93859d4 100644
--- a/src/inc_internal/maat_core.h
+++ b/src/inc_internal/maat_core.h
@@ -8,8 +8,8 @@
***********************************************************************************************
*/
-#ifndef _MAAT_RULE_H_
-#define _MAAT_RULE_H_
+#ifndef _MAAT_CORE_H_
+#define _MAAT_CORE_H_
#ifdef __cplusplus
extern "C"
@@ -153,9 +153,9 @@ struct maat_stat {
long long *thread_call_cnt;
long long *stream_cnt;
- long long *hit_compile_cnt;
+ long long *hit_rule_cnt;
long long *maat_state_cnt;
- long long *compile_state_cnt;
+ long long *rule_state_cnt;
long long *maat_state_free_cnt;
long long *maat_state_free_bytes;
@@ -189,11 +189,11 @@ struct maat {
struct maat_state {
struct maat *maat_inst;
- struct compile_state *compile_state;
+ struct rule_state *rule_state;
int Nth_scan;
int district_id; //-1: Any District; -2: Unkonwn District;
uint16_t thread_id;
- int16_t compile_table_id;
+ int16_t rule_table_id;
uint8_t district_flag;
uint8_t logic_not_flag;
};
diff --git a/src/inc_internal/maat_rule.h b/src/inc_internal/maat_rule.h
new file mode 100644
index 0000000..40c4a0f
--- /dev/null
+++ b/src/inc_internal/maat_rule.h
@@ -0,0 +1,137 @@
+/*
+**********************************************************************************************
+* File: maat_rule.h
+* Description:
+* Authors: Liu wentan
+* Date: 2022-10-31
+* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved.
+***********************************************************************************************
+*/
+
+#ifndef _MAAT_RULE_H_
+#define _MAAT_RULE_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "cJSON/cJSON.h"
+#include "rcu_hash.h"
+#include "maat.h"
+#include "maat_kv.h"
+#include "maat_core.h"
+
+struct rule_schema;
+struct rule_runtime;
+struct rule_state;
+struct group2group_runtime;
+
+/* rule schema API */
+void *rule_schema_new(cJSON *json, struct table_manager *tbl_mgr,
+ const char *table_name, struct log_handle *logger);
+void rule_schema_free(void *rule_schema);
+
+void *group2rule_schema_new(cJSON *json, struct table_manager *tbl_mgr,
+ const char *table_name, struct log_handle *logger);
+void group2rule_schema_free(void *g2c_schema);
+int group2rule_associated_rule_table_id(void *g2c_schema);
+
+/* rule runtime API */
+void *rule_runtime_new(void *rule_schema, size_t max_thread_num,
+ struct maat_garbage_bin *garbage_bin,
+ struct log_handle *logger);
+void rule_runtime_free(void *rule_runtime);
+
+void rule_runtime_init(void *rule_runtime, struct maat_runtime *maat_rt);
+
+int rule_runtime_update(void *rule_runtime, void *rule_schema,
+ const char *table_name, const char *line,
+ int valid_column);
+
+int rule_runtime_commit(void *rule_runtime, const char *table_name,
+ long long maat_rt_version);
+
+long long rule_runtime_rule_count(void *rule_runtime);
+
+long long rule_runtime_update_err_count(void *rule_runtime);
+
+int rule_runtime_match(struct rule_runtime *rule_rt, long long *rule_ids,
+ size_t rule_ids_size, struct maat_state *state);
+
+size_t rule_runtime_get_hit_paths(struct rule_runtime *rule_rt, int thread_id,
+ struct rule_state *rule_state,
+ struct maat_hit_path *hit_path_array,
+ size_t array_size, size_t n_hit_path);
+
+/* group2rule runtime API */
+void *group2rule_runtime_new(void *g2c_schema, size_t max_thread_num,
+ struct maat_garbage_bin *garbage_bin,
+ struct log_handle *logger);
+
+void group2rule_runtime_init(void *g2c_runtime, void *rule_runtime);
+
+void group2rule_runtime_free(void *g2c_runtime);
+
+int group2rule_runtime_update(void *g2c_runtime, void *g2c_schema,
+ const char *table_name, const char *line,
+ int valid_column);
+
+long long group2rule_runtime_not_clause_count(void *g2c_runtime);
+
+long long group2rule_runtime_rule_count(void *g2c_runtime);
+
+long long group2rule_runtime_update_err_count(void *g2c_runtime);
+
+/* maat rule state API */
+struct rule_state;
+struct rule_state *rule_state_new(void);
+
+void rule_state_reset(struct rule_state *rule_state);
+
+void rule_state_free(struct rule_state *rule_state,
+ struct maat *maat_instance, int thread_id);
+
+int rule_state_update(struct rule_state *rule_state, struct maat *maat_inst,
+ int vtable_id, int custom_rule_tbl_id, int Nth_scan,
+ struct maat_item *hit_items, size_t n_hit_item);
+
+void rule_state_clear_last_hit_group(struct rule_state *rule_state);
+
+void rule_state_not_logic_update(struct rule_state *rule_state,
+ struct rule_runtime *rule_rt,
+ struct maat *maat_inst, int vtable_id,
+ int Nth_scan);
+
+size_t rule_state_get_internal_hit_paths(struct rule_state *rule_state,
+ struct rule_runtime *rule_rt,
+ struct group2group_runtime *g2g_rt,
+ struct maat_hit_path *hit_path_array,
+ size_t array_size);
+
+size_t rule_state_get_direct_hit_groups(struct rule_state *rule_state,
+ struct maat_hit_group *group_array,
+ size_t array_size);
+
+size_t rule_state_get_direct_hit_group_cnt(struct rule_state *rule_state);
+
+size_t rule_state_get_indirect_hit_groups(struct rule_state *rule_state,
+ struct maat_hit_group *group_array,
+ size_t array_size);
+
+size_t rule_state_get_indirect_hit_group_cnt(struct rule_state *rule_state);
+
+size_t rule_state_get_last_hit_groups(struct rule_state *rule_state,
+ struct maat_hit_group *group_arary,
+ size_t array_size);
+
+size_t rule_state_get_last_hit_group_cnt(struct rule_state *rule_state);
+
+int rule_state_get_rule_table_id(struct rule_state *rule_state,
+ long long rule_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/src/inc_internal/maat_table.h b/src/inc_internal/maat_table.h
index 42e7ed8..ddc6587 100644
--- a/src/inc_internal/maat_table.h
+++ b/src/inc_internal/maat_table.h
@@ -39,9 +39,9 @@ enum table_type {
TABLE_TYPE_BOOL_PLUGIN,
//above are physical table
TABLE_TYPE_VIRTUAL,
- TABLE_TYPE_COMPILE,
+ TABLE_TYPE_RULE,
TABLE_TYPE_GROUP2GROUP,
- TABLE_TYPE_GROUP2COMPILE,
+ TABLE_TYPE_GROUP2RULE,
TABLE_TYPE_MAX
};
@@ -65,14 +65,14 @@ int table_manager_get_table_id(struct table_manager *tbl_mgr, const char *table_
* @brief get table_name's all conjunction parents' table_id
*
* for example: "table_id": 1,
- * "table_name":"COMPILE_CONJ"
- * "db_tables":["COMPILE_DEFAULT", "COMPILE_ALIAS"]
+ * "table_name":"RULE_CONJ"
+ * "db_tables":["RULE_DEFAULT", "RULE_ALIAS"]
*
* "table_id": 2,
- * "table_name": "COMPILE_PLUGIN",
- * "db_tables": ["COMPILE_DEFAULT"]
+ * "table_name": "RULE_PLUGIN",
+ * "db_tables": ["RULE_DEFAULT"]
*
- * so COMPILE_DEFAULT has two conjunction parents whose table_id is 1 and 2.
+ * so RULE_DEFAULT has two conjunction parents whose table_id is 1 and 2.
*/
int table_manager_get_conj_parent_table_ids(struct table_manager *tbl_mgr, const char *table_name,
long long *table_ids_array, size_t n_table_ids_array);
@@ -84,7 +84,7 @@ const char *table_manager_get_table_schema_tag(struct table_manager *tbl_mgr, in
enum table_type table_manager_get_table_type(struct table_manager *tbl_mgr, int table_id);
-int table_manager_get_default_compile_table_id(struct table_manager *tbl_mgr);
+int table_manager_get_default_rule_table_id(struct table_manager *tbl_mgr);
int table_manager_get_group2group_table_id(struct table_manager *tbl_mgr);
int table_manager_get_valid_column(struct table_manager *tbl_mgr, int table_id);
diff --git a/src/inc_internal/maat_utils.h b/src/inc_internal/maat_utils.h
index aaa3227..915861f 100644
--- a/src/inc_internal/maat_utils.h
+++ b/src/inc_internal/maat_utils.h
@@ -55,7 +55,7 @@ extern "C"
#endif
#define MAX_HIT_PATH_NUM 4096
-#define MAX_HIT_COMPILE_NUM 4096
+#define MAX_HIT_RULE_NUM 4096
#define MAX_HIT_GROUP_NUM 4096
#define MAX_HIT_ITEM_NUM 4096
diff --git a/src/json2iris.c b/src/json2iris.c
index d52b123..3ed2fb1 100644
--- a/src/json2iris.c
+++ b/src/json2iris.c
@@ -35,7 +35,7 @@ const char *untitled_group_name = "Untitled";
long long untitled_group_id = 123456789;
enum maat_group_relation {
- PARENT_TYPE_COMPILE = 0,
+ PARENT_TYPE_RULE = 0,
PARENT_TYPE_GROUP
};
@@ -68,8 +68,8 @@ struct iris_description {
struct iris_table *group_table;
struct iris_table *group2group_table;
- struct iris_table *group2compile_table;
- struct iris_table *compile_table;
+ struct iris_table *group2rule_table;
+ struct iris_table *rule_table;
struct group_info *group_name_map;
struct iris_table *iris_table_map;
@@ -130,7 +130,7 @@ static void free_iris_table_info(void *p)
static int
set_iris_descriptor(const char *json_file, cJSON *json,
const char *encrypt_key, const char *encrypt_algo,
- const char *compile_tn, const char *group2compile_tn,
+ const char *rule_tn, const char *group2rule_tn,
const char* group2group_tn, redisContext *redis_write_ctx,
struct iris_description *iris_cfg)
{
@@ -181,10 +181,10 @@ set_iris_descriptor(const char *json_file, cJSON *json,
maat_kv_register(iris_cfg->str2int_map, "hexbin", 1);
maat_kv_register(iris_cfg->str2int_map, "case plain", 2);
- iris_cfg->compile_table = query_table_info(iris_cfg, compile_tn,
- TABLE_TYPE_COMPILE);
- iris_cfg->group2compile_table = query_table_info(iris_cfg, group2compile_tn,
- TABLE_TYPE_GROUP2COMPILE);
+ iris_cfg->rule_table = query_table_info(iris_cfg, rule_tn,
+ TABLE_TYPE_RULE);
+ iris_cfg->group2rule_table = query_table_info(iris_cfg, group2rule_tn,
+ TABLE_TYPE_GROUP2RULE);
iris_cfg->group2group_table = query_table_info(iris_cfg, group2group_tn,
TABLE_TYPE_GROUP2GROUP);
@@ -571,14 +571,14 @@ write_interval_line(cJSON *region_json, struct iris_description *p_iris,
}
static int
-write_region_rule(cJSON *region_json, int compile_id, int group_id,
+write_region_rule(cJSON *region_json, int rule_id, int group_id,
struct iris_description *p_iris, struct log_handle *logger)
{
cJSON *item = cJSON_GetObjectItem(region_json, "table_name");
if (NULL == item || item->type != cJSON_String) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] compile rule %d's table_name not defined "
- "or format error", __FUNCTION__, __LINE__, compile_id);
+ "[%s:%d] rule rule %d's table_name not defined "
+ "or format error", __FUNCTION__, __LINE__, rule_id);
return -1;
}
const char *table_name = item->valuestring;
@@ -586,9 +586,9 @@ write_region_rule(cJSON *region_json, int compile_id, int group_id,
item = cJSON_GetObjectItem(region_json, "table_type");
if (NULL == item || item->type != cJSON_String) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] compile rule %d's table name %s's table_type "
+ "[%s:%d] rule rule %d's table name %s's table_type "
"not defined or format error", __FUNCTION__, __LINE__,
- compile_id, table_name);
+ rule_id, table_name);
return -1;
}
@@ -597,17 +597,17 @@ write_region_rule(cJSON *region_json, int compile_id, int group_id,
int ret = maat_kv_read(p_iris->str2int_map, table_type_str, &table_type_int, 1);
if (ret != 1) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] compile rule %d table name %s's table_type %s invalid",
- __FUNCTION__, __LINE__, compile_id, table_name, table_type_str);
+ "[%s:%d] rule rule %d table name %s's table_type %s invalid",
+ __FUNCTION__, __LINE__, rule_id, table_name, table_type_str);
return -1;
}
cJSON *table_content = cJSON_GetObjectItem(region_json, "table_content");
if (NULL == table_content || table_content->type != cJSON_Object) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] compile rule %d table name %s's table_content "
+ "[%s:%d] rule rule %d table name %s's table_content "
"not defined or format error", __FUNCTION__, __LINE__,
- compile_id, table_name);
+ rule_id, table_name);
return -1;
}
@@ -642,8 +642,8 @@ write_region_rule(cJSON *region_json, int compile_id, int group_id,
}
static int
-write_group2compile_line(int *group_ids, size_t n_group_id,
- int compile_id, int group_not_flag,
+write_group2rule_line(int *group_ids, size_t n_group_id,
+ int rule_id, int group_not_flag,
int clause_index, const char *vtable,
struct iris_description *p_iris,
struct iris_table *g2c_table)
@@ -654,10 +654,10 @@ write_group2compile_line(int *group_ids, size_t n_group_id,
if (g2c_table != NULL) {
table = g2c_table;
} else {
- if (NULL == p_iris->group2compile_table) {
+ if (NULL == p_iris->group2rule_table) {
return -1;
}
- table = p_iris->group2compile_table;
+ table = p_iris->group2rule_table;
}
if (n_group_id > 1) {
@@ -670,10 +670,10 @@ write_group2compile_line(int *group_ids, size_t n_group_id,
}
group_id_str[strlen(group_id_str) - 1] = '\0';
snprintf(buff, sizeof(buff), "%s\t%d\t%d\t%s\t%d\t1\n", group_id_str,
- compile_id, group_not_flag, vtable, clause_index);
+ rule_id, group_not_flag, vtable, clause_index);
} else {
snprintf(buff, sizeof(buff), "%d\t%d\t%d\t%s\t%d\t1\n", group_ids[0],
- compile_id, group_not_flag, vtable, clause_index);
+ rule_id, group_not_flag, vtable, clause_index);
}
table->write_pos += memcat(&(table->buff), table->write_pos,
@@ -748,7 +748,7 @@ write_group2group_line(int group_id, UT_array *incl_sub_group_ids,
static int
write_group_rule(cJSON *group_json, int parent_id,
- int parent_type, int tracking_compile_id,
+ int parent_type, int tracking_rule_id,
int Nth_group, struct iris_description *p_iris,
struct log_handle *logger)
{
@@ -774,7 +774,7 @@ write_group_rule(cJSON *group_json, int parent_id,
cJSON *tmp_json = cJSON_GetArrayItem(item, i);
if (NULL == tmp_json || tmp_json->type != cJSON_String) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] group_name of compile:%d format error",
+ "[%s:%d] group_name of rule:%d format error",
__FUNCTION__, __LINE__, parent_id);
return -1;
}
@@ -789,7 +789,7 @@ write_group_rule(cJSON *group_json, int parent_id,
group_id = item->valueint;
}
- if (parent_type == PARENT_TYPE_COMPILE) {
+ if (parent_type == PARENT_TYPE_RULE) {
item = cJSON_GetObjectItem(group_json, "virtual_table");
if (NULL == item || item->type != cJSON_String) {
virtual_table = "null";
@@ -814,7 +814,7 @@ write_group_rule(cJSON *group_json, int parent_id,
item = cJSON_GetObjectItem(group_json, "g2c_table_name");
if (item != NULL && item->type == cJSON_String) {
g2c_table = query_table_info(p_iris, item->valuestring,
- TABLE_TYPE_GROUP2COMPILE);
+ TABLE_TYPE_GROUP2RULE);
}
}
@@ -831,8 +831,8 @@ write_group_rule(cJSON *group_json, int parent_id,
}
group_ids[i] = group_info->group_id;
}
- assert(parent_type == PARENT_TYPE_COMPILE);
- ret = write_group2compile_line(group_ids, group_name_cnt, parent_id,
+ assert(parent_type == PARENT_TYPE_RULE);
+ ret = write_group2rule_line(group_ids, group_name_cnt, parent_id,
group_not_flag, clause_index,
virtual_table, p_iris, g2c_table);
@@ -858,12 +858,12 @@ write_group_rule(cJSON *group_json, int parent_id,
if (region_json != NULL) {
cJSON *region_rule = NULL;
cJSON_ArrayForEach(region_rule, region_json) {
- ret = write_region_rule(region_rule, tracking_compile_id,
+ ret = write_region_rule(region_rule, tracking_rule_id,
group_info->group_id, p_iris, logger);
if (ret < 0) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] compile rule %d write region error",
- __FUNCTION__, __LINE__, tracking_compile_id);
+ "[%s:%d] rule rule %d write region error",
+ __FUNCTION__, __LINE__, tracking_rule_id);
return -1;
}
}
@@ -876,7 +876,7 @@ write_group_rule(cJSON *group_json, int parent_id,
cJSON_ArrayForEach(item, sub_groups) {
i++;
ret = write_group_rule(item, group_info->group_id,
- PARENT_TYPE_GROUP, tracking_compile_id,
+ PARENT_TYPE_GROUP, tracking_rule_id,
i, p_iris, logger);
if (ret < 0) {
return -1;
@@ -886,19 +886,19 @@ write_group_rule(cJSON *group_json, int parent_id,
if (NULL == region_json && NULL == sub_groups) {
log_info(logger, MODULE_JSON2IRIS,
- "[%s:%d] A group of compile rule %d has neither regions, "
+ "[%s:%d] A group of rule rule %d has neither regions, "
"sub groups, nor refered another existed group",
- __FUNCTION__, __LINE__, tracking_compile_id);
+ __FUNCTION__, __LINE__, tracking_rule_id);
}
}
- if (parent_type == PARENT_TYPE_COMPILE) {
- ret = write_group2compile_line(&(group_info->group_id), 1, parent_id,
+ if (parent_type == PARENT_TYPE_RULE) {
+ ret = write_group2rule_line(&(group_info->group_id), 1, parent_id,
group_not_flag, clause_index,
virtual_table, p_iris, g2c_table);
if (ret < 0) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] compile:%d write group error",
+ "[%s:%d] rule:%d write group error",
__FUNCTION__, __LINE__, parent_id);
return -1;
}
@@ -909,19 +909,19 @@ write_group_rule(cJSON *group_json, int parent_id,
}
static int
-write_compile_line(cJSON *compile, struct iris_description *p_iris,
+write_rule_line(cJSON *rule, struct iris_description *p_iris,
struct log_handle *logger)
{
- cJSON *item=cJSON_GetObjectItem(compile, "compile_id");
+ cJSON *item=cJSON_GetObjectItem(rule, "rule_id");
if (item->type != cJSON_Number) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] compile_id format not number",
+ "[%s:%d] rule_id format not number",
__FUNCTION__, __LINE__);
return -1;
}
- int compile_id = item->valueint;
+ int rule_id = item->valueint;
- cJSON *group_array = cJSON_GetObjectItem(compile, "groups");
+ cJSON *group_array = cJSON_GetObjectItem(rule, "groups");
int group_num = cJSON_GetArraySize(group_array);
int *clause_ids = ALLOC(int, group_num);
int clause_num = 0;
@@ -950,80 +950,80 @@ write_compile_line(cJSON *compile, struct iris_description *p_iris,
clause_num = group_num;
}
- cJSON_AddNumberToObject(compile, "clause_num", clause_num);
+ cJSON_AddNumberToObject(rule, "clause_num", clause_num);
- struct translate_command compile_cmd[MAX_COLUMN_NUM];
- memset(compile_cmd, 0, sizeof(compile_cmd));
+ struct translate_command rule_cmd[MAX_COLUMN_NUM];
+ memset(rule_cmd, 0, sizeof(rule_cmd));
int cmd_cnt = 0;
- compile_cmd[cmd_cnt].json_string = "compile_id";
- compile_cmd[cmd_cnt].json_type = cJSON_Number;
+ rule_cmd[cmd_cnt].json_string = "rule_id";
+ rule_cmd[cmd_cnt].json_type = cJSON_Number;
cmd_cnt++;
- compile_cmd[cmd_cnt].json_string = "service";
- compile_cmd[cmd_cnt].json_type = cJSON_Number;
+ rule_cmd[cmd_cnt].json_string = "service";
+ rule_cmd[cmd_cnt].json_type = cJSON_Number;
cmd_cnt++;
- compile_cmd[cmd_cnt].json_string = "action";
- compile_cmd[cmd_cnt].json_type = cJSON_Number;
+ rule_cmd[cmd_cnt].json_string = "action";
+ rule_cmd[cmd_cnt].json_type = cJSON_Number;
cmd_cnt++;
- compile_cmd[cmd_cnt].json_string = "do_blacklist";
- compile_cmd[cmd_cnt].json_type = cJSON_Number;
+ rule_cmd[cmd_cnt].json_string = "do_blacklist";
+ rule_cmd[cmd_cnt].json_type = cJSON_Number;
cmd_cnt++;
- compile_cmd[cmd_cnt].json_string = "do_log";
- compile_cmd[cmd_cnt].json_type = cJSON_Number;
+ rule_cmd[cmd_cnt].json_string = "do_log";
+ rule_cmd[cmd_cnt].json_type = cJSON_Number;
cmd_cnt++;
- compile_cmd[cmd_cnt].json_string = "tags";
- compile_cmd[cmd_cnt].json_type = cJSON_String;
- compile_cmd[cmd_cnt].empty_allowed = 1;
- compile_cmd[cmd_cnt].default_string = "{}";
+ rule_cmd[cmd_cnt].json_string = "tags";
+ rule_cmd[cmd_cnt].json_type = cJSON_String;
+ rule_cmd[cmd_cnt].empty_allowed = 1;
+ rule_cmd[cmd_cnt].default_string = "{}";
cmd_cnt++;
- compile_cmd[cmd_cnt].json_string = "user_region";
- compile_cmd[cmd_cnt].json_type = cJSON_String;
+ rule_cmd[cmd_cnt].json_string = "user_region";
+ rule_cmd[cmd_cnt].json_type = cJSON_String;
cmd_cnt++;
- compile_cmd[cmd_cnt].json_string = "clause_num";
- compile_cmd[cmd_cnt].json_type = cJSON_Number;
+ rule_cmd[cmd_cnt].json_string = "clause_num";
+ rule_cmd[cmd_cnt].json_type = cJSON_Number;
cmd_cnt++;
- compile_cmd[cmd_cnt].json_string = "is_valid";
- compile_cmd[cmd_cnt].json_type = cJSON_String;
- compile_cmd[cmd_cnt].str2int_flag = 1;
+ rule_cmd[cmd_cnt].json_string = "is_valid";
+ rule_cmd[cmd_cnt].json_type = cJSON_String;
+ rule_cmd[cmd_cnt].str2int_flag = 1;
cmd_cnt++;
- compile_cmd[cmd_cnt].json_string = "modified_time";
- compile_cmd[cmd_cnt].json_type = cJSON_String;
- compile_cmd[cmd_cnt].empty_allowed = 1;
+ rule_cmd[cmd_cnt].json_string = "modified_time";
+ rule_cmd[cmd_cnt].json_type = cJSON_String;
+ rule_cmd[cmd_cnt].empty_allowed = 1;
time_t curr_time;
time(&curr_time);
static char temp[21];
snprintf(temp, 21, "%ld", curr_time);
- compile_cmd[cmd_cnt].default_string = temp;
+ rule_cmd[cmd_cnt].default_string = temp;
cmd_cnt++;
struct iris_table *table_info = NULL;
- item = cJSON_GetObjectItem(compile,"compile_table_name");
+ item = cJSON_GetObjectItem(rule,"rule_table_name");
if (NULL == item || item->type != cJSON_String) {
- if (NULL == p_iris->compile_table) {
+ if (NULL == p_iris->rule_table) {
return -1;
}
- table_info = p_iris->compile_table;
+ table_info = p_iris->rule_table;
} else {
- table_info = query_table_info(p_iris, item->valuestring, TABLE_TYPE_COMPILE);
+ table_info = query_table_info(p_iris, item->valuestring, TABLE_TYPE_RULE);
}
- int ret = direct_write_rule(compile, p_iris->str2int_map, compile_cmd,
+ int ret = direct_write_rule(rule, p_iris->str2int_map, rule_cmd,
cmd_cnt, table_info, logger);
if (ret < 0) {
return -1;
}
- return compile_id;
+ return rule_id;
}
static void write_table_idx(struct iris_description *p_iris,
@@ -1228,44 +1228,44 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
}
}
- int compile_cnt = 0;
- cJSON *compile_array = cJSON_GetObjectItem(json, "rules");
- if (compile_array != NULL) {
- compile_cnt = cJSON_GetArraySize(compile_array);
+ int rule_cnt = 0;
+ cJSON *rule_array = cJSON_GetObjectItem(json, "rules");
+ if (rule_array != NULL) {
+ rule_cnt = cJSON_GetArraySize(rule_array);
}
- if (compile_cnt > 0) {
- cJSON *compile_obj = NULL;
- cJSON_ArrayForEach(compile_obj, compile_array) {
- int compile_id = write_compile_line(compile_obj, p_iris, logger);
- if (compile_id < 0) {
+ if (rule_cnt > 0) {
+ cJSON *rule_obj = NULL;
+ cJSON_ArrayForEach(rule_obj, rule_array) {
+ int rule_id = write_rule_line(rule_obj, p_iris, logger);
+ if (rule_id < 0) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] In %d compile rule",
+ "[%s:%d] In %d rule rule",
__FUNCTION__, __LINE__, i);
return -1;
}
- group_array = cJSON_GetObjectItem(compile_obj, "groups");
+ group_array = cJSON_GetObjectItem(rule_obj, "groups");
if (NULL == group_array) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] compile rule %d have no group",
- __FUNCTION__, __LINE__, compile_id);
+ "[%s:%d] rule rule %d have no group",
+ __FUNCTION__, __LINE__, rule_id);
return -1;
}
int group_cnt = cJSON_GetArraySize(group_array);
if (group_cnt <= 0) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] compile rule %d have no groups",
- __FUNCTION__, __LINE__, compile_id);
+ "[%s:%d] rule rule %d have no groups",
+ __FUNCTION__, __LINE__, rule_id);
return -1;
}
i = 0;
cJSON *group_obj = NULL;
cJSON_ArrayForEach(group_obj, group_array) {
- ret = write_group_rule(group_obj, compile_id, PARENT_TYPE_COMPILE,
- compile_id, i, p_iris, logger);
+ ret = write_group_rule(group_obj, rule_id, PARENT_TYPE_RULE,
+ rule_id, i, p_iris, logger);
if (ret < 0) {
return -1;
}
@@ -1273,8 +1273,8 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
}
}
- cJSON_ArrayForEach(compile_obj, compile_array) {
- cJSON *group_array = cJSON_GetObjectItem(compile_obj, "groups");
+ cJSON_ArrayForEach(rule_obj, rule_array) {
+ cJSON *group_array = cJSON_GetObjectItem(rule_obj, "groups");
cJSON *group_obj = NULL;
cJSON_ArrayForEach(group_obj, group_array) {
@@ -1306,8 +1306,8 @@ int json2iris(const char *json_buff, const char *json_filename,
{
int ret = -1;
cJSON *tmp_obj = NULL;
- const char *compile_tbl_name = NULL;
- const char *group2compile_tbl_name = NULL;
+ const char *rule_tbl_name = NULL;
+ const char *group2rule_tbl_name = NULL;
const char *group2group_tbl_name = NULL;
struct iris_description iris_cfg;
@@ -1321,14 +1321,14 @@ int json2iris(const char *json_buff, const char *json_filename,
goto error_out;
}
- tmp_obj = cJSON_GetObjectItem(json, "compile_table");
+ tmp_obj = cJSON_GetObjectItem(json, "rule_table");
if (tmp_obj) {
- compile_tbl_name = tmp_obj->valuestring;
+ rule_tbl_name = tmp_obj->valuestring;
}
- tmp_obj = cJSON_GetObjectItem(json, "group2compile_table");
+ tmp_obj = cJSON_GetObjectItem(json, "group2rule_table");
if (tmp_obj) {
- group2compile_tbl_name = tmp_obj->valuestring;
+ group2rule_tbl_name = tmp_obj->valuestring;
}
tmp_obj = cJSON_GetObjectItem(json, "group2group_table");
@@ -1337,7 +1337,7 @@ int json2iris(const char *json_buff, const char *json_filename,
}
ret = set_iris_descriptor(json_filename, json, encrypt_key, encrypt_algo,
- compile_tbl_name, group2compile_tbl_name,
+ rule_tbl_name, group2rule_tbl_name,
group2group_tbl_name, redis_write_ctx, &iris_cfg);
if (ret < 0) {
goto error_out;
diff --git a/src/maat_api.c b/src/maat_api.c
index 7131359..5e3f88c 100644
--- a/src/maat_api.c
+++ b/src/maat_api.c
@@ -24,7 +24,7 @@
#include "maat_table.h"
#include "maat_config_monitor.h"
#include "maat_redis_monitor.h"
-#include "maat_compile.h"
+#include "maat_rule.h"
#include "alignment.h"
#include "ip_matcher.h"
#include "adapter_hs.h"
@@ -1300,23 +1300,23 @@ string_scan(struct table_manager *tbl_mgr, int thread_id,
}
static size_t
-group_to_compile(struct maat *maat_inst, long long *results, size_t n_result,
+group_to_rule(struct maat *maat_inst, long long *results, size_t n_result,
struct maat_state *state)
{
- int compile_table_id =
- table_manager_get_default_compile_table_id(maat_inst->tbl_mgr);
+ int rule_table_id =
+ table_manager_get_default_rule_table_id(maat_inst->tbl_mgr);
- if (state->compile_table_id > 0) {
- compile_table_id = state->compile_table_id;
+ if (state->rule_table_id > 0) {
+ rule_table_id = state->rule_table_id;
}
- void *compile_rt = table_manager_get_runtime(maat_inst->tbl_mgr,
- compile_table_id);
- if (NULL == compile_rt) {
+ void *rule_rt = table_manager_get_runtime(maat_inst->tbl_mgr,
+ rule_table_id);
+ if (NULL == rule_rt) {
return 0;
}
- return compile_runtime_match((struct compile_runtime *)compile_rt,
+ return rule_runtime_match((struct rule_runtime *)rule_rt,
results, n_result, state);
}
@@ -1372,15 +1372,15 @@ int maat_scan_flag(struct maat *maat_inst, int table_id,
maat_runtime_ref_inc(maat_rt, state->thread_id);
- size_t sum_hit_compile_cnt = 0;
+ size_t sum_hit_rule_cnt = 0;
if (hit_group_cnt > 0) {
- sum_hit_compile_cnt = group_to_compile(maat_inst, results, n_result, state);
- *n_hit_result = sum_hit_compile_cnt;
+ sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ *n_hit_result = sum_hit_rule_cnt;
}
- if (sum_hit_compile_cnt > 0) {
- alignment_int64_array_add(maat_inst->stat->hit_compile_cnt, state->thread_id,
- sum_hit_compile_cnt);
+ if (sum_hit_rule_cnt > 0) {
+ alignment_int64_array_add(maat_inst->stat->hit_rule_cnt, state->thread_id,
+ sum_hit_rule_cnt);
}
void *flag_rt = table_manager_get_runtime(maat_inst->tbl_mgr, phy_table_id);
@@ -1395,7 +1395,7 @@ int maat_scan_flag(struct maat *maat_inst, int table_id,
maat_runtime_ref_dec(maat_rt, state->thread_id);
- if (sum_hit_compile_cnt > 0) {
+ if (sum_hit_rule_cnt > 0) {
return MAAT_SCAN_HIT;
} else if (hit_group_cnt > 0) {
return MAAT_SCAN_HALF_HIT;
@@ -1457,15 +1457,15 @@ int maat_scan_integer(struct maat *maat_inst, int table_id,
maat_runtime_ref_inc(maat_rt, state->thread_id);
- size_t sum_hit_compile_cnt = 0;
+ size_t sum_hit_rule_cnt = 0;
if (hit_group_cnt > 0) {
- sum_hit_compile_cnt = group_to_compile(maat_inst, results, n_result, state);
- *n_hit_result = sum_hit_compile_cnt;
+ sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ *n_hit_result = sum_hit_rule_cnt;
}
- if (sum_hit_compile_cnt > 0) {
- alignment_int64_array_add(maat_inst->stat->hit_compile_cnt, state->thread_id,
- sum_hit_compile_cnt);
+ if (sum_hit_rule_cnt > 0) {
+ alignment_int64_array_add(maat_inst->stat->hit_rule_cnt, state->thread_id,
+ sum_hit_rule_cnt);
}
void *interval_rt = table_manager_get_runtime(maat_inst->tbl_mgr, phy_table_id);
@@ -1480,7 +1480,7 @@ int maat_scan_integer(struct maat *maat_inst, int table_id,
maat_runtime_ref_dec(maat_rt, state->thread_id);
- if (sum_hit_compile_cnt > 0) {
+ if (sum_hit_rule_cnt > 0) {
return MAAT_SCAN_HIT;
} else if (hit_group_cnt > 0) {
return MAAT_SCAN_HALF_HIT;
@@ -1541,15 +1541,15 @@ int maat_scan_ipv4_port(struct maat *maat_inst, int table_id, uint32_t ip_addr,
maat_runtime_ref_inc(maat_rt, state->thread_id);
- size_t sum_hit_compile_cnt = 0;
+ size_t sum_hit_rule_cnt = 0;
if (hit_group_cnt > 0) {
- sum_hit_compile_cnt = group_to_compile(maat_inst, results, n_result, state);
- *n_hit_result = sum_hit_compile_cnt;
+ sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ *n_hit_result = sum_hit_rule_cnt;
}
- if (sum_hit_compile_cnt > 0) {
- alignment_int64_array_add(maat_inst->stat->hit_compile_cnt, state->thread_id,
- sum_hit_compile_cnt);
+ if (sum_hit_rule_cnt > 0) {
+ alignment_int64_array_add(maat_inst->stat->hit_rule_cnt, state->thread_id,
+ sum_hit_rule_cnt);
}
void *ip_rt = table_manager_get_runtime(maat_inst->tbl_mgr, phy_table_id);
@@ -1564,7 +1564,7 @@ int maat_scan_ipv4_port(struct maat *maat_inst, int table_id, uint32_t ip_addr,
maat_runtime_ref_dec(maat_rt, state->thread_id);
- if (sum_hit_compile_cnt > 0) {
+ if (sum_hit_rule_cnt > 0) {
return MAAT_SCAN_HIT;
} else if (hit_group_cnt > 0) {
return MAAT_SCAN_HALF_HIT;
@@ -1625,15 +1625,15 @@ int maat_scan_ipv6_port(struct maat *maat_inst, int table_id, uint8_t *ip_addr,
maat_runtime_ref_inc(maat_rt, state->thread_id);
- size_t sum_hit_compile_cnt = 0;
+ size_t sum_hit_rule_cnt = 0;
if (hit_group_cnt > 0) {
- sum_hit_compile_cnt = group_to_compile(maat_inst, results, n_result, state);
- *n_hit_result = sum_hit_compile_cnt;
+ sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ *n_hit_result = sum_hit_rule_cnt;
}
- if (sum_hit_compile_cnt > 0) {
- alignment_int64_array_add(maat_inst->stat->hit_compile_cnt, state->thread_id,
- sum_hit_compile_cnt);
+ if (sum_hit_rule_cnt > 0) {
+ alignment_int64_array_add(maat_inst->stat->hit_rule_cnt, state->thread_id,
+ sum_hit_rule_cnt);
}
void *ip_rt = table_manager_get_runtime(maat_inst->tbl_mgr, phy_table_id);
@@ -1648,7 +1648,7 @@ int maat_scan_ipv6_port(struct maat *maat_inst, int table_id, uint8_t *ip_addr,
maat_runtime_ref_dec(maat_rt, state->thread_id);
- if (sum_hit_compile_cnt > 0) {
+ if (sum_hit_rule_cnt > 0) {
return MAAT_SCAN_HIT;
} else if (hit_group_cnt > 0) {
return MAAT_SCAN_HALF_HIT;
@@ -1728,15 +1728,15 @@ int maat_scan_string(struct maat *maat_inst, int table_id,
maat_runtime_ref_inc(maat_rt, state->thread_id);
- size_t sum_hit_compile_cnt = 0;
+ size_t sum_hit_rule_cnt = 0;
if (hit_group_cnt > 0) {
- sum_hit_compile_cnt = group_to_compile(maat_inst, results, n_result, state);
- *n_hit_result = sum_hit_compile_cnt;
+ sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ *n_hit_result = sum_hit_rule_cnt;
}
- if (sum_hit_compile_cnt > 0) {
- alignment_int64_array_add(maat_inst->stat->hit_compile_cnt, state->thread_id,
- sum_hit_compile_cnt);
+ if (sum_hit_rule_cnt > 0) {
+ alignment_int64_array_add(maat_inst->stat->hit_rule_cnt, state->thread_id,
+ sum_hit_rule_cnt);
}
void *expr_rt = table_manager_get_runtime(maat_inst->tbl_mgr, phy_table_id);
@@ -1751,7 +1751,7 @@ int maat_scan_string(struct maat *maat_inst, int table_id,
maat_runtime_ref_dec(maat_rt, state->thread_id);
- if (sum_hit_compile_cnt > 0) {
+ if (sum_hit_rule_cnt > 0) {
return MAAT_SCAN_HIT;
} else if (hit_group_cnt > 0) {
return MAAT_SCAN_HALF_HIT;
@@ -1765,14 +1765,14 @@ static void maat_state_add_hit_group(struct maat_state *state, int table_id,
{
struct maat *maat_inst = state->maat_inst;
- //clear compile_state->last_hit_group
- if (state != NULL && state->compile_state != NULL) {
- compile_state_clear_last_hit_group(state->compile_state);
+ //clear rule_state->last_hit_group
+ if (state != NULL && state->rule_state != NULL) {
+ rule_state_clear_last_hit_group(state->rule_state);
}
- if (NULL == state->compile_state) {
- state->compile_state = compile_state_new();
- alignment_int64_array_add(maat_inst->stat->compile_state_cnt,
+ if (NULL == state->rule_state) {
+ state->rule_state = rule_state_new();
+ alignment_int64_array_add(maat_inst->stat->rule_state_cnt,
state->thread_id, 1);
}
@@ -1787,8 +1787,8 @@ static void maat_state_add_hit_group(struct maat_state *state, int table_id,
hit_items[i].group_id = groups[i].group_id;
}
- compile_state_update(state->compile_state, maat_inst, table_id,
- state->compile_table_id, state->Nth_scan,
+ rule_state_update(state->rule_state, maat_inst, table_id,
+ state->rule_table_id, state->Nth_scan,
hit_items, n_hit_item);
}
@@ -1800,24 +1800,24 @@ maat_state_activate_hit_not_group(struct maat_state *state, int table_id)
}
struct maat *maat_inst = state->maat_inst;
- int compile_table_id =
- table_manager_get_default_compile_table_id(maat_inst->tbl_mgr);
- if (state->compile_table_id > 0) {
- compile_table_id = state->compile_table_id;
+ int rule_table_id =
+ table_manager_get_default_rule_table_id(maat_inst->tbl_mgr);
+ if (state->rule_table_id > 0) {
+ rule_table_id = state->rule_table_id;
}
- struct compile_runtime *compile_rt =
- table_manager_get_runtime(maat_inst->tbl_mgr, compile_table_id);
- if (NULL == compile_rt) {
+ struct rule_runtime *rule_rt =
+ table_manager_get_runtime(maat_inst->tbl_mgr, rule_table_id);
+ if (NULL == rule_rt) {
return;
}
- //clear compile_state->last_hit_group
- if (state != NULL && state->compile_state != NULL) {
- compile_state_clear_last_hit_group(state->compile_state);
+ //clear rule_state->last_hit_group
+ if (state != NULL && state->rule_state != NULL) {
+ rule_state_clear_last_hit_group(state->rule_state);
}
- compile_state_not_logic_update(state->compile_state, compile_rt, maat_inst,
+ rule_state_not_logic_update(state->rule_state, rule_rt, maat_inst,
table_id, state->Nth_scan);
}
@@ -1860,13 +1860,13 @@ int maat_scan_group(struct maat *maat_inst, int table_id,
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
maat_state_add_hit_group(state, table_id, groups, n_group);
- size_t hit_compile_cnt = group_to_compile(maat_inst, results, n_result, state);
- *n_hit_result = hit_compile_cnt;
+ size_t hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ *n_hit_result = hit_rule_cnt;
maat_runtime_ref_dec(maat_rt, state->thread_id);
- if (hit_compile_cnt > 0) {
- alignment_int64_array_add(maat_inst->stat->hit_compile_cnt, state->thread_id,
- hit_compile_cnt);
+ if (hit_rule_cnt > 0) {
+ alignment_int64_array_add(maat_inst->stat->hit_rule_cnt, state->thread_id,
+ hit_rule_cnt);
return MAAT_SCAN_HIT;
}
@@ -1883,7 +1883,7 @@ int maat_scan_not_logic(struct maat *maat_inst, int table_id,
return -1;
}
- if (NULL == state->compile_state) {
+ if (NULL == state->rule_state) {
return 0;
}
@@ -1896,13 +1896,13 @@ int maat_scan_not_logic(struct maat *maat_inst, int table_id,
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
maat_state_activate_hit_not_group(state, table_id);
- size_t hit_compile_cnt = group_to_compile(maat_inst, results, n_result, state);
- *n_hit_result = hit_compile_cnt;
+ size_t hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ *n_hit_result = hit_rule_cnt;
maat_runtime_ref_dec(maat_rt, state->thread_id);
- if (hit_compile_cnt > 0) {
- alignment_int64_array_add(maat_inst->stat->hit_compile_cnt, state->thread_id,
- hit_compile_cnt);
+ if (hit_rule_cnt > 0) {
+ alignment_int64_array_add(maat_inst->stat->hit_rule_cnt, state->thread_id,
+ hit_rule_cnt);
return MAAT_SCAN_HIT;
}
@@ -2061,15 +2061,15 @@ int maat_stream_scan(struct maat_stream *maat_stream, const char *data, int data
return MAAT_SCAN_ERR;
}
- size_t sum_hit_compile_cnt = 0;
+ size_t sum_hit_rule_cnt = 0;
if (hit_group_cnt > 0) {
- sum_hit_compile_cnt = group_to_compile(maat_inst, results, n_result, state);
- *n_hit_result = sum_hit_compile_cnt;
+ sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ *n_hit_result = sum_hit_rule_cnt;
}
- if (sum_hit_compile_cnt > 0) {
- alignment_int64_array_add(maat_inst->stat->hit_compile_cnt, maat_stream->thread_id,
- sum_hit_compile_cnt);
+ if (sum_hit_rule_cnt > 0) {
+ alignment_int64_array_add(maat_inst->stat->hit_rule_cnt, maat_stream->thread_id,
+ sum_hit_rule_cnt);
}
if (1 == maat_inst->opts.perf_on) {
@@ -2079,7 +2079,7 @@ int maat_stream_scan(struct maat_stream *maat_stream, const char *data, int data
expr_runtime_perf_stat(expr_rt, data_len, NULL, NULL, state->thread_id);
}
- if (sum_hit_compile_cnt > 0) {
+ if (sum_hit_rule_cnt > 0) {
return MAAT_SCAN_HIT;
} else if (hit_group_cnt > 0) {
return MAAT_SCAN_HALF_HIT;
@@ -2130,7 +2130,7 @@ struct maat_state *maat_state_new(struct maat *maat_inst, int thread_id)
state->district_id = DISTRICT_ANY;
state->thread_id = thread_id;
- /* state->compile_state no need to alloc memory at this point,
+ /* state->rule_state no need to alloc memory at this point,
but alloc it after hitting items
*/
alignment_int64_array_add(maat_inst->stat->maat_state_cnt, thread_id, 1);
@@ -2144,13 +2144,13 @@ void maat_state_reset(struct maat_state *state)
return;
}
- state->compile_table_id = 0;
+ state->rule_table_id = 0;
state->district_flag = DISTRICT_FLAG_UNSET;
state->district_id = DISTRICT_ANY;
state->Nth_scan = 0;
- if (state->compile_state != NULL) {
- compile_state_reset(state->compile_state);
+ if (state->rule_state != NULL) {
+ rule_state_reset(state->rule_state);
}
}
@@ -2165,10 +2165,10 @@ void maat_state_free(struct maat_state *state)
struct maat *maat_inst = state->maat_inst;
long long thread_id = state->thread_id;
- if (state->compile_state != NULL) {
- compile_state_free(state->compile_state, maat_inst, thread_id);
- state->compile_state = NULL;
- alignment_int64_array_add(maat_inst->stat->compile_state_cnt,
+ if (state->rule_state != NULL) {
+ rule_state_free(state->rule_state, maat_inst, thread_id);
+ state->rule_state = NULL;
+ alignment_int64_array_add(maat_inst->stat->rule_state_cnt,
thread_id, -1);
}
@@ -2244,10 +2244,10 @@ int maat_state_set_scan_district(struct maat_state *state, int table_id,
return 0;
}
-int maat_state_set_scan_compile_table(struct maat_state *state,
- int compile_table_id)
+int maat_state_set_scan_rule_table(struct maat_state *state,
+ int rule_table_id)
{
- if (NULL == state || compile_table_id < 0) {
+ if (NULL == state || rule_table_id < 0) {
return -1;
}
@@ -2258,25 +2258,25 @@ int maat_state_set_scan_compile_table(struct maat_state *state,
return -1;
}
- state->compile_table_id = compile_table_id;
+ state->rule_table_id = rule_table_id;
return 0;
}
-int maat_state_get_compile_table_ids(struct maat_state *state, long long *compile_ids,
- size_t n_compile_ids, int *compile_table_ids)
+int maat_state_get_rule_table_ids(struct maat_state *state, long long *rule_ids,
+ size_t n_rule_ids, int *rule_table_ids)
{
- if (NULL == state || NULL == compile_ids || 0 == n_compile_ids ||
- NULL == compile_table_ids) {
+ if (NULL == state || NULL == rule_ids || 0 == n_rule_ids ||
+ NULL == rule_table_ids) {
return -1;
}
- for (size_t i = 0; i < n_compile_ids; i++) {
- compile_table_ids[i] = compile_state_get_compile_table_id(state->compile_state,
- compile_ids[i]);
+ for (size_t i = 0; i < n_rule_ids; i++) {
+ rule_table_ids[i] = rule_state_get_rule_table_id(state->rule_state,
+ rule_ids[i]);
}
- return n_compile_ids;
+ return n_rule_ids;
}
int maat_state_get_hit_paths(struct maat_state *state, struct maat_hit_path *path_array,
@@ -2293,19 +2293,19 @@ int maat_state_get_hit_paths(struct maat_state *state, struct maat_hit_path *pat
return -1;
}
- if (NULL == state->compile_state) {
+ if (NULL == state->rule_state) {
return 0;
}
- int compile_table_id =
- table_manager_get_default_compile_table_id(maat_inst->tbl_mgr);
- if (state->compile_table_id > 0) {
- compile_table_id = state->compile_table_id;
+ int rule_table_id =
+ table_manager_get_default_rule_table_id(maat_inst->tbl_mgr);
+ if (state->rule_table_id > 0) {
+ rule_table_id = state->rule_table_id;
}
- void *compile_rt = table_manager_get_runtime(maat_inst->tbl_mgr,
- compile_table_id);
- if (NULL == compile_rt) {
+ void *rule_rt = table_manager_get_runtime(maat_inst->tbl_mgr,
+ rule_table_id);
+ if (NULL == rule_rt) {
return -1;
}
@@ -2313,13 +2313,13 @@ int maat_state_get_hit_paths(struct maat_state *state, struct maat_hit_path *pat
void *g2g_runtime = table_manager_get_runtime(maat_inst->tbl_mgr, g2g_table_id);
size_t hit_path_cnt =
- compile_state_get_internal_hit_paths(state->compile_state,
- (struct compile_runtime *)compile_rt,
+ rule_state_get_internal_hit_paths(state->rule_state,
+ (struct rule_runtime *)rule_rt,
(struct group2group_runtime *)g2g_runtime,
path_array, array_size);
- return compile_runtime_get_hit_paths((struct compile_runtime *)compile_rt,
- state->thread_id, state->compile_state,
+ return rule_runtime_get_hit_paths((struct rule_runtime *)rule_rt,
+ state->thread_id, state->rule_state,
path_array, array_size, hit_path_cnt);
}
@@ -2340,21 +2340,21 @@ int maat_state_get_direct_hit_groups(struct maat_state *state,
return -1;
}
- if (NULL == state->compile_state) {
+ if (NULL == state->rule_state) {
return 0;
}
- return compile_state_get_direct_hit_groups(state->compile_state,
+ return rule_state_get_direct_hit_groups(state->rule_state,
group_array, array_size);
}
size_t maat_state_get_direct_hit_group_cnt(struct maat_state *state)
{
- if (NULL == state || NULL == state->compile_state) {
+ if (NULL == state || NULL == state->rule_state) {
return 0;
}
- return compile_state_get_direct_hit_group_cnt(state->compile_state);
+ return rule_state_get_direct_hit_group_cnt(state->rule_state);
}
int maat_state_get_indirect_hit_groups(struct maat_state *state,
@@ -2365,40 +2365,40 @@ int maat_state_get_indirect_hit_groups(struct maat_state *state,
return -1;
}
- if (NULL == state->compile_state) {
+ if (NULL == state->rule_state) {
return 0;
}
- return compile_state_get_indirect_hit_groups(state->compile_state,
+ return rule_state_get_indirect_hit_groups(state->rule_state,
group_array, array_size);
}
size_t maat_state_get_indirect_hit_group_cnt(struct maat_state *state)
{
- if (NULL == state || NULL == state->compile_state) {
+ if (NULL == state || NULL == state->rule_state) {
return 0;
}
- return compile_state_get_indirect_hit_group_cnt(state->compile_state);
+ return rule_state_get_indirect_hit_group_cnt(state->rule_state);
}
int maat_state_get_last_hit_groups(struct maat_state *state,
struct maat_hit_group *group_array,
size_t array_size)
{
- if (NULL == state || NULL == state->compile_state) {
+ if (NULL == state || NULL == state->rule_state) {
return 0;
}
- return compile_state_get_last_hit_groups(state->compile_state,
+ return rule_state_get_last_hit_groups(state->rule_state,
group_array, array_size);
}
size_t maat_state_get_last_hit_group_cnt(struct maat_state *state)
{
- if (NULL == state || NULL == state->compile_state) {
+ if (NULL == state || NULL == state->rule_state) {
return 0;
}
- return compile_state_get_last_hit_group_cnt(state->compile_state);
+ return rule_state_get_last_hit_group_cnt(state->rule_state);
}
\ No newline at end of file
diff --git a/src/maat_core.c b/src/maat_core.c
index 61ba777..3084fdc 100644
--- a/src/maat_core.c
+++ b/src/maat_core.c
@@ -23,7 +23,7 @@
#include "maat_config_monitor.h"
#include "maat_redis_monitor.h"
#include "maat_table.h"
-#include "maat_compile.h"
+#include "maat_rule.h"
#include "maat_plugin.h"
#include "maat_ip_plugin.h"
#include "maat_ipport_plugin.h"
@@ -108,12 +108,12 @@ maat_start_cb(long long new_version, int update_type, void *u_param)
for (i = 0; i < max_table_cnt; i++) {
table_type = table_manager_get_table_type(maat_inst->tbl_mgr, i);
- if (table_type == TABLE_TYPE_COMPILE) {
- // compile runtime need a reference to maat runtime
- void *compile_rt =
+ if (table_type == TABLE_TYPE_RULE) {
+ // rule runtime need a reference to maat runtime
+ void *rule_rt =
table_manager_get_updating_runtime(maat_inst->tbl_mgr, i);
- compile_runtime_init(compile_rt, maat_inst->creating_maat_rt);
+ rule_runtime_init(rule_rt, maat_inst->creating_maat_rt);
}
}
} else {
diff --git a/src/maat_expr.c b/src/maat_expr.c
index af761d3..6bdbad9 100644
--- a/src/maat_expr.c
+++ b/src/maat_expr.c
@@ -20,7 +20,7 @@
#include "rcu_hash.h"
#include "maat.h"
#include "maat_core.h"
-#include "maat_compile.h"
+#include "maat_rule.h"
#include "maat_group.h"
#include "alignment.h"
#include "maat_garbage_collection.h"
@@ -953,9 +953,9 @@ int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id,
const char *data, size_t data_len,
int vtable_id, struct maat_state *state)
{
- //clear compile_state->last_hit_group
- if (state != NULL && state->compile_state != NULL) {
- compile_state_clear_last_hit_group(state->compile_state);
+ //clear rule_state->last_hit_group
+ if (state != NULL && state->rule_state != NULL) {
+ rule_state_clear_last_hit_group(state->rule_state);
}
if (0 == expr_rt->rule_num) {
@@ -1013,14 +1013,14 @@ int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id,
}
next:
- if (NULL == state->compile_state) {
- state->compile_state = compile_state_new();
- alignment_int64_array_add(state->maat_inst->stat->compile_state_cnt,
+ if (NULL == state->rule_state) {
+ state->rule_state = rule_state_new();
+ alignment_int64_array_add(state->maat_inst->stat->rule_state_cnt,
state->thread_id, 1);
}
- return compile_state_update(state->compile_state, state->maat_inst, vtable_id,
- state->compile_table_id, state->Nth_scan,
+ return rule_state_update(state->rule_state, state->maat_inst, vtable_id,
+ state->rule_table_id, state->Nth_scan,
hit_maat_items, real_hit_item_num);
}
@@ -1049,9 +1049,9 @@ int expr_runtime_stream_scan(struct expr_runtime_stream *expr_rt_stream,
{
struct expr_runtime *expr_rt = expr_rt_stream->ref_expr_rt;
- //clear compile_state->last_hit_group
- if (state != NULL && state->compile_state != NULL) {
- compile_state_clear_last_hit_group(state->compile_state);
+ //clear rule_state->last_hit_group
+ if (state != NULL && state->rule_state != NULL) {
+ rule_state_clear_last_hit_group(state->rule_state);
}
if (0 == expr_rt->rule_num) {
@@ -1107,14 +1107,14 @@ int expr_runtime_stream_scan(struct expr_runtime_stream *expr_rt_stream,
}
next:
- if (NULL == state->compile_state) {
- state->compile_state = compile_state_new();
- alignment_int64_array_add(state->maat_inst->stat->compile_state_cnt,
+ if (NULL == state->rule_state) {
+ state->rule_state = rule_state_new();
+ alignment_int64_array_add(state->maat_inst->stat->rule_state_cnt,
state->thread_id, 1);
}
- return compile_state_update(state->compile_state, state->maat_inst, vtable_id,
- state->compile_table_id, state->Nth_scan,
+ return rule_state_update(state->rule_state, state->maat_inst, vtable_id,
+ state->rule_table_id, state->Nth_scan,
hit_maat_items, real_hit_item_cnt);
}
diff --git a/src/maat_flag.c b/src/maat_flag.c
index 9707e09..f34b966 100644
--- a/src/maat_flag.c
+++ b/src/maat_flag.c
@@ -19,7 +19,7 @@
#include "rcu_hash.h"
#include "maat_table.h"
#include "alignment.h"
-#include "maat_compile.h"
+#include "maat_rule.h"
#include "maat_garbage_collection.h"
#define MODULE_FLAG module_name_str("maat.flag")
@@ -555,9 +555,9 @@ long long flag_runtime_rule_count(void *flag_runtime)
int flag_runtime_scan(struct flag_runtime *flag_rt, int thread_id,
long long flag, int vtable_id, struct maat_state *state)
{
- //clear compile_state->last_hit_group
- if (state != NULL && state->compile_state != NULL) {
- compile_state_clear_last_hit_group(state->compile_state);
+ //clear rule_state->last_hit_group
+ if (state != NULL && state->rule_state != NULL) {
+ rule_state_clear_last_hit_group(state->rule_state);
}
if (0 == flag_rt->rule_num) {
@@ -609,14 +609,14 @@ int flag_runtime_scan(struct flag_runtime *flag_rt, int thread_id,
}
next:
- if (NULL == state->compile_state) {
- state->compile_state = compile_state_new();
- alignment_int64_array_add(state->maat_inst->stat->compile_state_cnt,
+ if (NULL == state->rule_state) {
+ state->rule_state = rule_state_new();
+ alignment_int64_array_add(state->maat_inst->stat->rule_state_cnt,
state->thread_id, 1);
}
- return compile_state_update(state->compile_state, state->maat_inst, vtable_id,
- state->compile_table_id, state->Nth_scan,
+ return rule_state_update(state->rule_state, state->maat_inst, vtable_id,
+ state->rule_table_id, state->Nth_scan,
hit_maat_items, real_hit_item_cnt);
}
diff --git a/src/maat_interval.c b/src/maat_interval.c
index afcfa7c..921bdd4 100644
--- a/src/maat_interval.c
+++ b/src/maat_interval.c
@@ -15,7 +15,7 @@
#include "rcu_hash.h"
#include "alignment.h"
#include "maat_garbage_collection.h"
-#include "maat_compile.h"
+#include "maat_rule.h"
#include "interval_matcher.h"
#include "maat_interval.h"
@@ -544,9 +544,9 @@ long long interval_runtime_rule_count(void *interval_runtime)
int interval_runtime_scan(struct interval_runtime *interval_rt, int thread_id,
long long integer, int vtable_id, struct maat_state *state)
{
- //clear compile_state->last_hit_group
- if (state != NULL && state->compile_state != NULL) {
- compile_state_clear_last_hit_group(state->compile_state);
+ //clear rule_state->last_hit_group
+ if (state != NULL && state->rule_state != NULL) {
+ rule_state_clear_last_hit_group(state->rule_state);
}
if (0 == interval_rt->rule_num) {
@@ -598,14 +598,14 @@ int interval_runtime_scan(struct interval_runtime *interval_rt, int thread_id,
}
next:
- if (NULL == state->compile_state) {
- state->compile_state = compile_state_new();
- alignment_int64_array_add(state->maat_inst->stat->compile_state_cnt,
+ if (NULL == state->rule_state) {
+ state->rule_state = rule_state_new();
+ alignment_int64_array_add(state->maat_inst->stat->rule_state_cnt,
state->thread_id, 1);
}
- return compile_state_update(state->compile_state, state->maat_inst, vtable_id,
- state->compile_table_id, state->Nth_scan,
+ return rule_state_update(state->rule_state, state->maat_inst, vtable_id,
+ state->rule_table_id, state->Nth_scan,
hit_maat_items, real_hit_item_cnt);
}
diff --git a/src/maat_ip.c b/src/maat_ip.c
index ad214e7..e6c7c6c 100644
--- a/src/maat_ip.c
+++ b/src/maat_ip.c
@@ -17,7 +17,7 @@
#include "ip_matcher.h"
#include "maat_ip.h"
#include "maat_core.h"
-#include "maat_compile.h"
+#include "maat_rule.h"
#include "alignment.h"
#include "maat_garbage_collection.h"
@@ -522,9 +522,9 @@ long long ip_runtime_ipv6_rule_count(void *ip_runtime)
int ip_runtime_scan(struct ip_runtime *ip_rt, int thread_id, int ip_type,
uint8_t *ip_addr, int port, int vtable_id, struct maat_state *state)
{
- //clear compile_state->last_hit_group
- if (state != NULL && state->compile_state != NULL) {
- compile_state_clear_last_hit_group(state->compile_state);
+ //clear rule_state->last_hit_group
+ if (state != NULL && state->rule_state != NULL) {
+ rule_state_clear_last_hit_group(state->rule_state);
}
if (0 == ip_rt->rule_num) {
@@ -593,14 +593,14 @@ int ip_runtime_scan(struct ip_runtime *ip_rt, int thread_id, int ip_type,
real_hit_item_cnt);
}
next:
- if (NULL == state->compile_state) {
- state->compile_state = compile_state_new();
- alignment_int64_array_add(state->maat_inst->stat->compile_state_cnt,
+ if (NULL == state->rule_state) {
+ state->rule_state = rule_state_new();
+ alignment_int64_array_add(state->maat_inst->stat->rule_state_cnt,
state->thread_id, 1);
}
- return compile_state_update(state->compile_state, state->maat_inst, vtable_id,
- state->compile_table_id, state->Nth_scan,
+ return rule_state_update(state->rule_state, state->maat_inst, vtable_id,
+ state->rule_table_id, state->Nth_scan,
hit_maat_items, real_hit_item_cnt);
}
diff --git a/src/maat_compile.c b/src/maat_rule.c
similarity index 53%
rename from src/maat_compile.c
rename to src/maat_rule.c
index bac613a..454cff8 100644
--- a/src/maat_compile.c
+++ b/src/maat_rule.c
@@ -1,6 +1,6 @@
/*
**********************************************************************************************
-* File: maat_compile.c
+* File: maat_rule.c
* Description:
* Authors: Liu wentan
* Date: 2022-10-31
@@ -19,14 +19,14 @@
#include "uthash/uthash.h"
#include "bool_matcher.h"
#include "igraph/igraph.h"
-#include "maat_compile.h"
+#include "maat_rule.h"
#include "maat_garbage_collection.h"
#include "maat_group.h"
#include "maat_ex_data.h"
#include "maat_table.h"
#include "alignment.h"
-#define MODULE_COMPILE module_name_str("maat.compile")
+#define MODULE_RULE module_name_str("maat.rule")
#define MAX_NOT_CLAUSE_NUM 8
@@ -35,8 +35,8 @@ enum clause_not_flag {
CLAUSE_NOT_FLAG_SET
};
-struct compile_schema {
- int compile_id_column;
+struct rule_schema {
+ int rule_id_column;
int rule_tag_column;
int declared_clause_num_column;
int table_id;
@@ -44,27 +44,27 @@ struct compile_schema {
struct log_handle *logger;
};
-struct group2compile_schema {
+struct group2rule_schema {
int group_id_column;
- int compile_id_column;
+ int rule_id_column;
int not_flag_column;
int vtable_name_column;
int clause_index_column;
- int asso_compile_table_id; //asso is abbreviation for associated
+ int asso_rule_table_id; //asso is abbreviation for associated
int table_id;
struct table_manager *ref_tbl_mgr;
};
-struct compile_item {
+struct rule_item {
int declared_clause_num;
- long long compile_id;
+ long long rule_id;
char *table_line;
size_t table_line_len;
};
-struct group2compile_item {
+struct group2rule_item {
UT_array *group_ids;
- long long compile_id;
+ long long rule_id;
int not_flag;
int vtable_id;
int clause_index;
@@ -96,10 +96,10 @@ struct table_group {
UT_hash_handle hh;
};
-/* compile_runtime and group2compile_runtime share compile_hash_map */
-struct compile_runtime {
+/* rule_runtime and group2rule_runtime share rule_hash_map */
+struct rule_runtime {
struct bool_matcher *bm;
- struct rcu_hash_table *cfg_hash; //
+ struct rcu_hash_table *cfg_hash; //
struct maat_runtime *ref_maat_rt;
struct clause_id_kv *clause_id_kv_hash; //store clause_ids(not_flag == 0)
struct clause_id_kv *not_clause_id_kv_hash; //store NOT_clause_ids(not_flag == 1)
@@ -112,11 +112,11 @@ struct compile_runtime {
long long update_err_cnt;
};
-struct group2compile_runtime {
+struct group2rule_runtime {
long long not_clause_cnt;
long long rule_num;
long long update_err_cnt;
- struct compile_runtime *ref_compile_rt;
+ struct rule_runtime *ref_rule_rt;
struct table_clause *tbl_not_clause_hash; //each virtual table's not clause number <= MAX_NOT_CLAUSE_NUM
};
@@ -126,7 +126,7 @@ struct clause_literal {
int vtable_id;
};
-struct compile_clause {
+struct rule_clause {
long long clause_id;
UT_array *literals; //struct clause_literal
char not_flag; // 1 byte
@@ -134,20 +134,20 @@ struct compile_clause {
char pad[6]; // for 8 bytes alignment
};
-struct compile_sort_para {
+struct rule_sort_para {
int declared_clause_num;
- long long compile_id;
+ long long rule_id;
};
-#define MAAT_COMPILE_MAGIC 0x4a5b6c7d
-struct maat_compile {
+#define MAAT_RULE_MAGIC 0x4a5b6c7d
+struct maat_rule {
uint32_t magic_num;
int actual_clause_num;
int declared_clause_num;
int table_id;
- long long compile_id;
- void *user_data; // compile_item
- struct compile_clause clauses[MAX_ITEMS_PER_BOOL_EXPR];
+ long long rule_id;
+ void *user_data; // rule_item
+ struct rule_clause clauses[MAX_ITEMS_PER_BOOL_EXPR];
};
struct internal_hit_path {
@@ -158,15 +158,15 @@ struct internal_hit_path {
int NOT_flag; // 1 means NOT clause
};
-struct compile2table_id {
- long long compile_id;
+struct rule2table_id {
+ long long rule_id;
int table_id;
};
-struct compile_state {
+struct rule_state {
int Nth_scan;
int this_scan_not_logic;
- time_t compile_rt_version;
+ time_t rule_rt_version;
UT_array *internal_hit_paths;
UT_array *all_hit_clauses;
@@ -176,48 +176,48 @@ struct compile_state {
UT_array *direct_hit_groups;
UT_array *indirect_hit_groups;
UT_array *last_hit_groups;
- UT_array *hit_compile_table_ids;
+ UT_array *hit_rule_table_ids;
struct table_group *hit_not_tbl_groups;
};
UT_icd ut_clause_id_icd = {sizeof(long long), NULL, NULL, NULL};
UT_icd ut_clause_literal_icd = {sizeof(struct clause_literal), NULL, NULL, NULL};
-UT_icd ut_compile_group_id_icd = {sizeof(long long), NULL, NULL, NULL};
+UT_icd ut_rule_group_id_icd = {sizeof(long long), NULL, NULL, NULL};
UT_icd ut_maat_hit_group_icd = {sizeof(struct maat_hit_group), NULL, NULL, NULL};
UT_icd ut_hit_path_icd = {sizeof(struct internal_hit_path), NULL, NULL, NULL};
-UT_icd ut_hit_compile_table_id_icd = {sizeof(struct compile2table_id), NULL, NULL, NULL};
+UT_icd ut_hit_rule_table_id_icd = {sizeof(struct rule2table_id), NULL, NULL, NULL};
-static struct maat_compile *maat_compile_new(long long compile_id)
+static struct maat_rule *maat_rule_new(long long rule_id)
{
- struct maat_compile *compile = ALLOC(struct maat_compile, 1);
+ struct maat_rule *rule = ALLOC(struct maat_rule, 1);
- compile->magic_num = MAAT_COMPILE_MAGIC;
- compile->compile_id = compile_id;
+ rule->magic_num = MAAT_RULE_MAGIC;
+ rule->rule_id = rule_id;
for(int i = 0; i < MAX_ITEMS_PER_BOOL_EXPR; i++) {
- utarray_new(compile->clauses[i].literals, &ut_clause_literal_icd);
- compile->clauses[i].in_use = 0;
- compile->clauses[i].clause_id = 0;
+ utarray_new(rule->clauses[i].literals, &ut_clause_literal_icd);
+ rule->clauses[i].in_use = 0;
+ rule->clauses[i].clause_id = 0;
}
- return compile;
+ return rule;
}
-static int maat_compile_set(struct maat_compile *compile, int table_id,
+static int maat_rule_set(struct maat_rule *rule, int table_id,
int declared_clause_num, void *user_data)
{
- if (NULL == compile) {
+ if (NULL == rule) {
return -1;
}
- compile->table_id = table_id;
- compile->declared_clause_num = declared_clause_num;
- compile->user_data = user_data;
+ rule->table_id = table_id;
+ rule->declared_clause_num = declared_clause_num;
+ rule->user_data = user_data;
return 0;
}
-static int compile_accept_tag_match(struct compile_schema *schema, const char *line,
+static int rule_accept_tag_match(struct rule_schema *schema, const char *line,
const char *table_name, struct log_handle *logger)
{
size_t column_offset = 0;
@@ -228,7 +228,7 @@ static int compile_accept_tag_match(struct compile_schema *schema, const char *l
int ret = get_column_pos(line, schema->rule_tag_column,
&column_offset, &column_len);
if (ret < 0) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] table: <%s> has no rule_tag in line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR;
@@ -240,14 +240,14 @@ static int compile_accept_tag_match(struct compile_schema *schema, const char *l
ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str);
FREE(tag_str);
if (TAG_MATCH_ERR == ret) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] table: <%s> has invalid tag format in line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR;
}
if (TAG_MATCH_UNMATCHED == ret) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] table: <%s> has unmatched tag in line:%s",
__FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_UNMATCHED;
@@ -258,59 +258,59 @@ static int compile_accept_tag_match(struct compile_schema *schema, const char *l
return TAG_MATCH_MATCHED;
}
-static struct compile_item *
-compile_item_new(const char *table_line, struct compile_schema *schema,
+static struct rule_item *
+rule_item_new(const char *table_line, struct rule_schema *schema,
const char *table_name, struct log_handle *logger)
{
- int ret = compile_accept_tag_match(schema, table_line, table_name, logger);
+ int ret = rule_accept_tag_match(schema, table_line, table_name, logger);
if (ret == TAG_MATCH_UNMATCHED) {
return NULL;
}
size_t column_offset = 0;
size_t column_len = 0;
- struct compile_item *compile_item = ALLOC(struct compile_item, 1);
+ struct rule_item *rule_item = ALLOC(struct rule_item, 1);
- ret = get_column_pos(table_line, schema->compile_id_column,
+ ret = get_column_pos(table_line, schema->rule_id_column,
&column_offset, &column_len);
if (ret < 0) {
- log_fatal(logger, MODULE_COMPILE,
- "[%s:%d] table: <%s> has no compile_id in line:%s",
+ log_fatal(logger, MODULE_RULE,
+ "[%s:%d] table: <%s> has no rule_id in line:%s",
__FUNCTION__, __LINE__, table_name, table_line);
goto error;
}
- compile_item->compile_id = atoll(table_line + column_offset);
+ rule_item->rule_id = atoll(table_line + column_offset);
ret = get_column_pos(table_line, schema->declared_clause_num_column,
&column_offset, &column_len);
if (ret < 0) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] table: <%s> has no clause_num in line:%s",
__FUNCTION__, __LINE__, table_name, table_line);
goto error;
}
- compile_item->declared_clause_num = atoi(table_line + column_offset);
- if (compile_item->declared_clause_num < 0 ||
- compile_item->declared_clause_num > MAX_NOT_CLAUSE_NUM) {
- log_fatal(logger, MODULE_COMPILE,
+ rule_item->declared_clause_num = atoi(table_line + column_offset);
+ if (rule_item->declared_clause_num < 0 ||
+ rule_item->declared_clause_num > MAX_NOT_CLAUSE_NUM) {
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] table: <%s> clause_num:%d exceed maximum:%d in line:%s",
- __FUNCTION__, __LINE__, table_name, compile_item->declared_clause_num,
+ __FUNCTION__, __LINE__, table_name, rule_item->declared_clause_num,
MAX_NOT_CLAUSE_NUM, table_line);
goto error;
}
- compile_item->table_line_len = strlen(table_line);
- compile_item->table_line = ALLOC(char, compile_item->table_line_len + 1);
- memcpy(compile_item->table_line, table_line, compile_item->table_line_len);
+ rule_item->table_line_len = strlen(table_line);
+ rule_item->table_line = ALLOC(char, rule_item->table_line_len + 1);
+ memcpy(rule_item->table_line, table_line, rule_item->table_line_len);
- return compile_item;
+ return rule_item;
error:
- FREE(compile_item);
+ FREE(rule_item);
return NULL;
}
-static void compile_item_free(struct compile_item *item)
+static void rule_item_free(struct rule_item *item)
{
item->declared_clause_num = 0;
@@ -321,17 +321,17 @@ static void compile_item_free(struct compile_item *item)
FREE(item);
}
-static void maat_compile_free(struct maat_compile *compile)
+static void maat_rule_free(struct maat_rule *rule)
{
- struct compile_clause *clause = NULL;
+ struct rule_clause *clause = NULL;
- if (compile->user_data != NULL) {
- compile_item_free(compile->user_data);
- compile->user_data = NULL;
+ if (rule->user_data != NULL) {
+ rule_item_free(rule->user_data);
+ rule->user_data = NULL;
}
for (int i = 0; i < MAX_ITEMS_PER_BOOL_EXPR; i++) {
- clause = compile->clauses + i;
+ clause = rule->clauses + i;
if (clause->literals != NULL) {
utarray_free(clause->literals);
@@ -342,21 +342,21 @@ static void maat_compile_free(struct maat_compile *compile)
clause->clause_id = 0;
}
- compile->magic_num = 0;
- FREE(compile);
+ rule->magic_num = 0;
+ FREE(rule);
}
-static void rcu_compile_cfg_free(void *user_ctx, void *data)
+static void rcu_rule_cfg_free(void *user_ctx, void *data)
{
- struct maat_compile *compile = (struct maat_compile *)data;
- maat_compile_free(compile);
+ struct maat_rule *rule = (struct maat_rule *)data;
+ maat_rule_free(rule);
}
-void *compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
+void *rule_schema_new(cJSON *json, struct table_manager *tbl_mgr,
const char *table_name,
struct log_handle *logger)
{
- struct compile_schema *schema = ALLOC(struct compile_schema, 1);
+ struct rule_schema *schema = ALLOC(struct rule_schema, 1);
schema->logger = logger;
cJSON *custom_item = NULL;
@@ -364,7 +364,7 @@ void *compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) {
schema->table_id = item->valueint;
} else {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] table: <%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -372,18 +372,18 @@ void *compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom");
if (item == NULL || item->type != cJSON_Object) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] table: <%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name);
goto error;
}
- custom_item = cJSON_GetObjectItem(item, "compile_id");
+ custom_item = cJSON_GetObjectItem(item, "rule_id");
if (custom_item != NULL && custom_item->type == cJSON_Number) {
- schema->compile_id_column = custom_item->valueint;
+ schema->rule_id_column = custom_item->valueint;
} else {
- log_fatal(logger, MODULE_COMPILE,
- "[%s:%d] table: <%s> schema has no compile_id column",
+ log_fatal(logger, MODULE_RULE,
+ "[%s:%d] table: <%s> schema has no rule_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
}
@@ -397,7 +397,7 @@ void *compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->declared_clause_num_column = custom_item->valueint;
} else {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] table: <%s> schema has no clause_num column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -410,40 +410,40 @@ error:
return NULL;
}
-void compile_schema_free(void *compile_schema)
+void rule_schema_free(void *rule_schema)
{
- FREE(compile_schema);
+ FREE(rule_schema);
}
-void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
+void *group2rule_schema_new(cJSON *json, struct table_manager *tbl_mgr,
const char *table_name, struct log_handle *logger)
{
- struct group2compile_schema *g2c_schema = ALLOC(struct group2compile_schema, 1);
+ struct group2rule_schema *g2c_schema = ALLOC(struct group2rule_schema, 1);
cJSON *custom_item = NULL;
cJSON *item = cJSON_GetObjectItem(json, "table_id");
if (item != NULL && item->type == cJSON_Number) {
g2c_schema->table_id = item->valueint;
} else {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] table: <%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
}
- item = cJSON_GetObjectItem(json, "associated_compile_table_id");
+ item = cJSON_GetObjectItem(json, "associated_rule_table_id");
if (item != NULL && item->type == cJSON_Number) {
- g2c_schema->asso_compile_table_id = item->valueint;
+ g2c_schema->asso_rule_table_id = item->valueint;
} else {
- log_fatal(logger, MODULE_COMPILE,
- "[%s:%d] table: <%s> schema has no associated_compile_table_id column",
+ log_fatal(logger, MODULE_RULE,
+ "[%s:%d] table: <%s> schema has no associated_rule_table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
}
item = cJSON_GetObjectItem(json, "custom");
if (item == NULL || item->type != cJSON_Object) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] table: <%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -453,18 +453,18 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2c_schema->group_id_column = custom_item->valueint;
} else {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] table: <%s> schema has no group_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
}
- custom_item = cJSON_GetObjectItem(item, "compile_id");
+ custom_item = cJSON_GetObjectItem(item, "rule_id");
if (custom_item != NULL && custom_item->type == cJSON_Number) {
- g2c_schema->compile_id_column = custom_item->valueint;
+ g2c_schema->rule_id_column = custom_item->valueint;
} else {
- log_fatal(logger, MODULE_COMPILE,
- "[%s:%d] table: <%s> schema has no compile_id column",
+ log_fatal(logger, MODULE_RULE,
+ "[%s:%d] table: <%s> schema has no rule_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
}
@@ -473,7 +473,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2c_schema->not_flag_column = custom_item->valueint;
} else {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] table: <%s> schema has no not_flag column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -483,7 +483,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2c_schema->vtable_name_column = custom_item->valueint;
} else {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] table: <%s> schema has no virtual_table_name column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -493,7 +493,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2c_schema->clause_index_column = custom_item->valueint;
} else {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] table: <%s> schema has no clause_index column",
__FUNCTION__, __LINE__, table_name);
goto error;
@@ -506,39 +506,39 @@ error:
return NULL;
}
-void group2compile_schema_free(void *g2c_schema)
+void group2rule_schema_free(void *g2c_schema)
{
FREE(g2c_schema);
}
-int group2compile_associated_compile_table_id(void *g2c_schema)
+int group2rule_associated_rule_table_id(void *g2c_schema)
{
- struct group2compile_schema *schema = (struct group2compile_schema *)g2c_schema;
+ struct group2rule_schema *schema = (struct group2rule_schema *)g2c_schema;
- return schema->asso_compile_table_id;
+ return schema->asso_rule_table_id;
}
-#define COMPILE_GC_TIMEOUT_S 5
-void *compile_runtime_new(void *compile_schema, size_t max_thread_num,
+#define RULE_GC_TIMEOUT_S 5
+void *rule_runtime_new(void *rule_schema, size_t max_thread_num,
struct maat_garbage_bin *garbage_bin,
struct log_handle *logger)
{
- if (NULL == compile_schema) {
+ if (NULL == rule_schema) {
return NULL;
}
- struct compile_runtime *compile_rt = ALLOC(struct compile_runtime, 1);
+ struct rule_runtime *rule_rt = ALLOC(struct rule_runtime, 1);
- compile_rt->expr_match_buff = ALLOC(struct bool_expr_match,
- max_thread_num * MAX_HIT_COMPILE_NUM);
- compile_rt->version = time(NULL);
- compile_rt->cfg_hash = rcu_hash_new(rcu_compile_cfg_free, NULL, COMPILE_GC_TIMEOUT_S);
- compile_rt->clause_id_kv_hash = NULL;
- compile_rt->not_clause_id_kv_hash = NULL;
- compile_rt->logger = logger;
- compile_rt->ref_garbage_bin = garbage_bin;
+ rule_rt->expr_match_buff = ALLOC(struct bool_expr_match,
+ max_thread_num * MAX_HIT_RULE_NUM);
+ rule_rt->version = time(NULL);
+ rule_rt->cfg_hash = rcu_hash_new(rcu_rule_cfg_free, NULL, RULE_GC_TIMEOUT_S);
+ rule_rt->clause_id_kv_hash = NULL;
+ rule_rt->not_clause_id_kv_hash = NULL;
+ rule_rt->logger = logger;
+ rule_rt->ref_garbage_bin = garbage_bin;
- return compile_rt;
+ return rule_rt;
}
static void clause_id_kv_hash_free(struct clause_id_kv *hash)
@@ -562,54 +562,54 @@ static void garbage_clause_id_kv_hash_free(void *hash, void *arg)
clause_id_kv_hash_free((struct clause_id_kv *)hash);
}
-void compile_runtime_free(void *compile_runtime)
+void rule_runtime_free(void *rule_runtime)
{
- if (NULL == compile_runtime) {
+ if (NULL == rule_runtime) {
return;
}
- struct compile_runtime *compile_rt = (struct compile_runtime *)compile_runtime;
+ struct rule_runtime *rule_rt = (struct rule_runtime *)rule_runtime;
- if (compile_rt->bm != NULL) {
- bool_matcher_free(compile_rt->bm);
- compile_rt->bm = NULL;
+ if (rule_rt->bm != NULL) {
+ bool_matcher_free(rule_rt->bm);
+ rule_rt->bm = NULL;
}
- if (compile_rt->cfg_hash != NULL) {
- rcu_hash_free(compile_rt->cfg_hash);
- compile_rt->cfg_hash = NULL;
+ if (rule_rt->cfg_hash != NULL) {
+ rcu_hash_free(rule_rt->cfg_hash);
+ rule_rt->cfg_hash = NULL;
}
- if (compile_rt->clause_id_kv_hash != NULL) {
- clause_id_kv_hash_free(compile_rt->clause_id_kv_hash);
- compile_rt->clause_id_kv_hash = NULL;
+ if (rule_rt->clause_id_kv_hash != NULL) {
+ clause_id_kv_hash_free(rule_rt->clause_id_kv_hash);
+ rule_rt->clause_id_kv_hash = NULL;
}
- if (compile_rt->not_clause_id_kv_hash != NULL) {
- clause_id_kv_hash_free(compile_rt->not_clause_id_kv_hash);
- compile_rt->not_clause_id_kv_hash = NULL;
+ if (rule_rt->not_clause_id_kv_hash != NULL) {
+ clause_id_kv_hash_free(rule_rt->not_clause_id_kv_hash);
+ rule_rt->not_clause_id_kv_hash = NULL;
}
- if (compile_rt->expr_match_buff != NULL) {
- FREE(compile_rt->expr_match_buff);
+ if (rule_rt->expr_match_buff != NULL) {
+ FREE(rule_rt->expr_match_buff);
}
- FREE(compile_rt);
+ FREE(rule_rt);
}
-void compile_runtime_init(void *compile_runtime, struct maat_runtime *maat_rt)
+void rule_runtime_init(void *rule_runtime, struct maat_runtime *maat_rt)
{
- if (NULL == compile_runtime) {
+ if (NULL == rule_runtime) {
return;
}
- struct compile_runtime *compile_rt =
- (struct compile_runtime *)compile_runtime;
+ struct rule_runtime *rule_rt =
+ (struct rule_runtime *)rule_runtime;
- compile_rt->ref_maat_rt = maat_rt;
+ rule_rt->ref_maat_rt = maat_rt;
}
-void *group2compile_runtime_new(void *g2c_schema, size_t max_thread_num,
+void *group2rule_runtime_new(void *g2c_schema, size_t max_thread_num,
struct maat_garbage_bin *garbage_bin,
struct log_handle *logger)
{
@@ -617,30 +617,30 @@ void *group2compile_runtime_new(void *g2c_schema, size_t max_thread_num,
return NULL;
}
- struct group2compile_runtime *g2c_rt =
- ALLOC(struct group2compile_runtime, 1);
+ struct group2rule_runtime *g2c_rt =
+ ALLOC(struct group2rule_runtime, 1);
g2c_rt->tbl_not_clause_hash = NULL;
return g2c_rt;
}
-void group2compile_runtime_init(void *g2c_runtime, void *compile_runtime)
+void group2rule_runtime_init(void *g2c_runtime, void *rule_runtime)
{
- struct group2compile_runtime *g2c_rt =
- (struct group2compile_runtime *)g2c_runtime;
+ struct group2rule_runtime *g2c_rt =
+ (struct group2rule_runtime *)g2c_runtime;
- g2c_rt->ref_compile_rt = (struct compile_runtime *)compile_runtime;
+ g2c_rt->ref_rule_rt = (struct rule_runtime *)rule_runtime;
}
-void group2compile_runtime_free(void *g2c_runtime)
+void group2rule_runtime_free(void *g2c_runtime)
{
if (NULL == g2c_runtime) {
return;
}
- struct group2compile_runtime *g2c_rt =
- (struct group2compile_runtime *)g2c_runtime;
+ struct group2rule_runtime *g2c_rt =
+ (struct group2rule_runtime *)g2c_runtime;
if (g2c_rt->tbl_not_clause_hash != NULL) {
struct table_clause *not_clause = NULL, *tmp_not_clause = NULL;
@@ -671,7 +671,7 @@ static int is_valid_table_name(const char *str)
return 1;
}
-static void group2compile_item_free(struct group2compile_item *g2c_item)
+static void group2rule_item_free(struct group2rule_item *g2c_item)
{
if (NULL == g2c_item) {
return;
@@ -685,20 +685,20 @@ static void group2compile_item_free(struct group2compile_item *g2c_item)
FREE(g2c_item);
}
-static struct group2compile_item *
-group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema,
+static struct group2rule_item *
+group2rule_item_new(const char *line, struct group2rule_schema *g2c_schema,
const char *table_name, struct log_handle *logger)
{
size_t column_offset = 0;
size_t column_len = 0;
char vtable_name[MAX_NAME_STR_LEN + 1] = {0};
- struct group2compile_item *g2c_item = ALLOC(struct group2compile_item, 1);
- utarray_new(g2c_item->group_ids, &ut_compile_group_id_icd);
+ struct group2rule_item *g2c_item = ALLOC(struct group2rule_item, 1);
+ utarray_new(g2c_item->group_ids, &ut_rule_group_id_icd);
int ret = get_column_pos(line, g2c_schema->group_id_column, &column_offset,
&column_len);
if (ret < 0) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] g2c table:<%s> has no group_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -709,33 +709,33 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
ret = ids_str2longlong_array(group_ids_str, g2c_item->group_ids);
if (ret < 0) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] g2c table:<%s> group_ids str2longlong failed in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
}
if (utarray_len(g2c_item->group_ids) > MAX_GROUP_CNT) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] g2c table:<%s> group_ids exceed maximum:%d in line:%s",
__FUNCTION__, __LINE__, table_name, MAX_GROUP_CNT, line);
goto error;
}
- ret = get_column_pos(line, g2c_schema->compile_id_column, &column_offset,
+ ret = get_column_pos(line, g2c_schema->rule_id_column, &column_offset,
&column_len);
if (ret < 0) {
- log_fatal(logger, MODULE_COMPILE,
- "[%s:%d] g2c table:<%s> has no compile_id in line:%s",
+ log_fatal(logger, MODULE_RULE,
+ "[%s:%d] g2c table:<%s> has no rule_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
}
- g2c_item->compile_id = atoll(line + column_offset);
+ g2c_item->rule_id = atoll(line + column_offset);
ret = get_column_pos(line, g2c_schema->not_flag_column, &column_offset,
&column_len);
if (ret < 0) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] g2c table:<%s> has no NOT_flag in line:%s ",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -744,7 +744,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
g2c_item->not_flag = atoi(line + column_offset);
if (g2c_item->not_flag != CLAUSE_NOT_FLAG_SET &&
g2c_item->not_flag != CLAUSE_NOT_FLAG_UNSET) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] g2c table:<%s> NOT_flag:%d is illegal in line:%s ",
__FUNCTION__, __LINE__, table_name, g2c_item->not_flag, line);
goto error;
@@ -753,14 +753,14 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
ret = get_column_pos(line, g2c_schema->vtable_name_column, &column_offset,
&column_len);
if (ret < 0) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] g2c table:<%s> has no virtual_table_name in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
}
if (column_len > MAX_NAME_STR_LEN) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] g2c table:<%s> virtual_table_name length exceed "
"maxium:%d in line:%s", __FUNCTION__, __LINE__, table_name,
MAX_NAME_STR_LEN, line);
@@ -774,7 +774,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
g2c_item->vtable_id = table_manager_get_table_id(g2c_schema->ref_tbl_mgr,
vtable_name);
if (g2c_item->vtable_id < 0) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] g2c table:<%s> has unknown virtual table:%s in line:%s",
__FUNCTION__, __LINE__, table_name, vtable_name, line);
goto error;
@@ -784,7 +784,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
ret = get_column_pos(line, g2c_schema->clause_index_column, &column_offset,
&column_len);
if (ret < 0) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] g2c table:<%s> has no clause_index in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
@@ -792,7 +792,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
g2c_item->clause_index = atoi(line + column_offset);
if (g2c_item->clause_index < 0 || g2c_item->clause_index >= MAX_NOT_CLAUSE_NUM) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d] g2c table:<%s> clause_index:%d exceed maximum:%d in line:%s",
__FUNCTION__, __LINE__, table_name, g2c_item->clause_index,
MAX_NOT_CLAUSE_NUM, line);
@@ -802,7 +802,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
return g2c_item;
error:
- group2compile_item_free(g2c_item);
+ group2rule_item_free(g2c_item);
return NULL;
}
@@ -819,8 +819,8 @@ static inline int compare_group_id(const void *a, const void *b)
}
}
-static void compile_clause_add_literal(struct compile_clause *clause,
- struct group2compile_item *g2c_item)
+static void rule_clause_add_literal(struct rule_clause *clause,
+ struct group2rule_item *g2c_item)
{
struct clause_literal tmp_literal;
tmp_literal.vtable_id = g2c_item->vtable_id;
@@ -833,8 +833,8 @@ static void compile_clause_add_literal(struct compile_clause *clause,
utarray_push_back(clause->literals, &tmp_literal);
}
-void compile_clause_remove_literal(struct compile_clause *clause,
- struct group2compile_item *g2c_item)
+void rule_clause_remove_literal(struct rule_clause *clause,
+ struct group2rule_item *g2c_item)
{
struct clause_literal *tmp_literal = NULL;
@@ -848,10 +848,10 @@ void compile_clause_remove_literal(struct compile_clause *clause,
}
}
-static int maat_compile_clause_find_literal(struct maat_compile *compile,
- struct group2compile_item *g2c_item)
+static int maat_rule_clause_find_literal(struct maat_rule *rule,
+ struct group2rule_item *g2c_item)
{
- struct compile_clause *clause = compile->clauses + g2c_item->clause_index;
+ struct rule_clause *clause = rule->clauses + g2c_item->clause_index;
struct clause_literal *tmp_literal = NULL;
int found = 0;
@@ -865,56 +865,56 @@ static int maat_compile_clause_find_literal(struct maat_compile *compile,
return found;
}
-static void maat_compile_clause_add_literal(struct maat_compile *compile,
- struct group2compile_item *g2c_item)
+static void maat_rule_clause_add_literal(struct maat_rule *rule,
+ struct group2rule_item *g2c_item)
{
- struct compile_clause *clause = compile->clauses + g2c_item->clause_index;
+ struct rule_clause *clause = rule->clauses + g2c_item->clause_index;
clause->not_flag = g2c_item->not_flag;
if (0 == clause->in_use) {
clause->in_use = 1;
- compile->actual_clause_num++;
+ rule->actual_clause_num++;
}
- compile_clause_add_literal(clause, g2c_item);
+ rule_clause_add_literal(clause, g2c_item);
}
-static void maat_compile_clause_remove_literal(struct maat_compile *compile,
- struct group2compile_item *g2c_item)
+static void maat_rule_clause_remove_literal(struct maat_rule *rule,
+ struct group2rule_item *g2c_item)
{
- struct compile_clause *clause = compile->clauses + g2c_item->clause_index;
+ struct rule_clause *clause = rule->clauses + g2c_item->clause_index;
- compile_clause_remove_literal(clause, g2c_item);
+ rule_clause_remove_literal(clause, g2c_item);
if (0 == utarray_len(clause->literals)) {
clause->in_use = 0;
clause->clause_id = 0;
- compile->actual_clause_num--;
+ rule->actual_clause_num--;
}
}
static struct bool_matcher *
-maat_compile_bool_matcher_new(struct compile_runtime *compile_rt,
- size_t *compile_cnt)
+maat_rule_bool_matcher_new(struct rule_runtime *rule_rt,
+ size_t *rule_cnt)
{
- if (NULL == compile_rt) {
+ if (NULL == rule_rt) {
return NULL;
}
size_t i = 0, j = 0, idx = 0;
int has_clause_num = 0;
- // STEP 1, update clause_id of each compile
+ // STEP 1, update clause_id of each rule
void **data_array = NULL;
- struct maat_compile *iter_compile = NULL;
- size_t rule_cnt = rcu_updating_hash_list(compile_rt->cfg_hash, &data_array);
- *compile_cnt = rule_cnt;
+ struct maat_rule *iter_rule = NULL;
+ size_t node_cnt = rcu_updating_hash_list(rule_rt->cfg_hash, &data_array);
+ *rule_cnt = node_cnt;
- for (idx = 0; idx < rule_cnt; idx++) {
- iter_compile = (struct maat_compile *)data_array[idx];
+ for (idx = 0; idx < node_cnt; idx++) {
+ iter_rule = (struct maat_rule *)data_array[idx];
has_clause_num = 0;
for (i = 0; i < MAX_ITEMS_PER_BOOL_EXPR; i++) {
- struct compile_clause *clause = iter_compile->clauses + i;
+ struct rule_clause *clause = iter_rule->clauses + i;
if (!clause->in_use) {
continue;
}
@@ -922,42 +922,42 @@ maat_compile_bool_matcher_new(struct compile_runtime *compile_rt,
has_clause_num++;
if (0 == clause->clause_id) {
clause->clause_id =
- maat_runtime_get_sequence(compile_rt->ref_maat_rt, "clause_id");
+ maat_runtime_get_sequence(rule_rt->ref_maat_rt, "clause_id");
}
}
- assert(has_clause_num == iter_compile->actual_clause_num);
+ assert(has_clause_num == iter_rule->actual_clause_num);
}
- // STEP 2, serial compile clause states to a bool expression array
+ // STEP 2, serial rule clause states to a bool expression array
size_t expr_cnt = 0;
- struct bool_expr *bool_expr_array = ALLOC(struct bool_expr, rule_cnt);
+ struct bool_expr *bool_expr_array = ALLOC(struct bool_expr, node_cnt);
- for (idx = 0; idx < rule_cnt; idx++) {
- iter_compile = (struct maat_compile *)data_array[idx];
+ for (idx = 0; idx < node_cnt; idx++) {
+ iter_rule = (struct maat_rule *)data_array[idx];
for (i = 0, j = 0; i < MAX_ITEMS_PER_BOOL_EXPR; i++) {
- if (iter_compile->clauses[i].in_use) {
+ if (iter_rule->clauses[i].in_use) {
// TODO:mytest need to delete
#if 0
struct clause_literal *tmp_cl = NULL;
- for(tmp_cl = (struct clause_literal *)utarray_front(iter_compile->clauses[i].literals); tmp_cl !=NULL;
- tmp_cl = (struct clause_literal *)utarray_next(iter_compile->clauses[i].literals, tmp_cl)) {
+ for(tmp_cl = (struct clause_literal *)utarray_front(iter_rule->clauses[i].literals); tmp_cl !=NULL;
+ tmp_cl = (struct clause_literal *)utarray_next(iter_rule->clauses[i].literals, tmp_cl)) {
for (size_t it = 0; it < tmp_cl->group_cnt; it++) {
- printf(" compile_rt:%p compile_id:%lld, clause_id:%llu, clause_query_key{%lld: %d, %d}\n",
- compile_rt, iter_compile->compile_id, iter_compile->clauses[i].clause_id, tmp_cl->group_ids[it],
- tmp_cl->vtable_id, iter_compile->clauses[i].not_flag);
+ printf(" rule_rt:%p rule_id:%lld, clause_id:%llu, clause_query_key{%lld: %d, %d}\n",
+ rule_rt, iter_rule->rule_id, iter_rule->clauses[i].clause_id, tmp_cl->group_ids[it],
+ tmp_cl->vtable_id, iter_rule->clauses[i].not_flag);
}
}
#endif
- bool_expr_array[expr_cnt].items[j].item_id = iter_compile->clauses[i].clause_id;
+ bool_expr_array[expr_cnt].items[j].item_id = iter_rule->clauses[i].clause_id;
bool_expr_array[expr_cnt].items[j].not_flag = 0;
j++;
}
}
- // some compile may have zero groups, e.g. default policy.
- if (j == (size_t)iter_compile->declared_clause_num && j > 0) {
- bool_expr_array[expr_cnt].expr_id = iter_compile->compile_id;
- bool_expr_array[expr_cnt].user_tag = iter_compile;
+ // some rule may have zero groups, e.g. default policy.
+ if (j == (size_t)iter_rule->declared_clause_num && j > 0) {
+ bool_expr_array[expr_cnt].expr_id = iter_rule->rule_id;
+ bool_expr_array[expr_cnt].user_tag = iter_rule;
bool_expr_array[expr_cnt].item_num = j;
expr_cnt++;
}
@@ -968,7 +968,7 @@ maat_compile_bool_matcher_new(struct compile_runtime *compile_rt,
// STEP 3, build bool matcher
size_t mem_size = 0;
if (0 == expr_cnt) {
- log_fatal(compile_rt->logger, MODULE_COMPILE,
+ log_fatal(rule_rt->logger, MODULE_RULE,
"[%s:%d] No bool expression to build bool matcher.",
__FUNCTION__, __LINE__);
FREE(bool_expr_array);
@@ -977,11 +977,11 @@ maat_compile_bool_matcher_new(struct compile_runtime *compile_rt,
struct bool_matcher *bm = bool_matcher_new(bool_expr_array, expr_cnt, &mem_size);
if (bm != NULL) {
- log_info(compile_rt->logger, MODULE_COMPILE,
+ log_info(rule_rt->logger, MODULE_RULE,
"Build bool matcher of %zu expressions with %zu bytes memory.",
expr_cnt, mem_size);
} else {
- log_fatal(compile_rt->logger, MODULE_COMPILE,
+ log_fatal(rule_rt->logger, MODULE_RULE,
"[%s:%d] Build bool matcher failed!", __FUNCTION__, __LINE__);
}
@@ -1018,7 +1018,7 @@ static inline int compare_hit_group(const void *pa, const void *pb)
return ret;
}
-static inline int compare_compile_id(const void *a, const void *b)
+static inline int compare_rule_id(const void *a, const void *b)
{
long long ret = *(const long long *)a - *(const long long *)b;
@@ -1034,28 +1034,28 @@ static inline int compare_compile_id(const void *a, const void *b)
/**
* @brief build hash for clause or not_clause
*
- * @param compile_rt: compile runtime handle
- * @param not_flag: specify whether to build clause or NOT_clause hash for compile runtime
+ * @param rule_rt: rule runtime handle
+ * @param not_flag: specify whether to build clause or NOT_clause hash for rule runtime
* 0 -> clause hash
* 1 -> NOT_clause hash
*
* @retval generated clause_id_kv_hash
*/
static struct clause_id_kv *
-build_clause_id_kv_hash(struct compile_runtime *compile_rt, int not_flag)
+build_clause_id_kv_hash(struct rule_runtime *rule_rt, int not_flag)
{
- if (NULL == compile_rt) {
+ if (NULL == rule_rt) {
return NULL;
}
void **data_array = NULL;
struct clause_id_kv *clause_id_kv_hash = NULL;
- size_t compile_cnt = rcu_updating_hash_list(compile_rt->cfg_hash, &data_array);
+ size_t rule_cnt = rcu_updating_hash_list(rule_rt->cfg_hash, &data_array);
- for (size_t idx = 0; idx < compile_cnt; idx++) {
- struct maat_compile *compile = (struct maat_compile *)data_array[idx];
+ for (size_t idx = 0; idx < rule_cnt; idx++) {
+ struct maat_rule *rule = (struct maat_rule *)data_array[idx];
for (size_t i = 0; i < MAX_ITEMS_PER_BOOL_EXPR; i++) {
- struct compile_clause *clause = compile->clauses + i;
+ struct rule_clause *clause = rule->clauses + i;
if (!clause->in_use) {
continue;
}
@@ -1105,12 +1105,12 @@ build_clause_id_kv_hash(struct compile_runtime *compile_rt, int not_flag)
}
static int
-maat_compile_has_clause(struct maat_compile *compile, long long clause_id)
+maat_rule_has_clause(struct maat_rule *rule, long long clause_id)
{
- struct compile_clause *clause = NULL;
+ struct rule_clause *clause = NULL;
for (size_t i = 0; i < MAX_ITEMS_PER_BOOL_EXPR; i++) {
- clause = compile->clauses + i;
+ clause = rule->clauses + i;
if (!clause->in_use) {
continue;
}
@@ -1124,28 +1124,28 @@ maat_compile_has_clause(struct maat_compile *compile, long long clause_id)
}
static size_t
-compile_state_if_new_hit_compile(struct compile_state *compile_state,
- struct maat_compile *compile)
+rule_state_if_new_hit_rule(struct rule_state *rule_state,
+ struct maat_rule *rule)
{
size_t i = 0;
size_t r_in_c_cnt = 0;
int ret = 0;
long long new_hit_clause_id = 0;
- if (0 == compile_state->this_scan_not_logic) {
- for (i = 0; i < utarray_len(compile_state->this_scan_hit_clauses); i++) {
+ if (0 == rule_state->this_scan_not_logic) {
+ for (i = 0; i < utarray_len(rule_state->this_scan_hit_clauses); i++) {
new_hit_clause_id =
- *(long long*)utarray_eltptr(compile_state->this_scan_hit_clauses, i);
- ret = maat_compile_has_clause(compile, new_hit_clause_id);
+ *(long long*)utarray_eltptr(rule_state->this_scan_hit_clauses, i);
+ ret = maat_rule_has_clause(rule, new_hit_clause_id);
if (ret) {
r_in_c_cnt++;
}
}
} else {
- for (i = 0; i < utarray_len(compile_state->this_scan_hit_not_clauses); i++) {
+ for (i = 0; i < utarray_len(rule_state->this_scan_hit_not_clauses); i++) {
new_hit_clause_id =
- *(long long*)utarray_eltptr(compile_state->this_scan_hit_not_clauses, i);
- ret = maat_compile_has_clause(compile, new_hit_clause_id);
+ *(long long*)utarray_eltptr(rule_state->this_scan_hit_not_clauses, i);
+ ret = maat_rule_has_clause(rule, new_hit_clause_id);
if (ret) {
r_in_c_cnt++;
}
@@ -1156,80 +1156,80 @@ compile_state_if_new_hit_compile(struct compile_state *compile_state,
}
static void
-compile_state_update_hit_compile_table_id(struct compile_state *compile_state,
- long long compile_id, int table_id)
+rule_state_update_hit_rule_table_id(struct rule_state *rule_state,
+ long long rule_id, int table_id)
{
- if (!utarray_find(compile_state->hit_compile_table_ids, &compile_id,
- compare_compile_id)) {
- struct compile2table_id compile_table_id = {compile_id, table_id};
- utarray_push_back(compile_state->hit_compile_table_ids, &compile_table_id);
- utarray_sort(compile_state->hit_compile_table_ids, compare_compile_id);
+ if (!utarray_find(rule_state->hit_rule_table_ids, &rule_id,
+ compare_rule_id)) {
+ struct rule2table_id rule_table_id = {rule_id, table_id};
+ utarray_push_back(rule_state->hit_rule_table_ids, &rule_table_id);
+ utarray_sort(rule_state->hit_rule_table_ids, compare_rule_id);
}
}
static size_t
-maat_compile_bool_matcher_match(struct compile_runtime *compile_rt,
- struct compile_state *compile_state,
+maat_rule_bool_matcher_match(struct rule_runtime *rule_rt,
+ struct rule_state *rule_state,
int thread_id, void **user_data_array,
size_t ud_array_size)
{
size_t ud_result_cnt = 0;
- struct maat_compile *compile = NULL;
- struct bool_expr_match *expr_match = compile_rt->expr_match_buff +
- (thread_id * MAX_HIT_COMPILE_NUM);
+ struct maat_rule *rule = NULL;
+ struct bool_expr_match *expr_match = rule_rt->expr_match_buff +
+ (thread_id * MAX_HIT_RULE_NUM);
assert(thread_id >= 0);
- if (0 == compile_state->compile_rt_version) {
- compile_state->compile_rt_version = compile_rt->version;
+ if (0 == rule_state->rule_rt_version) {
+ rule_state->rule_rt_version = rule_rt->version;
}
- if (NULL == compile_rt->bm ||
- 0 == utarray_len(compile_state->all_hit_clauses) ||
- compile_state->compile_rt_version != compile_rt->version) {
+ if (NULL == rule_rt->bm ||
+ 0 == utarray_len(rule_state->all_hit_clauses) ||
+ rule_state->rule_rt_version != rule_rt->version) {
return 0;
}
//TODO:mytest need to delete
#if 0
- unsigned long long *p = utarray_eltptr(compile_state->all_hit_clauses, 0);
- for (p = (unsigned long long *)utarray_front(compile_state->all_hit_clauses); p != NULL;
- p = (unsigned long long *)utarray_next(compile_state->all_hit_clauses, p)) {
- printf("before bool_matcher_match compile_rt:%p compile_state clause_id:%llu\n", compile_rt, *p);
+ unsigned long long *p = utarray_eltptr(rule_state->all_hit_clauses, 0);
+ for (p = (unsigned long long *)utarray_front(rule_state->all_hit_clauses); p != NULL;
+ p = (unsigned long long *)utarray_next(rule_state->all_hit_clauses, p)) {
+ printf("before bool_matcher_match rule_rt:%p rule_state clause_id:%llu\n", rule_rt, *p);
}
#endif
int bool_match_ret =
- bool_matcher_match(compile_rt->bm,
- (unsigned long long *)utarray_eltptr(compile_state->all_hit_clauses, 0),
- utarray_len(compile_state->all_hit_clauses),
- expr_match, MAX_HIT_COMPILE_NUM);
+ bool_matcher_match(rule_rt->bm,
+ (unsigned long long *)utarray_eltptr(rule_state->all_hit_clauses, 0),
+ utarray_len(rule_state->all_hit_clauses),
+ expr_match, MAX_HIT_RULE_NUM);
for (int i = 0; i < bool_match_ret && ud_result_cnt < ud_array_size; i++) {
- compile = (struct maat_compile *)expr_match[i].user_tag;
- assert(compile->magic_num == MAAT_COMPILE_MAGIC);
- assert((unsigned long long)compile->compile_id == expr_match[i].expr_id);
- if (0 == compile->actual_clause_num) {
+ rule = (struct maat_rule *)expr_match[i].user_tag;
+ assert(rule->magic_num == MAAT_RULE_MAGIC);
+ assert((unsigned long long)rule->rule_id == expr_match[i].expr_id);
+ if (0 == rule->actual_clause_num) {
continue;
}
- size_t n_new_hit_compile =
- compile_state_if_new_hit_compile(compile_state, compile);
+ size_t n_new_hit_rule =
+ rule_state_if_new_hit_rule(rule_state, rule);
- if (compile->user_data != NULL && n_new_hit_compile > 0) {
- user_data_array[ud_result_cnt] = compile->user_data;
+ if (rule->user_data != NULL && n_new_hit_rule > 0) {
+ user_data_array[ud_result_cnt] = rule->user_data;
ud_result_cnt++;
- compile_state_update_hit_compile_table_id(compile_state, compile->compile_id,
- compile->table_id);
+ rule_state_update_hit_rule_table_id(rule_state, rule->rule_id,
+ rule->table_id);
}
}
return ud_result_cnt;
}
-static struct compile_item *compile_item_clone(struct compile_item *item)
+static struct rule_item *rule_item_clone(struct rule_item *item)
{
- struct compile_item *new_item = ALLOC(struct compile_item, 1);
+ struct rule_item *new_item = ALLOC(struct rule_item, 1);
- new_item->compile_id = item->compile_id;
+ new_item->rule_id = item->rule_id;
new_item->declared_clause_num = item->declared_clause_num;
new_item->table_line_len = item->table_line_len;
new_item->table_line = ALLOC(char, new_item->table_line_len + 1);
@@ -1238,181 +1238,181 @@ static struct compile_item *compile_item_clone(struct compile_item *item)
return new_item;
}
-static struct maat_compile *
-maat_compile_clone(struct maat_compile *compile, int deep_copy)
+static struct maat_rule *
+maat_rule_clone(struct maat_rule *rule, int deep_copy)
{
- struct maat_compile *new_compile = ALLOC(struct maat_compile, 1);
+ struct maat_rule *new_rule = ALLOC(struct maat_rule, 1);
- new_compile->magic_num = compile->magic_num;
- new_compile->compile_id = compile->compile_id;
- new_compile->actual_clause_num = compile->actual_clause_num;
- new_compile->declared_clause_num = compile->declared_clause_num;
- if (1 == deep_copy && compile->user_data != NULL) {
- new_compile->user_data =
- compile_item_clone((struct compile_item *)compile->user_data);
+ new_rule->magic_num = rule->magic_num;
+ new_rule->rule_id = rule->rule_id;
+ new_rule->actual_clause_num = rule->actual_clause_num;
+ new_rule->declared_clause_num = rule->declared_clause_num;
+ if (1 == deep_copy && rule->user_data != NULL) {
+ new_rule->user_data =
+ rule_item_clone((struct rule_item *)rule->user_data);
}
struct clause_literal *tmp_literal = NULL;
for (size_t i = 0; i < MAX_ITEMS_PER_BOOL_EXPR; i++) {
- new_compile->clauses[i].clause_id = compile->clauses[i].clause_id;
- new_compile->clauses[i].in_use = compile->clauses[i].in_use;
- new_compile->clauses[i].not_flag = compile->clauses[i].not_flag;
- utarray_new(new_compile->clauses[i].literals, &ut_clause_literal_icd);
- for (size_t j = 0; j < utarray_len(compile->clauses[i].literals); j++) {
+ new_rule->clauses[i].clause_id = rule->clauses[i].clause_id;
+ new_rule->clauses[i].in_use = rule->clauses[i].in_use;
+ new_rule->clauses[i].not_flag = rule->clauses[i].not_flag;
+ utarray_new(new_rule->clauses[i].literals, &ut_clause_literal_icd);
+ for (size_t j = 0; j < utarray_len(rule->clauses[i].literals); j++) {
tmp_literal =
- (struct clause_literal *)utarray_eltptr(compile->clauses[i].literals, j);
- utarray_push_back(new_compile->clauses[i].literals, tmp_literal);
+ (struct clause_literal *)utarray_eltptr(rule->clauses[i].literals, j);
+ utarray_push_back(new_rule->clauses[i].literals, tmp_literal);
}
}
- return new_compile;
+ return new_rule;
}
-static int maat_add_group_to_compile(struct rcu_hash_table *hash_tbl,
- struct group2compile_item *g2c_item,
+static int maat_add_group_to_rule(struct rcu_hash_table *hash_tbl,
+ struct group2rule_item *g2c_item,
struct log_handle *logger)
{
int ret = 0;
- long long compile_id = g2c_item->compile_id;
- struct maat_compile *compile = NULL;
+ long long rule_id = g2c_item->rule_id;
+ struct maat_rule *rule = NULL;
int updating_flag = rcu_hash_is_updating(hash_tbl);
if (1 == updating_flag) {
- compile = rcu_updating_hash_find(hash_tbl, (char *)&compile_id, sizeof(long long));
- if (compile != NULL) {
- ret = maat_compile_clause_find_literal(compile, g2c_item);
+ rule = rcu_updating_hash_find(hash_tbl, (char *)&rule_id, sizeof(long long));
+ if (rule != NULL) {
+ ret = maat_rule_clause_find_literal(rule, g2c_item);
if (ret > 0) {
- log_fatal(logger, MODULE_COMPILE,
- "[%s:%d]compile:%lld clause(index:%d) already has vtable_id:%d's "
- "literal, can't add again", __FUNCTION__, __LINE__, compile->compile_id,
+ log_fatal(logger, MODULE_RULE,
+ "[%s:%d]rule:%lld clause(index:%d) already has vtable_id:%d's "
+ "literal, can't add again", __FUNCTION__, __LINE__, rule->rule_id,
g2c_item->clause_index, g2c_item->vtable_id);
return -1;
}
- /* compile found in updating hash(added by compile runtime), it can
+ /* rule found in updating hash(added by rule runtime), it can
* be modified directly */
- maat_compile_clause_add_literal(compile, g2c_item);
+ maat_rule_clause_add_literal(rule, g2c_item);
} else {
- /* compile neither in effective hash nor in updating hash, so new one */
- compile = maat_compile_new(compile_id);
- assert(compile != NULL);
+ /* rule neither in effective hash nor in updating hash, so new one */
+ rule = maat_rule_new(rule_id);
+ assert(rule != NULL);
- maat_compile_clause_add_literal(compile, g2c_item);
- rcu_hash_add(hash_tbl, (char *)&compile_id, sizeof(long long), compile);
+ maat_rule_clause_add_literal(rule, g2c_item);
+ rcu_hash_add(hash_tbl, (char *)&rule_id, sizeof(long long), rule);
}
} else {
- compile = rcu_hash_find(hash_tbl, (char *)&compile_id, sizeof(long long));
- if (compile != NULL) {
+ rule = rcu_hash_find(hash_tbl, (char *)&rule_id, sizeof(long long));
+ if (rule != NULL) {
/*******************************************************************
- compile found in effective hash(added by compile runtime), which means
+ rule found in effective hash(added by rule runtime), which means
- 1. rcu_hash_add(hash_tbl, compile) ==> finished
+ 1. rcu_hash_add(hash_tbl, rule) ==> finished
2. rcu_hash_commit(hash_tbl) ==> finished
can only be deleted but not modified
before delete it, we need to make a copy for further use
*********************************************************************/
- ret = maat_compile_clause_find_literal(compile, g2c_item);
+ ret = maat_rule_clause_find_literal(rule, g2c_item);
if (ret > 0) {
- log_fatal(logger, MODULE_COMPILE,
- "[%s:%d]compile:%lld clause(index:%d) already has vtable_id:%d's "
- "literal, can't add again", __FUNCTION__, __LINE__, compile->compile_id,
+ log_fatal(logger, MODULE_RULE,
+ "[%s:%d]rule:%lld clause(index:%d) already has vtable_id:%d's "
+ "literal, can't add again", __FUNCTION__, __LINE__, rule->rule_id,
g2c_item->clause_index, g2c_item->vtable_id);
return -1;
}
- struct maat_compile *copy_compile = maat_compile_clone(compile, 1);
- assert(copy_compile != NULL);
+ struct maat_rule *copy_rule = maat_rule_clone(rule, 1);
+ assert(copy_rule != NULL);
- /* delete compile from rcu hash */
- rcu_hash_del(hash_tbl, (char *)&compile_id, sizeof(long long));
+ /* delete rule from rcu hash */
+ rcu_hash_del(hash_tbl, (char *)&rule_id, sizeof(long long));
- maat_compile_clause_add_literal(copy_compile, g2c_item);
- rcu_hash_add(hash_tbl, (char *)&compile_id, sizeof(long long), copy_compile);
+ maat_rule_clause_add_literal(copy_rule, g2c_item);
+ rcu_hash_add(hash_tbl, (char *)&rule_id, sizeof(long long), copy_rule);
} else {
- compile = maat_compile_new(compile_id);
- assert(compile != NULL);
+ rule = maat_rule_new(rule_id);
+ assert(rule != NULL);
- maat_compile_clause_add_literal(compile, g2c_item);
- rcu_hash_add(hash_tbl, (char *)&compile_id, sizeof(long long), compile);
+ maat_rule_clause_add_literal(rule, g2c_item);
+ rcu_hash_add(hash_tbl, (char *)&rule_id, sizeof(long long), rule);
}
}
return 0;
}
-static int maat_remove_group_from_compile(struct rcu_hash_table *hash_tbl,
- struct group2compile_item *g2c_item,
+static int maat_remove_group_from_rule(struct rcu_hash_table *hash_tbl,
+ struct group2rule_item *g2c_item,
struct log_handle *logger)
{
int ret = 0;
- long long compile_id = g2c_item->compile_id;
- struct maat_compile *compile = NULL;
+ long long rule_id = g2c_item->rule_id;
+ struct maat_rule *rule = NULL;
int updating_flag = rcu_hash_is_updating(hash_tbl);
if (1 == updating_flag) {
- compile = rcu_updating_hash_find(hash_tbl, (char *)&compile_id,
+ rule = rcu_updating_hash_find(hash_tbl, (char *)&rule_id,
sizeof(long long));
- if (NULL == compile) {
- log_fatal(logger, MODULE_COMPILE,
- "[%s:%d] Remove clause(index:%d) from compile %lld failed,"
- "compile not existed.", __FUNCTION__, __LINE__,
- g2c_item->clause_index, compile_id);
+ if (NULL == rule) {
+ log_fatal(logger, MODULE_RULE,
+ "[%s:%d] Remove clause(index:%d) from rule %lld failed,"
+ "rule not existed.", __FUNCTION__, __LINE__,
+ g2c_item->clause_index, rule_id);
return -1;
} else {
- ret = maat_compile_clause_find_literal(compile, g2c_item);
+ ret = maat_rule_clause_find_literal(rule, g2c_item);
if (0 == ret) {
- log_fatal(logger, MODULE_COMPILE,
- "[%s:%d]compile:%lld clause(index:%d) has no vtable_id:%d's "
+ log_fatal(logger, MODULE_RULE,
+ "[%s:%d]rule:%lld clause(index:%d) has no vtable_id:%d's "
"literal, can't be removed", __FUNCTION__, __LINE__,
- compile->compile_id, g2c_item->clause_index, g2c_item->vtable_id);
+ rule->rule_id, g2c_item->clause_index, g2c_item->vtable_id);
return -1;
}
- /* compile found in updating hash, it can be modified directly */
- maat_compile_clause_remove_literal(compile, g2c_item);
- if (0 == compile->actual_clause_num && NULL == compile->user_data) {
- rcu_hash_del(hash_tbl, (char *)&compile_id, sizeof(long long));
+ /* rule found in updating hash, it can be modified directly */
+ maat_rule_clause_remove_literal(rule, g2c_item);
+ if (0 == rule->actual_clause_num && NULL == rule->user_data) {
+ rcu_hash_del(hash_tbl, (char *)&rule_id, sizeof(long long));
}
}
} else {
//find in effetive hash
- compile = rcu_hash_find(hash_tbl, (char *)&compile_id, sizeof(long long));
- if (compile != NULL) {
- ret = maat_compile_clause_find_literal(compile, g2c_item);
+ rule = rcu_hash_find(hash_tbl, (char *)&rule_id, sizeof(long long));
+ if (rule != NULL) {
+ ret = maat_rule_clause_find_literal(rule, g2c_item);
if (0 == ret) {
- log_fatal(logger, MODULE_COMPILE,
- "[%s:%d]compile:%lld clause(index:%d) has no vtable_id:%d's "
+ log_fatal(logger, MODULE_RULE,
+ "[%s:%d]rule:%lld clause(index:%d) has no vtable_id:%d's "
"literal, can't be removed", __FUNCTION__, __LINE__,
- compile->compile_id, g2c_item->clause_index, g2c_item->vtable_id);
+ rule->rule_id, g2c_item->clause_index, g2c_item->vtable_id);
return -1;
}
/*******************************************************************
- compile found in effective hash, which means
+ rule found in effective hash, which means
- 1. rcu_hash_add(hash_tbl, compile) ==> finished
+ 1. rcu_hash_add(hash_tbl, rule) ==> finished
2. rcu_hash_commit(hash_tbl) ==> finished
can only be deleted but not modified
before delete it, we need to make a copy for further use
*********************************************************************/
- struct maat_compile *copy_compile = maat_compile_clone(compile, 1);
- assert(copy_compile != NULL);
+ struct maat_rule *copy_rule = maat_rule_clone(rule, 1);
+ assert(copy_rule != NULL);
- /* delete compile from rcu hash */
- rcu_hash_del(hash_tbl, (char *)&compile_id, sizeof(long long));
- maat_compile_clause_remove_literal(copy_compile, g2c_item);
+ /* delete rule from rcu hash */
+ rcu_hash_del(hash_tbl, (char *)&rule_id, sizeof(long long));
+ maat_rule_clause_remove_literal(copy_rule, g2c_item);
- if (0 == copy_compile->actual_clause_num && NULL == copy_compile->user_data) {
- maat_compile_free(copy_compile);
+ if (0 == copy_rule->actual_clause_num && NULL == copy_rule->user_data) {
+ maat_rule_free(copy_rule);
} else {
- rcu_hash_add(hash_tbl, (char *)&compile_id, sizeof(long long), copy_compile);
+ rcu_hash_add(hash_tbl, (char *)&rule_id, sizeof(long long), copy_rule);
}
} else {
- log_fatal(logger, MODULE_COMPILE,
- "[%s:%d] Remove clause(index:%d) from compile_id %lld failed,"
- "compile is not existed.", __FUNCTION__, __LINE__,
- g2c_item->clause_index, compile_id);
+ log_fatal(logger, MODULE_RULE,
+ "[%s:%d] Remove clause(index:%d) from rule_id %lld failed,"
+ "rule is not existed.", __FUNCTION__, __LINE__,
+ g2c_item->clause_index, rule_id);
return -1;
}
}
@@ -1420,37 +1420,37 @@ static int maat_remove_group_from_compile(struct rcu_hash_table *hash_tbl,
return 0;
}
-struct compile_state *compile_state_new(void)
+struct rule_state *rule_state_new(void)
{
- struct compile_state *compile_state = ALLOC(struct compile_state, 1);
+ struct rule_state *rule_state = ALLOC(struct rule_state, 1);
- utarray_new(compile_state->internal_hit_paths, &ut_hit_path_icd);
- utarray_new(compile_state->all_hit_clauses, &ut_clause_id_icd);
- utarray_new(compile_state->this_scan_hit_clauses, &ut_clause_id_icd);
- utarray_new(compile_state->this_scan_hit_not_clauses, &ut_clause_id_icd);
- utarray_new(compile_state->exclude_not_clauses, &ut_clause_id_icd);
- utarray_new(compile_state->direct_hit_groups, &ut_maat_hit_group_icd);
- utarray_new(compile_state->indirect_hit_groups, &ut_maat_hit_group_icd);
- utarray_new(compile_state->last_hit_groups, &ut_maat_hit_group_icd);
- utarray_new(compile_state->hit_compile_table_ids, &ut_hit_compile_table_id_icd);
- compile_state->hit_not_tbl_groups = NULL;
+ utarray_new(rule_state->internal_hit_paths, &ut_hit_path_icd);
+ utarray_new(rule_state->all_hit_clauses, &ut_clause_id_icd);
+ utarray_new(rule_state->this_scan_hit_clauses, &ut_clause_id_icd);
+ utarray_new(rule_state->this_scan_hit_not_clauses, &ut_clause_id_icd);
+ utarray_new(rule_state->exclude_not_clauses, &ut_clause_id_icd);
+ utarray_new(rule_state->direct_hit_groups, &ut_maat_hit_group_icd);
+ utarray_new(rule_state->indirect_hit_groups, &ut_maat_hit_group_icd);
+ utarray_new(rule_state->last_hit_groups, &ut_maat_hit_group_icd);
+ utarray_new(rule_state->hit_rule_table_ids, &ut_hit_rule_table_id_icd);
+ rule_state->hit_not_tbl_groups = NULL;
- return compile_state;
+ return rule_state;
}
static long long
-compile_state_hit_not_tbl_groups_free(struct compile_state *compile_state)
+rule_state_hit_not_tbl_groups_free(struct rule_state *rule_state)
{
- if (NULL == compile_state) {
+ if (NULL == rule_state) {
return 0;
}
long long free_bytes = 0;
struct table_group *tbl_group = NULL, *tmp_tbl_group = NULL;
- HASH_ITER(hh, compile_state->hit_not_tbl_groups, tbl_group, tmp_tbl_group) {
+ HASH_ITER(hh, rule_state->hit_not_tbl_groups, tbl_group, tmp_tbl_group) {
free_bytes +=
(sizeof(tbl_group) + utarray_len(tbl_group->group_ids) * sizeof(long long));
- HASH_DEL(compile_state->hit_not_tbl_groups, tbl_group);
+ HASH_DEL(rule_state->hit_not_tbl_groups, tbl_group);
if (tbl_group->group_ids != NULL) {
utarray_free(tbl_group->group_ids);
tbl_group->group_ids = NULL;
@@ -1461,118 +1461,118 @@ compile_state_hit_not_tbl_groups_free(struct compile_state *compile_state)
return free_bytes;
}
-void compile_state_reset(struct compile_state *compile_state)
+void rule_state_reset(struct rule_state *rule_state)
{
- if (NULL == compile_state) {
+ if (NULL == rule_state) {
return;
}
- compile_state->this_scan_not_logic = 0;
- compile_state->Nth_scan = 0;
- compile_state->compile_rt_version = 0;
+ rule_state->this_scan_not_logic = 0;
+ rule_state->Nth_scan = 0;
+ rule_state->rule_rt_version = 0;
- utarray_clear(compile_state->internal_hit_paths);
- utarray_clear(compile_state->all_hit_clauses);
- utarray_clear(compile_state->this_scan_hit_clauses);
- utarray_clear(compile_state->this_scan_hit_not_clauses);
- utarray_clear(compile_state->exclude_not_clauses);
- utarray_clear(compile_state->direct_hit_groups);
- utarray_clear(compile_state->indirect_hit_groups);
- utarray_clear(compile_state->last_hit_groups);
- utarray_clear(compile_state->hit_compile_table_ids);
+ utarray_clear(rule_state->internal_hit_paths);
+ utarray_clear(rule_state->all_hit_clauses);
+ utarray_clear(rule_state->this_scan_hit_clauses);
+ utarray_clear(rule_state->this_scan_hit_not_clauses);
+ utarray_clear(rule_state->exclude_not_clauses);
+ utarray_clear(rule_state->direct_hit_groups);
+ utarray_clear(rule_state->indirect_hit_groups);
+ utarray_clear(rule_state->last_hit_groups);
+ utarray_clear(rule_state->hit_rule_table_ids);
struct table_group *tbl_group = NULL, *tmp_tbl_group = NULL;
- HASH_ITER(hh, compile_state->hit_not_tbl_groups, tbl_group, tmp_tbl_group) {
+ HASH_ITER(hh, rule_state->hit_not_tbl_groups, tbl_group, tmp_tbl_group) {
utarray_clear(tbl_group->group_ids);
}
}
-void compile_state_free(struct compile_state *compile_state,
+void rule_state_free(struct rule_state *rule_state,
struct maat *maat_inst, int thread_id)
{
- if (NULL == compile_state) {
+ if (NULL == rule_state) {
return;
}
long long free_bytes = 0;
- if (compile_state->internal_hit_paths != NULL) {
- free_bytes += utarray_size(compile_state->internal_hit_paths) *
+ if (rule_state->internal_hit_paths != NULL) {
+ free_bytes += utarray_size(rule_state->internal_hit_paths) *
sizeof(struct internal_hit_path);
- utarray_free(compile_state->internal_hit_paths);
- compile_state->internal_hit_paths = NULL;
+ utarray_free(rule_state->internal_hit_paths);
+ rule_state->internal_hit_paths = NULL;
}
- if (compile_state->all_hit_clauses != NULL) {
- free_bytes += utarray_size(compile_state->all_hit_clauses) *
+ if (rule_state->all_hit_clauses != NULL) {
+ free_bytes += utarray_size(rule_state->all_hit_clauses) *
sizeof(long long);
- utarray_free(compile_state->all_hit_clauses);
- compile_state->all_hit_clauses = NULL;
+ utarray_free(rule_state->all_hit_clauses);
+ rule_state->all_hit_clauses = NULL;
}
- if (compile_state->this_scan_hit_clauses != NULL) {
- free_bytes += utarray_size(compile_state->this_scan_hit_clauses) *
+ if (rule_state->this_scan_hit_clauses != NULL) {
+ free_bytes += utarray_size(rule_state->this_scan_hit_clauses) *
sizeof(long long);
- utarray_free(compile_state->this_scan_hit_clauses);
- compile_state->this_scan_hit_clauses = NULL;
+ utarray_free(rule_state->this_scan_hit_clauses);
+ rule_state->this_scan_hit_clauses = NULL;
}
- if (compile_state->this_scan_hit_not_clauses != NULL) {
- free_bytes += utarray_size(compile_state->this_scan_hit_not_clauses) *
+ if (rule_state->this_scan_hit_not_clauses != NULL) {
+ free_bytes += utarray_size(rule_state->this_scan_hit_not_clauses) *
sizeof(long long);
- utarray_free(compile_state->this_scan_hit_not_clauses);
- compile_state->this_scan_hit_not_clauses = NULL;
+ utarray_free(rule_state->this_scan_hit_not_clauses);
+ rule_state->this_scan_hit_not_clauses = NULL;
}
- if (compile_state->exclude_not_clauses != NULL) {
- free_bytes += utarray_size(compile_state->exclude_not_clauses) *
+ if (rule_state->exclude_not_clauses != NULL) {
+ free_bytes += utarray_size(rule_state->exclude_not_clauses) *
sizeof(long long);
- utarray_free(compile_state->exclude_not_clauses);
- compile_state->exclude_not_clauses = NULL;
+ utarray_free(rule_state->exclude_not_clauses);
+ rule_state->exclude_not_clauses = NULL;
}
- if (compile_state->direct_hit_groups != NULL) {
- free_bytes += utarray_size(compile_state->direct_hit_groups) *
+ if (rule_state->direct_hit_groups != NULL) {
+ free_bytes += utarray_size(rule_state->direct_hit_groups) *
sizeof(struct maat_hit_group);
- utarray_free(compile_state->direct_hit_groups);
- compile_state->direct_hit_groups = NULL;
+ utarray_free(rule_state->direct_hit_groups);
+ rule_state->direct_hit_groups = NULL;
}
- if (compile_state->indirect_hit_groups != NULL) {
- free_bytes += utarray_size(compile_state->indirect_hit_groups) *
+ if (rule_state->indirect_hit_groups != NULL) {
+ free_bytes += utarray_size(rule_state->indirect_hit_groups) *
sizeof(struct maat_hit_group);
- utarray_free(compile_state->indirect_hit_groups);
- compile_state->indirect_hit_groups = NULL;
+ utarray_free(rule_state->indirect_hit_groups);
+ rule_state->indirect_hit_groups = NULL;
}
- if (compile_state->last_hit_groups != NULL) {
- free_bytes += utarray_size(compile_state->last_hit_groups) *
+ if (rule_state->last_hit_groups != NULL) {
+ free_bytes += utarray_size(rule_state->last_hit_groups) *
sizeof(struct maat_hit_group);
- utarray_free(compile_state->last_hit_groups);
- compile_state->last_hit_groups = NULL;
+ utarray_free(rule_state->last_hit_groups);
+ rule_state->last_hit_groups = NULL;
}
- if (compile_state->hit_compile_table_ids != NULL) {
- free_bytes += utarray_size(compile_state->hit_compile_table_ids) *
- sizeof(struct compile2table_id);
- utarray_free(compile_state->hit_compile_table_ids);
- compile_state->hit_compile_table_ids = NULL;
+ if (rule_state->hit_rule_table_ids != NULL) {
+ free_bytes += utarray_size(rule_state->hit_rule_table_ids) *
+ sizeof(struct rule2table_id);
+ utarray_free(rule_state->hit_rule_table_ids);
+ rule_state->hit_rule_table_ids = NULL;
}
- free_bytes += compile_state_hit_not_tbl_groups_free(compile_state);
+ free_bytes += rule_state_hit_not_tbl_groups_free(rule_state);
- FREE(compile_state);
+ FREE(rule_state);
- free_bytes += sizeof(struct compile_state);
+ free_bytes += sizeof(struct rule_state);
alignment_int64_array_add(maat_inst->stat->maat_state_free_bytes,
thread_id, free_bytes);
}
static void
-compile_state_add_internal_hit_path(struct compile_state *compile_state,
+rule_state_add_internal_hit_path(struct rule_state *rule_state,
long long item_id, long long group_id,
int vtable_id, int NOT_flag, int Nth_scan)
{
- if (NULL == compile_state) {
+ if (NULL == rule_state) {
return;
}
@@ -1583,14 +1583,14 @@ compile_state_add_internal_hit_path(struct compile_state *compile_state,
new_path.vtable_id = vtable_id;
new_path.NOT_flag = NOT_flag;
- utarray_push_back(compile_state->internal_hit_paths, &new_path);
+ utarray_push_back(rule_state->internal_hit_paths, &new_path);
}
-static int maat_compile_has_clause_query_key(struct maat_compile *compile,
+static int maat_rule_has_clause_query_key(struct maat_rule *rule,
struct clause_query_key *key)
{
for (int i = 0; i < MAX_ITEMS_PER_BOOL_EXPR; i++) {
- struct compile_clause *clause = compile->clauses+i;
+ struct rule_clause *clause = rule->clauses+i;
if(!clause->in_use) {
continue;
}
@@ -1619,15 +1619,15 @@ static int maat_compile_has_clause_query_key(struct maat_compile *compile,
}
static size_t
-maat_compile_get_hit_clause_index(struct maat_compile *compile,
+maat_rule_get_hit_clause_index(struct maat_rule *rule,
int vtable_id, long long hit_group_id,
int *clause_idx_array, size_t array_size)
{
size_t hit_clause_cnt = 0;
- struct compile_clause *tmp_clause = NULL;
+ struct rule_clause *tmp_clause = NULL;
for (int i = 0; i < MAX_ITEMS_PER_BOOL_EXPR; i++) {
- tmp_clause = &compile->clauses[i];
+ tmp_clause = &rule->clauses[i];
if (!tmp_clause->in_use) {
continue;
}
@@ -1653,7 +1653,7 @@ maat_compile_get_hit_clause_index(struct maat_compile *compile,
}
static int
-maat_compile_is_hit_path_existed(const struct maat_hit_path *hit_paths,
+maat_rule_is_hit_path_existed(const struct maat_hit_path *hit_paths,
size_t n_path, const struct maat_hit_path *find)
{
for (size_t i = 0; i < n_path; i++) {
@@ -1665,10 +1665,10 @@ maat_compile_is_hit_path_existed(const struct maat_hit_path *hit_paths,
return 0;
}
-void populate_hit_path_with_compile(struct maat_hit_path *hit_path_array,
+void populate_hit_path_with_rule(struct maat_hit_path *hit_path_array,
size_t array_idx, size_t n_hit_path,
size_t *n_new_hit_path,
- struct maat_compile *compile)
+ struct maat_rule *rule)
{
size_t i = 0;
size_t idx = array_idx;
@@ -1681,11 +1681,11 @@ void populate_hit_path_with_compile(struct maat_hit_path *hit_path_array,
}
struct maat_hit_path tmp_path;
- if (hit_path_array[idx].compile_id < 0) {
- hit_path_array[idx].compile_id = compile->compile_id;
- // find out which clause in compile hit
+ if (hit_path_array[idx].rule_id < 0) {
+ hit_path_array[idx].rule_id = rule->rule_id;
+ // find out which clause in rule hit
n_clause_index =
- maat_compile_get_hit_clause_index(compile, hit_path_array[idx].vtable_id,
+ maat_rule_get_hit_clause_index(rule, hit_path_array[idx].vtable_id,
hit_path_array[idx].top_group_id,
clause_index_array,
MAX_ITEMS_PER_BOOL_EXPR);
@@ -1699,14 +1699,14 @@ void populate_hit_path_with_compile(struct maat_hit_path *hit_path_array,
}
}
} else {
- // means same clause_query_id hit more than one compile_id
+ // means same clause_query_id hit more than one rule_id
tmp_path = hit_path_array[idx];
- tmp_path.compile_id = compile->compile_id;
- if (!maat_compile_is_hit_path_existed(hit_path_array, n_hit_path + new_hit_path_cnt, &tmp_path)) {
+ tmp_path.rule_id = rule->rule_id;
+ if (!maat_rule_is_hit_path_existed(hit_path_array, n_hit_path + new_hit_path_cnt, &tmp_path)) {
hit_path_array[n_hit_path + new_hit_path_cnt] = tmp_path;
new_hit_path_cnt++;
n_clause_index =
- maat_compile_get_hit_clause_index(compile, tmp_path.vtable_id, tmp_path.top_group_id,
+ maat_rule_get_hit_clause_index(rule, tmp_path.vtable_id, tmp_path.top_group_id,
clause_index_array, MAX_ITEMS_PER_BOOL_EXPR);
hit_path_array[n_hit_path + new_hit_path_cnt - 1].clause_index = clause_index_array[0];
if (n_clause_index > 1) {
@@ -1723,33 +1723,33 @@ void populate_hit_path_with_compile(struct maat_hit_path *hit_path_array,
*n_new_hit_path = new_hit_path_cnt;
}
-size_t compile_runtime_get_hit_paths(struct compile_runtime *compile_rt, int thread_id,
- struct compile_state *compile_state,
+size_t rule_runtime_get_hit_paths(struct rule_runtime *rule_rt, int thread_id,
+ struct rule_state *rule_state,
struct maat_hit_path *hit_path_array,
size_t array_size, size_t n_hit_path)
{
- /* assign hit_path_array[].compile_id */
+ /* assign hit_path_array[].rule_id */
size_t n_new_hit_path = 0;
- struct maat_compile *compile = NULL;
+ struct maat_rule *rule = NULL;
struct clause_query_key key = {0, 0, 0};
- struct bool_expr_match *expr_match = compile_rt->expr_match_buff +
- (thread_id * MAX_HIT_COMPILE_NUM);
+ struct bool_expr_match *expr_match = rule_rt->expr_match_buff +
+ (thread_id * MAX_HIT_RULE_NUM);
assert(thread_id >= 0);
- if (compile_state->compile_rt_version != compile_rt->version) {
+ if (rule_state->rule_rt_version != rule_rt->version) {
return 0;
}
int bool_match_ret =
- bool_matcher_match(compile_rt->bm,
- (unsigned long long *)utarray_eltptr(compile_state->all_hit_clauses, 0),
- utarray_len(compile_state->all_hit_clauses), expr_match, MAX_HIT_COMPILE_NUM);
+ bool_matcher_match(rule_rt->bm,
+ (unsigned long long *)utarray_eltptr(rule_state->all_hit_clauses, 0),
+ utarray_len(rule_state->all_hit_clauses), expr_match, MAX_HIT_RULE_NUM);
for (int idx = 0; idx < bool_match_ret; idx++) {
- compile = (struct maat_compile *)expr_match[idx].user_tag;
- assert(compile->magic_num == MAAT_COMPILE_MAGIC);
- assert((unsigned long long)compile->compile_id == expr_match[idx].expr_id);
- if (0 == compile->actual_clause_num || NULL == compile->user_data) {
+ rule = (struct maat_rule *)expr_match[idx].user_tag;
+ assert(rule->magic_num == MAAT_RULE_MAGIC);
+ assert((unsigned long long)rule->rule_id == expr_match[idx].expr_id);
+ if (0 == rule->actual_clause_num || NULL == rule->user_data) {
continue;
}
@@ -1762,9 +1762,9 @@ size_t compile_runtime_get_hit_paths(struct compile_runtime *compile_rt, int thr
key.vtable_id = hit_path_array[j].vtable_id;
key.not_flag = hit_path_array[j].NOT_flag;
- if (maat_compile_has_clause_query_key(compile, &key)) {
- populate_hit_path_with_compile(hit_path_array, j, n_hit_path,
- &n_new_hit_path, compile);
+ if (maat_rule_has_clause_query_key(rule, &key)) {
+ populate_hit_path_with_rule(hit_path_array, j, n_hit_path,
+ &n_new_hit_path, rule);
}
}
}
@@ -1773,11 +1773,11 @@ size_t compile_runtime_get_hit_paths(struct compile_runtime *compile_rt, int thr
}
static void
-compile_state_add_direct_hit_groups(struct compile_state *compile_state,
+rule_state_add_direct_hit_groups(struct rule_state *rule_state,
struct maat_item *hit_items,
size_t n_hit_items, int vtable_id)
{
- if (NULL == compile_state || NULL == hit_items) {
+ if (NULL == rule_state || NULL == hit_items) {
return;
}
@@ -1786,16 +1786,16 @@ compile_state_add_direct_hit_groups(struct compile_state *compile_state,
hit_group.item_id = hit_items[i].item_id;
hit_group.group_id = hit_items[i].group_id;
hit_group.vtable_id = vtable_id;
- utarray_push_back(compile_state->direct_hit_groups, &hit_group);
+ utarray_push_back(rule_state->direct_hit_groups, &hit_group);
}
}
static void
-compile_state_add_indirect_hit_groups(struct compile_state *compile_state,
+rule_state_add_indirect_hit_groups(struct rule_state *rule_state,
long long *group_ids,
size_t n_group_ids, int vtable_id)
{
- if (NULL == compile_state || NULL == group_ids) {
+ if (NULL == rule_state || NULL == group_ids) {
return;
}
@@ -1804,117 +1804,117 @@ compile_state_add_indirect_hit_groups(struct compile_state *compile_state,
hit_group.item_id = 0;
hit_group.group_id = group_ids[i];
hit_group.vtable_id = vtable_id;
- utarray_push_back(compile_state->indirect_hit_groups, &hit_group);
+ utarray_push_back(rule_state->indirect_hit_groups, &hit_group);
}
}
static void
-compile_state_add_hit_clauses(struct compile_state *compile_state,
+rule_state_add_hit_clauses(struct rule_state *rule_state,
UT_array *clause_id_array)
{
size_t i = 0;
long long *clause_id = NULL;
- size_t new_clause_idx = utarray_len(compile_state->this_scan_hit_clauses);
+ size_t new_clause_idx = utarray_len(rule_state->this_scan_hit_clauses);
for (i = 0; i < utarray_len(clause_id_array); i++) {
clause_id = (long long *)utarray_eltptr(clause_id_array, i);
- if (utarray_find(compile_state->all_hit_clauses, clause_id, compare_clause_id)) {
+ if (utarray_find(rule_state->all_hit_clauses, clause_id, compare_clause_id)) {
continue;
}
- utarray_push_back(compile_state->this_scan_hit_clauses, clause_id);
+ utarray_push_back(rule_state->this_scan_hit_clauses, clause_id);
}
- if ((utarray_len(compile_state->this_scan_hit_clauses) - new_clause_idx) > 0) {
- utarray_reserve(compile_state->all_hit_clauses,
- utarray_len(compile_state->this_scan_hit_clauses) - new_clause_idx);
+ if ((utarray_len(rule_state->this_scan_hit_clauses) - new_clause_idx) > 0) {
+ utarray_reserve(rule_state->all_hit_clauses,
+ utarray_len(rule_state->this_scan_hit_clauses) - new_clause_idx);
- for (i = new_clause_idx; i < utarray_len(compile_state->this_scan_hit_clauses); i++) {
- clause_id = (long long *)utarray_eltptr(compile_state->this_scan_hit_clauses, i);
- utarray_push_back(compile_state->all_hit_clauses, clause_id);
+ for (i = new_clause_idx; i < utarray_len(rule_state->this_scan_hit_clauses); i++) {
+ clause_id = (long long *)utarray_eltptr(rule_state->this_scan_hit_clauses, i);
+ utarray_push_back(rule_state->all_hit_clauses, clause_id);
}
- utarray_sort(compile_state->all_hit_clauses, compare_clause_id);
+ utarray_sort(rule_state->all_hit_clauses, compare_clause_id);
}
}
static void
-compile_state_add_exclude_not_clauses(struct compile_state *compile_state,
+rule_state_add_exclude_not_clauses(struct rule_state *rule_state,
UT_array *clause_id_array)
{
for (size_t i = 0; i < utarray_len(clause_id_array); i++) {
long long *clause_id = (long long *)utarray_eltptr(clause_id_array, i);
- if (utarray_find(compile_state->exclude_not_clauses, clause_id,
+ if (utarray_find(rule_state->exclude_not_clauses, clause_id,
compare_clause_id)) {
continue;
}
- utarray_push_back(compile_state->exclude_not_clauses, clause_id);
+ utarray_push_back(rule_state->exclude_not_clauses, clause_id);
}
- utarray_sort(compile_state->exclude_not_clauses, compare_clause_id);
+ utarray_sort(rule_state->exclude_not_clauses, compare_clause_id);
}
static void
-compile_state_add_hit_not_clauses(struct compile_state *compile_state,
+rule_state_add_hit_not_clauses(struct rule_state *rule_state,
UT_array *clause_id_array)
{
size_t i = 0;
long long *clause_id = NULL;
- size_t new_clause_idx = utarray_len(compile_state->this_scan_hit_not_clauses);
+ size_t new_clause_idx = utarray_len(rule_state->this_scan_hit_not_clauses);
for (i = 0; i < utarray_len(clause_id_array); i++) {
clause_id = (long long *)utarray_eltptr(clause_id_array, i);
- if (utarray_find(compile_state->all_hit_clauses, clause_id, compare_clause_id)) {
+ if (utarray_find(rule_state->all_hit_clauses, clause_id, compare_clause_id)) {
continue;
}
- if (utarray_find(compile_state->exclude_not_clauses, clause_id, compare_clause_id)) {
+ if (utarray_find(rule_state->exclude_not_clauses, clause_id, compare_clause_id)) {
continue;
}
- utarray_push_back(compile_state->this_scan_hit_not_clauses, clause_id);
+ utarray_push_back(rule_state->this_scan_hit_not_clauses, clause_id);
}
- if ((utarray_len(compile_state->this_scan_hit_not_clauses) - new_clause_idx) > 0) {
- utarray_reserve(compile_state->all_hit_clauses,
- utarray_len(compile_state->this_scan_hit_not_clauses) - new_clause_idx);
+ if ((utarray_len(rule_state->this_scan_hit_not_clauses) - new_clause_idx) > 0) {
+ utarray_reserve(rule_state->all_hit_clauses,
+ utarray_len(rule_state->this_scan_hit_not_clauses) - new_clause_idx);
- for (i = new_clause_idx; i < utarray_len(compile_state->this_scan_hit_not_clauses); i++) {
- clause_id = (long long *)utarray_eltptr(compile_state->this_scan_hit_not_clauses, i);
- utarray_push_back(compile_state->all_hit_clauses, clause_id);
+ for (i = new_clause_idx; i < utarray_len(rule_state->this_scan_hit_not_clauses); i++) {
+ clause_id = (long long *)utarray_eltptr(rule_state->this_scan_hit_not_clauses, i);
+ utarray_push_back(rule_state->all_hit_clauses, clause_id);
}
- utarray_sort(compile_state->all_hit_clauses, compare_clause_id);
+ utarray_sort(rule_state->all_hit_clauses, compare_clause_id);
}
}
static void
-compile_state_update_hit_clauses(struct compile_state *compile_state,
- struct compile_runtime *compile_rt,
+rule_state_update_hit_clauses(struct rule_state *rule_state,
+ struct rule_runtime *rule_rt,
long long group_id, int vtable_id)
{
- if (NULL == compile_state || NULL == compile_rt) {
+ if (NULL == rule_state || NULL == rule_rt) {
return;
}
struct clause_query_key key = {group_id, vtable_id, 0};
struct clause_id_kv *clause_id_kv = NULL;
- HASH_FIND(hh, compile_rt->clause_id_kv_hash, &key, sizeof(key), clause_id_kv);
+ HASH_FIND(hh, rule_rt->clause_id_kv_hash, &key, sizeof(key), clause_id_kv);
if (clause_id_kv != NULL) {
- compile_state_add_hit_clauses(compile_state, clause_id_kv->clause_ids);
+ rule_state_add_hit_clauses(rule_state, clause_id_kv->clause_ids);
}
key.not_flag = 1;
- HASH_FIND(hh, compile_rt->not_clause_id_kv_hash, &key, sizeof(key), clause_id_kv);
+ HASH_FIND(hh, rule_rt->not_clause_id_kv_hash, &key, sizeof(key), clause_id_kv);
if (clause_id_kv != NULL) {
- compile_state_add_exclude_not_clauses(compile_state, clause_id_kv->clause_ids);
+ rule_state_add_exclude_not_clauses(rule_state, clause_id_kv->clause_ids);
}
}
static void
-compile_state_cache_hit_not_groups(struct compile_state *compile_state,
- struct compile_runtime *compile_rt,
+rule_state_cache_hit_not_groups(struct rule_state *rule_state,
+ struct rule_runtime *rule_rt,
long long *hit_group_ids,
size_t n_hit_group_id, int vtable_id)
{
- if (NULL == compile_state || NULL == compile_rt) {
+ if (NULL == rule_state || NULL == rule_rt) {
return;
}
@@ -1923,7 +1923,7 @@ compile_state_cache_hit_not_groups(struct compile_state *compile_state,
}
struct table_group *tbl_group = NULL;
- HASH_FIND(hh, compile_state->hit_not_tbl_groups, &vtable_id, sizeof(int), tbl_group);
+ HASH_FIND(hh, rule_state->hit_not_tbl_groups, &vtable_id, sizeof(int), tbl_group);
if (tbl_group != NULL) {
for (size_t i = 0; i < n_hit_group_id; i++) {
long long *group_id = (long long *)utarray_find(tbl_group->group_ids,
@@ -1938,7 +1938,7 @@ compile_state_cache_hit_not_groups(struct compile_state *compile_state,
}
struct clause_id_kv *clause_id_kv = NULL, *tmp_clause_id_kv = NULL;
- HASH_ITER(hh, compile_rt->not_clause_id_kv_hash, clause_id_kv, tmp_clause_id_kv) {
+ HASH_ITER(hh, rule_rt->not_clause_id_kv_hash, clause_id_kv, tmp_clause_id_kv) {
if (clause_id_kv->key.vtable_id != vtable_id) {
continue;
}
@@ -1953,8 +1953,8 @@ compile_state_cache_hit_not_groups(struct compile_state *compile_state,
if (NULL == tbl_group) {
tbl_group = ALLOC(struct table_group, 1);
tbl_group->vtable_id = vtable_id;
- utarray_new(tbl_group->group_ids, &ut_compile_group_id_icd);
- HASH_ADD_INT(compile_state->hit_not_tbl_groups, vtable_id, tbl_group);
+ utarray_new(tbl_group->group_ids, &ut_rule_group_id_icd);
+ HASH_ADD_INT(rule_state->hit_not_tbl_groups, vtable_id, tbl_group);
}
if (!utarray_find(tbl_group->group_ids, &(clause_id_kv->key.group_id),
@@ -1968,13 +1968,13 @@ compile_state_cache_hit_not_groups(struct compile_state *compile_state,
}
}
-int compile_state_get_compile_table_id(struct compile_state *compile_state,
- long long compile_id)
+int rule_state_get_rule_table_id(struct rule_state *rule_state,
+ long long rule_id)
{
- struct compile2table_id *tmp = NULL;
+ struct rule2table_id *tmp = NULL;
- tmp = utarray_find(compile_state->hit_compile_table_ids, &compile_id,
- compare_compile_id);
+ tmp = utarray_find(rule_state->hit_rule_table_ids, &rule_id,
+ compare_rule_id);
if (NULL == tmp) {
return -1;
}
@@ -1983,195 +1983,195 @@ int compile_state_get_compile_table_id(struct compile_state *compile_state,
}
static int
-compile_runtime_add_compile(struct compile_runtime *compile_rt,
- struct compile_schema *schema,
- long long compile_id, const char *table_name,
+rule_runtime_add_rule(struct rule_runtime *rule_rt,
+ struct rule_schema *schema,
+ long long rule_id, const char *table_name,
const char *line, struct log_handle *logger)
{
- struct maat_compile *compile = NULL;
- struct compile_item *compile_item = compile_item_new(line, schema, table_name,
- compile_rt->logger);
- if (NULL == compile_item) {
+ struct maat_rule *rule = NULL;
+ struct rule_item *rule_item = rule_item_new(line, schema, table_name,
+ rule_rt->logger);
+ if (NULL == rule_item) {
return -1;
}
int table_id = table_manager_get_table_id(schema->ref_tbl_mgr, table_name);
if (table_id < 0) {
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d]table_name:%s has invalid table_id:%d, drop line:%s",
__FUNCTION__, __LINE__, table_name, table_id, line);
return -1;
}
- int updating_flag = rcu_hash_is_updating(compile_rt->cfg_hash);
+ int updating_flag = rcu_hash_is_updating(rule_rt->cfg_hash);
if (1 == updating_flag) {
- compile = rcu_updating_hash_find(compile_rt->cfg_hash, (char *)&compile_id,
+ rule = rcu_updating_hash_find(rule_rt->cfg_hash, (char *)&rule_id,
sizeof(long long));
- if (compile != NULL) {
+ if (rule != NULL) {
/****************************************************************
- compile found in updating hash(added by group2compile runtime), which means
+ rule found in updating hash(added by group2rule runtime), which means
- 1. rcu_hash_add(htable, compile) ==> finished
+ 1. rcu_hash_add(htable, rule) ==> finished
2. rcu_hash_commit(htable) ==> undo
because it's in updating hash, we can modify it directly
******************************************************************/
- /* compile has group2compile_table info, so set compile_table info */
- maat_compile_set(compile, table_id, compile_item->declared_clause_num, compile_item);
+ /* rule has group2rule_table info, so set rule_table info */
+ maat_rule_set(rule, table_id, rule_item->declared_clause_num, rule_item);
} else {
- // compile neither in effective hash nor in updating hash
- compile = maat_compile_new(compile_item->compile_id);
- assert(compile != NULL);
- maat_compile_set(compile, table_id, compile_item->declared_clause_num, compile_item);
- rcu_hash_add(compile_rt->cfg_hash, (char *)&compile_id, sizeof(long long), compile);
+ // rule neither in effective hash nor in updating hash
+ rule = maat_rule_new(rule_item->rule_id);
+ assert(rule != NULL);
+ maat_rule_set(rule, table_id, rule_item->declared_clause_num, rule_item);
+ rcu_hash_add(rule_rt->cfg_hash, (char *)&rule_id, sizeof(long long), rule);
}
} else {
- compile = rcu_hash_find(compile_rt->cfg_hash, (char *)&compile_id, sizeof(long long));
- if (compile != NULL) {
+ rule = rcu_hash_find(rule_rt->cfg_hash, (char *)&rule_id, sizeof(long long));
+ if (rule != NULL) {
/********************************************************************************
- compile found in effective hash(added by group2compile runtime), which means
+ rule found in effective hash(added by group2rule runtime), which means
- 1. rcu_hash_add(htable, compile) ==> finished
+ 1. rcu_hash_add(htable, rule) ==> finished
2. rcu_hash_commit(htable) ==> finished
can only be deleted but not modified
before delete it, we need to make a copy for further use
***********************************************************************************/
- struct maat_compile *copy_compile = maat_compile_clone(compile, 0);
- assert(copy_compile != NULL);
+ struct maat_rule *copy_rule = maat_rule_clone(rule, 0);
+ assert(copy_rule != NULL);
- /* delete compile from rcu hash */
- rcu_hash_del(compile_rt->cfg_hash, (char *)&compile_id, sizeof(long long));
+ /* delete rule from rcu hash */
+ rcu_hash_del(rule_rt->cfg_hash, (char *)&rule_id, sizeof(long long));
- /* copy_compile has group2compile_table info, so set compile_table info */
- maat_compile_set(copy_compile, table_id, compile_item->declared_clause_num, compile_item);
- /* add copy_compile to rcu hash */
- rcu_hash_add(compile_rt->cfg_hash, (char *)&compile_id, sizeof(long long), copy_compile);
+ /* copy_rule has group2rule_table info, so set rule_table info */
+ maat_rule_set(copy_rule, table_id, rule_item->declared_clause_num, rule_item);
+ /* add copy_rule to rcu hash */
+ rcu_hash_add(rule_rt->cfg_hash, (char *)&rule_id, sizeof(long long), copy_rule);
} else {
- compile = maat_compile_new(compile_item->compile_id);
- assert(compile != NULL);
- maat_compile_set(compile, table_id, compile_item->declared_clause_num, compile_item);
- rcu_hash_add(compile_rt->cfg_hash, (char *)&compile_id, sizeof(long long), compile);
+ rule = maat_rule_new(rule_item->rule_id);
+ assert(rule != NULL);
+ maat_rule_set(rule, table_id, rule_item->declared_clause_num, rule_item);
+ rcu_hash_add(rule_rt->cfg_hash, (char *)&rule_id, sizeof(long long), rule);
}
}
return 0;
}
-static void garbage_compile_item_free(void *data, void *arg)
+static void garbage_rule_item_free(void *data, void *arg)
{
if (NULL == data) {
return;
}
- struct compile_item *compile_item = (struct compile_item *)data;
+ struct rule_item *rule_item = (struct rule_item *)data;
- compile_item_free(compile_item);
+ rule_item_free(rule_item);
}
-static void compile_runtime_del_compile(struct compile_runtime *compile_rt,
- long long compile_id)
+static void rule_runtime_del_rule(struct rule_runtime *rule_rt,
+ long long rule_id)
{
- struct maat_compile *compile = NULL;
+ struct maat_rule *rule = NULL;
- int updating_flag = rcu_hash_is_updating(compile_rt->cfg_hash);
+ int updating_flag = rcu_hash_is_updating(rule_rt->cfg_hash);
if (1 == updating_flag) {
// find in updating hash
- compile = rcu_updating_hash_find(compile_rt->cfg_hash, (char *)&compile_id,
+ rule = rcu_updating_hash_find(rule_rt->cfg_hash, (char *)&rule_id,
sizeof(long long));
- if (compile != NULL) {
+ if (rule != NULL) {
/****************************************************************
- compile found in updating hash, which means
+ rule found in updating hash, which means
- 1. rcu_hash_del(htable, compile) ==> finished
+ 1. rcu_hash_del(htable, rule) ==> finished
2. rcu_hash_commit(htable) ==> undo
because it's in updating hash, we can modify it directly
******************************************************************/
- if (compile->user_data != NULL) {
- maat_garbage_bagging(compile_rt->ref_garbage_bin, compile->user_data, NULL,
- garbage_compile_item_free);
- compile->user_data = NULL;
+ if (rule->user_data != NULL) {
+ maat_garbage_bagging(rule_rt->ref_garbage_bin, rule->user_data, NULL,
+ garbage_rule_item_free);
+ rule->user_data = NULL;
}
- if (0 == compile->actual_clause_num) {
- rcu_hash_del(compile_rt->cfg_hash, (char *)&compile_id, sizeof(long long));
+ if (0 == rule->actual_clause_num) {
+ rcu_hash_del(rule_rt->cfg_hash, (char *)&rule_id, sizeof(long long));
}
}
} else {
// find in effective hash
- compile = rcu_hash_find(compile_rt->cfg_hash, (char *)&compile_id, sizeof(long long));
- if (compile != NULL) {
+ rule = rcu_hash_find(rule_rt->cfg_hash, (char *)&rule_id, sizeof(long long));
+ if (rule != NULL) {
/*******************************************************************
- compile found in effective hash, which means
+ rule found in effective hash, which means
- 1. rcu_hash_add(htable, compile) ==> finished
+ 1. rcu_hash_add(htable, rule) ==> finished
2. rcu_hash_commit(htable) ==> finished
can only be deleted but not modified
before delete it, we need to make a copy for further use
*********************************************************************/
- struct maat_compile *copy_compile = maat_compile_clone(compile, 0);
- assert(copy_compile != NULL);
+ struct maat_rule *copy_rule = maat_rule_clone(rule, 0);
+ assert(copy_rule != NULL);
- /* delete compile from rcu hash */
- rcu_hash_del(compile_rt->cfg_hash, (char *)&compile_id, sizeof(long long));
+ /* delete rule from rcu hash */
+ rcu_hash_del(rule_rt->cfg_hash, (char *)&rule_id, sizeof(long long));
- if (0 == copy_compile->actual_clause_num) {
- maat_compile_free(copy_compile);
+ if (0 == copy_rule->actual_clause_num) {
+ maat_rule_free(copy_rule);
} else {
- rcu_hash_add(compile_rt->cfg_hash, (char *)&compile_id,
- sizeof(long long), copy_compile);
+ rcu_hash_add(rule_rt->cfg_hash, (char *)&rule_id,
+ sizeof(long long), copy_rule);
}
}
}
}
-int compile_runtime_update(void *compile_runtime, void *compile_schema,
+int rule_runtime_update(void *rule_runtime, void *rule_schema,
const char *table_name, const char *line,
int valid_column)
{
- if (NULL == compile_runtime || NULL == compile_schema || NULL == line) {
+ if (NULL == rule_runtime || NULL == rule_schema || NULL == line) {
return -1;
}
- struct compile_schema *schema = (struct compile_schema *)compile_schema;
- struct compile_runtime *compile_rt = (struct compile_runtime *)compile_runtime;
+ struct rule_schema *schema = (struct rule_schema *)rule_schema;
+ struct rule_runtime *rule_rt = (struct rule_runtime *)rule_runtime;
int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) {
- log_fatal(compile_rt->logger, MODULE_COMPILE,
- "[%s:%d] compile table:<%s> has no is_valid(column seq:%d)"
+ log_fatal(rule_rt->logger, MODULE_RULE,
+ "[%s:%d] rule table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line);
- compile_rt->update_err_cnt++;
+ rule_rt->update_err_cnt++;
return -1;
}
- long long compile_id = get_column_value(line, schema->compile_id_column);
- if (compile_id < 0) {
- log_fatal(compile_rt->logger, MODULE_COMPILE,
- "[%s:%d] compile table:<%s> has no compile_id(column seq:%d)"
+ long long rule_id = get_column_value(line, schema->rule_id_column);
+ if (rule_id < 0) {
+ log_fatal(rule_rt->logger, MODULE_RULE,
+ "[%s:%d] rule table:<%s> has no rule_id(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
- schema->compile_id_column, line);
- compile_rt->update_err_cnt++;
+ schema->rule_id_column, line);
+ rule_rt->update_err_cnt++;
return -1;
}
if (0 == is_valid) {
// delete
- compile_runtime_del_compile(compile_rt, compile_id);
+ rule_runtime_del_rule(rule_rt, rule_id);
} else {
// add
- int ret = compile_runtime_add_compile(compile_rt, schema, compile_id,
- table_name, line, compile_rt->logger);
+ int ret = rule_runtime_add_rule(rule_rt, schema, rule_id,
+ table_name, line, rule_rt->logger);
if (ret < 0) {
- compile_rt->update_err_cnt++;
+ rule_rt->update_err_cnt++;
}
}
return 0;
}
-static int validate_table_not_clause(struct group2compile_runtime *g2c_rt,
+static int validate_table_not_clause(struct group2rule_runtime *g2c_rt,
struct table_manager *tbl_mgr, int table_id,
int is_valid, struct log_handle *logger)
{
@@ -2195,7 +2195,7 @@ static int validate_table_not_clause(struct group2compile_runtime *g2c_rt,
} else {
if (not_clause->actual_clause_num >= MAX_NOT_CLAUSE_NUM) {
const char *table_name = table_manager_get_table_name(tbl_mgr, table_id);
- log_fatal(logger, MODULE_COMPILE,
+ log_fatal(logger, MODULE_RULE,
"[%s:%d]table:<%s> NOT clause num exceed maximum:%d",
__FUNCTION__, __LINE__, table_name, MAX_NOT_CLAUSE_NUM);
return -1;
@@ -2207,7 +2207,7 @@ static int validate_table_not_clause(struct group2compile_runtime *g2c_rt,
return 0;
}
-int group2compile_runtime_update(void *g2c_runtime, void *g2c_schema,
+int group2rule_runtime_update(void *g2c_runtime, void *g2c_schema,
const char *table_name, const char *line,
int valid_column)
{
@@ -2215,13 +2215,13 @@ int group2compile_runtime_update(void *g2c_runtime, void *g2c_schema,
return -1;
}
- struct group2compile_schema *schema = (struct group2compile_schema *)g2c_schema;
- struct group2compile_runtime *g2c_rt = (struct group2compile_runtime *)g2c_runtime;
- struct compile_runtime *compile_rt = g2c_rt->ref_compile_rt;
+ struct group2rule_schema *schema = (struct group2rule_schema *)g2c_schema;
+ struct group2rule_runtime *g2c_rt = (struct group2rule_runtime *)g2c_runtime;
+ struct rule_runtime *rule_rt = g2c_rt->ref_rule_rt;
int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) {
- log_fatal(compile_rt->logger, MODULE_COMPILE,
+ log_fatal(rule_rt->logger, MODULE_RULE,
"[%s:%d] g2c table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line);
@@ -2230,8 +2230,8 @@ int group2compile_runtime_update(void *g2c_runtime, void *g2c_schema,
}
int ret = -1;
- struct group2compile_item *g2c_item =
- group2compile_item_new(line, schema, table_name, compile_rt->logger);
+ struct group2rule_item *g2c_item =
+ group2rule_item_new(line, schema, table_name, rule_rt->logger);
if (NULL == g2c_item) {
g2c_rt->update_err_cnt++;
return -1;
@@ -2240,9 +2240,9 @@ int group2compile_runtime_update(void *g2c_runtime, void *g2c_schema,
if (1 == g2c_item->not_flag) {
ret = validate_table_not_clause(g2c_rt, schema->ref_tbl_mgr,
g2c_item->vtable_id, is_valid,
- compile_rt->logger);
+ rule_rt->logger);
if (ret < 0) {
- log_fatal(compile_rt->logger, MODULE_COMPILE,
+ log_fatal(rule_rt->logger, MODULE_RULE,
"[%s:%d]validate NOT clause failed, abandon config:%s",
__FUNCTION__, __LINE__, line);
goto next;
@@ -2251,8 +2251,8 @@ int group2compile_runtime_update(void *g2c_runtime, void *g2c_schema,
if (0 == is_valid) {
//delete
- ret = maat_remove_group_from_compile(compile_rt->cfg_hash, g2c_item,
- compile_rt->logger);
+ ret = maat_remove_group_from_rule(rule_rt->cfg_hash, g2c_item,
+ rule_rt->logger);
if (0 == ret) {
if (g2c_item->not_flag) {
g2c_rt->not_clause_cnt--;
@@ -2263,8 +2263,8 @@ int group2compile_runtime_update(void *g2c_runtime, void *g2c_schema,
}
} else {
//add
- ret = maat_add_group_to_compile(compile_rt->cfg_hash, g2c_item,
- compile_rt->logger);
+ ret = maat_add_group_to_rule(rule_rt->cfg_hash, g2c_item,
+ rule_rt->logger);
if (0 == ret) {
if (g2c_item->not_flag) {
g2c_rt->not_clause_cnt++;
@@ -2276,82 +2276,82 @@ int group2compile_runtime_update(void *g2c_runtime, void *g2c_schema,
}
next:
- group2compile_item_free(g2c_item);
+ group2rule_item_free(g2c_item);
return ret;
}
-long long group2compile_runtime_not_clause_count(void *g2c_runtime)
+long long group2rule_runtime_not_clause_count(void *g2c_runtime)
{
if (NULL == g2c_runtime) {
return 0;
}
- struct group2compile_runtime *g2c_rt =
- (struct group2compile_runtime *)g2c_runtime;
+ struct group2rule_runtime *g2c_rt =
+ (struct group2rule_runtime *)g2c_runtime;
return g2c_rt->not_clause_cnt;
}
-long long group2compile_runtime_rule_count(void *g2c_runtime)
+long long group2rule_runtime_rule_count(void *g2c_runtime)
{
if (NULL == g2c_runtime) {
return 0;
}
- struct group2compile_runtime *g2c_rt =
- (struct group2compile_runtime *)g2c_runtime;
+ struct group2rule_runtime *g2c_rt =
+ (struct group2rule_runtime *)g2c_runtime;
return g2c_rt->rule_num;
}
-long long group2compile_runtime_update_err_count(void *g2c_runtime)
+long long group2rule_runtime_update_err_count(void *g2c_runtime)
{
if (NULL == g2c_runtime) {
return 0;
}
- struct group2compile_runtime *g2c_rt =
- (struct group2compile_runtime *)g2c_runtime;
+ struct group2rule_runtime *g2c_rt =
+ (struct group2rule_runtime *)g2c_runtime;
return g2c_rt->update_err_cnt;
}
-int compile_runtime_commit(void *compile_runtime, const char *table_name,
+int rule_runtime_commit(void *rule_runtime, const char *table_name,
long long maat_rt_version)
{
- if (NULL == compile_runtime) {
+ if (NULL == rule_runtime) {
return -1;
}
- struct compile_runtime *compile_rt =
- (struct compile_runtime *)compile_runtime;
+ struct rule_runtime *rule_rt =
+ (struct rule_runtime *)rule_runtime;
- int updating_flag = rcu_hash_is_updating(compile_rt->cfg_hash);
+ int updating_flag = rcu_hash_is_updating(rule_rt->cfg_hash);
if (0 == updating_flag) {
return 0;
}
int ret = 0;
- size_t compile_cnt = 0;
+ size_t rule_cnt = 0;
struct bool_matcher *old_bool_matcher = NULL;
struct bool_matcher *new_bool_matcher = NULL;
struct timespec start, end;
clock_gettime(CLOCK_MONOTONIC, &start);
- new_bool_matcher = maat_compile_bool_matcher_new(compile_rt, &compile_cnt);
+ new_bool_matcher = maat_rule_bool_matcher_new(rule_rt, &rule_cnt);
clock_gettime(CLOCK_MONOTONIC, &end);
long long time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 +
(end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_bool_matcher) {
- log_fatal(compile_rt->logger, MODULE_COMPILE,
- "[%s:%d] table[%s] rebuild compile bool_matcher failed, compile"
- " rules count:%zu", __FUNCTION__, __LINE__, table_name, compile_cnt);
+ log_fatal(rule_rt->logger, MODULE_RULE,
+ "[%s:%d] table[%s] rebuild rule bool_matcher failed, rule"
+ " rules count:%zu", __FUNCTION__, __LINE__, table_name, rule_cnt);
ret = -1;
} else {
- log_info(compile_rt->logger, MODULE_COMPILE,
- "table[%s] commit %zu compile rules and rebuild compile bool_matcher"
- " completed, version:%lld, consume:%lldms", table_name, compile_cnt,
+ log_info(rule_rt->logger, MODULE_RULE,
+ "table[%s] commit %zu rule rules and rebuild rule bool_matcher"
+ " completed, version:%lld, consume:%lldms", table_name, rule_cnt,
maat_rt_version, time_elapse_ms);
}
@@ -2360,125 +2360,125 @@ int compile_runtime_commit(void *compile_runtime, const char *table_name,
struct clause_id_kv *old_not_clause_id_kv_hash = NULL;
struct clause_id_kv *new_not_clause_id_kv_hash = NULL;
- new_clause_id_kv_hash = build_clause_id_kv_hash(compile_rt, 0);
- new_not_clause_id_kv_hash = build_clause_id_kv_hash(compile_rt, 1);
+ new_clause_id_kv_hash = build_clause_id_kv_hash(rule_rt, 0);
+ new_not_clause_id_kv_hash = build_clause_id_kv_hash(rule_rt, 1);
- old_clause_id_kv_hash = compile_rt->clause_id_kv_hash;
- old_not_clause_id_kv_hash = compile_rt->not_clause_id_kv_hash;
- old_bool_matcher = compile_rt->bm;
+ old_clause_id_kv_hash = rule_rt->clause_id_kv_hash;
+ old_not_clause_id_kv_hash = rule_rt->not_clause_id_kv_hash;
+ old_bool_matcher = rule_rt->bm;
/*
rule_monitor_loop thread
- STEP_1. compile_rt->bm = new_bool_matcher
- STEP_2: rcu_hash_commit(new_compile)
+ STEP_1. rule_rt->bm = new_bool_matcher
+ STEP_2: rcu_hash_commit(new_rule)
scan thread
- Assume_1. If scan thread is using bool_matcher_match(compile_rt->bm)
+ Assume_1. If scan thread is using bool_matcher_match(rule_rt->bm)
before STEP_1 or after STEP_2, it's ok.
- Assume_2. If scan thread is using bool_matcher_match(compile_rt->bm)
+ Assume_2. If scan thread is using bool_matcher_match(rule_rt->bm)
between STEP_1 and STEP_2.
- P1: If new compile is hit and returned, then caller can get this compile's
- ex_data by using maat_plugin_table_get_ex_data(hit_compile_id) because
+ P1: If new rule is hit and returned, then caller can get this rule's
+ ex_data by using maat_plugin_table_get_ex_data(hit_rule_id) because
STEP_2 is fast enough.
*/
- compile_rt->bm = new_bool_matcher;
- compile_rt->clause_id_kv_hash = new_clause_id_kv_hash;
- compile_rt->not_clause_id_kv_hash = new_not_clause_id_kv_hash;
- rcu_hash_commit(compile_rt->cfg_hash); //after commit, old cfg still available within COMPILE_GC_TIMEOUT_S.
+ rule_rt->bm = new_bool_matcher;
+ rule_rt->clause_id_kv_hash = new_clause_id_kv_hash;
+ rule_rt->not_clause_id_kv_hash = new_not_clause_id_kv_hash;
+ rcu_hash_commit(rule_rt->cfg_hash); //after commit, old cfg still available within RULE_GC_TIMEOUT_S.
- maat_garbage_bagging(compile_rt->ref_garbage_bin, old_bool_matcher, NULL,
+ maat_garbage_bagging(rule_rt->ref_garbage_bin, old_bool_matcher, NULL,
garbage_bool_matcher_free);
- maat_garbage_bagging(compile_rt->ref_garbage_bin, old_clause_id_kv_hash, NULL,
+ maat_garbage_bagging(rule_rt->ref_garbage_bin, old_clause_id_kv_hash, NULL,
garbage_clause_id_kv_hash_free);
- maat_garbage_bagging(compile_rt->ref_garbage_bin, old_not_clause_id_kv_hash, NULL,
+ maat_garbage_bagging(rule_rt->ref_garbage_bin, old_not_clause_id_kv_hash, NULL,
garbage_clause_id_kv_hash_free);
- compile_rt->rule_num = rcu_hash_count(compile_rt->cfg_hash);
+ rule_rt->rule_num = rcu_hash_count(rule_rt->cfg_hash);
return ret;
}
-long long compile_runtime_rule_count(void *compile_runtime)
+long long rule_runtime_rule_count(void *rule_runtime)
{
- if (NULL == compile_runtime) {
+ if (NULL == rule_runtime) {
return 0;
}
- struct compile_runtime *compile_rt =
- (struct compile_runtime *)compile_runtime;
+ struct rule_runtime *rule_rt =
+ (struct rule_runtime *)rule_runtime;
- return compile_rt->rule_num;
+ return rule_rt->rule_num;
}
-long long compile_runtime_update_err_count(void *compile_runtime)
+long long rule_runtime_update_err_count(void *rule_runtime)
{
- if (NULL == compile_runtime) {
+ if (NULL == rule_runtime) {
return 0;
}
- struct compile_runtime *compile_rt =
- (struct compile_runtime *)compile_runtime;
+ struct rule_runtime *rule_rt =
+ (struct rule_runtime *)rule_runtime;
- return compile_rt->update_err_cnt;
+ return rule_rt->update_err_cnt;
}
-static int compile_sort_para_compare(const struct compile_sort_para *a,
- const struct compile_sort_para *b)
+static int rule_sort_para_compare(const struct rule_sort_para *a,
+ const struct rule_sort_para *b)
{
- //If compile rule's execute sequences are not specified or equal.
+ //If rule rule's execute sequences are not specified or equal.
if (a->declared_clause_num != b->declared_clause_num) {
return (a->declared_clause_num - b->declared_clause_num);
} else {
- return (b->compile_id - a->compile_id);
+ return (b->rule_id - a->rule_id);
}
}
-static void compile_sort_para_set(struct compile_sort_para *para,
- const struct compile_item *item)
+static void rule_sort_para_set(struct rule_sort_para *para,
+ const struct rule_item *item)
{
- para->compile_id = item->compile_id;
+ para->rule_id = item->rule_id;
para->declared_clause_num = item->declared_clause_num;
}
-static int compare_compile_item(const void *a, const void *b)
+static int compare_rule_item(const void *a, const void *b)
{
- const struct compile_item *ra = *(const struct compile_item **)a;
- const struct compile_item *rb = *(const struct compile_item **)b;
+ const struct rule_item *ra = *(const struct rule_item **)a;
+ const struct rule_item *rb = *(const struct rule_item **)b;
- struct compile_sort_para sa, sb;
- compile_sort_para_set(&sa, ra);
- compile_sort_para_set(&sb, rb);
+ struct rule_sort_para sa, sb;
+ rule_sort_para_set(&sa, ra);
+ rule_sort_para_set(&sb, rb);
- return compile_sort_para_compare(&sa, &sb);
+ return rule_sort_para_compare(&sa, &sb);
}
-int compile_runtime_match(struct compile_runtime *compile_rt, long long *compile_ids,
- size_t compile_ids_size, struct maat_state *state)
+int rule_runtime_match(struct rule_runtime *rule_rt, long long *rule_ids,
+ size_t rule_ids_size, struct maat_state *state)
{
- struct compile_state *compile_state = state->compile_state;
- struct compile_item *compile_items[compile_ids_size];
+ struct rule_state *rule_state = state->rule_state;
+ struct rule_item *rule_items[rule_ids_size];
- // all hit clause_id -> compile_id
+ // all hit clause_id -> rule_id
size_t bool_match_ret =
- maat_compile_bool_matcher_match(compile_rt, compile_state,
+ maat_rule_bool_matcher_match(rule_rt, rule_state,
state->thread_id,
- (void **)compile_items,
- compile_ids_size);
+ (void **)rule_items,
+ rule_ids_size);
if (bool_match_ret > 0) {
- qsort(compile_items, bool_match_ret, sizeof(struct compile_item *),
- compare_compile_item);
+ qsort(rule_items, bool_match_ret, sizeof(struct rule_item *),
+ compare_rule_item);
}
for (size_t i = 0; i < bool_match_ret; i++) {
- compile_ids[i] = compile_items[i]->compile_id;
+ rule_ids[i] = rule_items[i]->rule_id;
}
- return MIN(bool_match_ret, compile_ids_size);
+ return MIN(bool_match_ret, rule_ids_size);
}
-int compile_state_update(struct compile_state *compile_state, struct maat *maat_inst,
- int vtable_id, int custom_compile_tbl_id, int Nth_scan,
+int rule_state_update(struct rule_state *rule_state, struct maat *maat_inst,
+ int vtable_id, int custom_rule_tbl_id, int Nth_scan,
struct maat_item *hit_items, size_t n_hit_item)
{
size_t i = 0, j = 0;
@@ -2486,9 +2486,9 @@ int compile_state_update(struct compile_state *compile_state, struct maat *maat_
long long hit_group_ids[MAX_HIT_GROUP_NUM];
struct maat_hit_group hit_group;
- utarray_clear(compile_state->this_scan_hit_clauses);
- compile_state->this_scan_not_logic = 0;
- compile_state->Nth_scan = Nth_scan;
+ utarray_clear(rule_state->this_scan_hit_clauses);
+ rule_state->this_scan_not_logic = 0;
+ rule_state->Nth_scan = Nth_scan;
for (i = 0; i < hit_cnt; i++) {
hit_group_ids[i] = hit_items[i].group_id;
@@ -2496,7 +2496,7 @@ int compile_state_update(struct compile_state *compile_state, struct maat *maat_
hit_group.item_id = hit_items[i].item_id;
hit_group.group_id = hit_items[i].group_id;
hit_group.vtable_id = vtable_id;
- utarray_push_back(compile_state->last_hit_groups, &hit_group);
+ utarray_push_back(rule_state->last_hit_groups, &hit_group);
}
int g2g_table_id = table_manager_get_group2group_table_id(maat_inst->tbl_mgr);
@@ -2510,31 +2510,31 @@ int compile_state_update(struct compile_state *compile_state, struct maat *maat_
hit_group.item_id = 0;
hit_group.group_id = super_group_ids[i];
hit_group.vtable_id = vtable_id;
- utarray_push_back(compile_state->last_hit_groups, &hit_group);
+ utarray_push_back(rule_state->last_hit_groups, &hit_group);
}
if (1 == maat_inst->opts.hit_path_on && hit_cnt > 0) {
for (i = 0; i < hit_cnt; i++) {
- compile_state_add_internal_hit_path(compile_state, hit_items[i].item_id,
+ rule_state_add_internal_hit_path(rule_state, hit_items[i].item_id,
hit_items[i].group_id, vtable_id, 0, Nth_scan);
}
}
if (1 == maat_inst->opts.hit_group_on) {
- compile_state_add_direct_hit_groups(compile_state, hit_items, hit_cnt, vtable_id);
- compile_state_add_indirect_hit_groups(compile_state, super_group_ids,
+ rule_state_add_direct_hit_groups(rule_state, hit_items, hit_cnt, vtable_id);
+ rule_state_add_indirect_hit_groups(rule_state, super_group_ids,
super_group_cnt, vtable_id);
}
/* update hit clause */
- int compile_table_id = table_manager_get_default_compile_table_id(maat_inst->tbl_mgr);
- if (custom_compile_tbl_id > 0) {
- compile_table_id = custom_compile_tbl_id;
+ int rule_table_id = table_manager_get_default_rule_table_id(maat_inst->tbl_mgr);
+ if (custom_rule_tbl_id > 0) {
+ rule_table_id = custom_rule_tbl_id;
}
- struct compile_runtime *compile_rt = table_manager_get_runtime(maat_inst->tbl_mgr,
- compile_table_id);
- if (NULL == compile_rt) {
+ struct rule_runtime *rule_rt = table_manager_get_runtime(maat_inst->tbl_mgr,
+ rule_table_id);
+ if (NULL == rule_rt) {
return 0;
}
@@ -2543,39 +2543,39 @@ int compile_state_update(struct compile_state *compile_state, struct maat *maat_
}
for (i = 0; i < hit_cnt; i++) {
- compile_state_update_hit_clauses(compile_state, compile_rt,
+ rule_state_update_hit_clauses(rule_state, rule_rt,
hit_group_ids[i], vtable_id);
}
- compile_state_cache_hit_not_groups(compile_state, compile_rt, hit_group_ids,
+ rule_state_cache_hit_not_groups(rule_state, rule_rt, hit_group_ids,
hit_cnt, vtable_id);
return hit_cnt;
}
-void compile_state_clear_last_hit_group(struct compile_state *compile_state)
+void rule_state_clear_last_hit_group(struct rule_state *rule_state)
{
- if (NULL == compile_state) {
+ if (NULL == rule_state) {
return;
}
- utarray_clear(compile_state->last_hit_groups);
+ utarray_clear(rule_state->last_hit_groups);
}
-void compile_state_not_logic_update(struct compile_state *compile_state,
- struct compile_runtime *compile_rt,
+void rule_state_not_logic_update(struct rule_state *rule_state,
+ struct rule_runtime *rule_rt,
struct maat *maat_inst, int vtable_id,
int Nth_scan)
{
- if (NULL == compile_state || NULL == maat_inst) {
+ if (NULL == rule_state || NULL == maat_inst) {
return;
}
- compile_state->this_scan_not_logic = 1;
- compile_state->Nth_scan = Nth_scan;
- utarray_clear(compile_state->this_scan_hit_not_clauses);
+ rule_state->this_scan_not_logic = 1;
+ rule_state->Nth_scan = Nth_scan;
+ utarray_clear(rule_state->this_scan_hit_not_clauses);
struct table_group *tbl_group = NULL;
- HASH_FIND(hh, compile_state->hit_not_tbl_groups, &vtable_id, sizeof(int), tbl_group);
+ HASH_FIND(hh, rule_state->hit_not_tbl_groups, &vtable_id, sizeof(int), tbl_group);
if (NULL == tbl_group) {
return;
}
@@ -2585,67 +2585,67 @@ void compile_state_not_logic_update(struct compile_state *compile_state,
long long *group_id = utarray_eltptr(tbl_group->group_ids, i);
struct clause_query_key key = {*group_id, vtable_id, 1};
- HASH_FIND(hh, compile_rt->not_clause_id_kv_hash, &key, sizeof(key), clause_id_kv);
+ HASH_FIND(hh, rule_rt->not_clause_id_kv_hash, &key, sizeof(key), clause_id_kv);
if (NULL == clause_id_kv) {
continue;
}
- compile_state_add_hit_not_clauses(compile_state, clause_id_kv->clause_ids);
+ rule_state_add_hit_not_clauses(rule_state, clause_id_kv->clause_ids);
if (1 == maat_inst->opts.hit_path_on) {
- compile_state_add_internal_hit_path(compile_state, -1, *group_id,
+ rule_state_add_internal_hit_path(rule_state, -1, *group_id,
vtable_id, 1, Nth_scan);
}
}
}
-size_t compile_state_get_indirect_hit_groups(struct compile_state *compile_state,
+size_t rule_state_get_indirect_hit_groups(struct rule_state *rule_state,
struct maat_hit_group *group_array,
size_t array_size)
{
size_t i = 0;
struct maat_hit_group *hit_group = NULL;
- for (i = 0; i < utarray_len(compile_state->indirect_hit_groups) && i < array_size; i++) {
+ for (i = 0; i < utarray_len(rule_state->indirect_hit_groups) && i < array_size; i++) {
hit_group =
- (struct maat_hit_group *)utarray_eltptr(compile_state->indirect_hit_groups, i);
+ (struct maat_hit_group *)utarray_eltptr(rule_state->indirect_hit_groups, i);
group_array[i].item_id = hit_group->item_id;
group_array[i].group_id = hit_group->group_id;
group_array[i].vtable_id = hit_group->vtable_id;
}
- utarray_clear(compile_state->indirect_hit_groups);
+ utarray_clear(rule_state->indirect_hit_groups);
return i;
}
-size_t compile_state_get_indirect_hit_group_cnt(struct compile_state *compile_state)
+size_t rule_state_get_indirect_hit_group_cnt(struct rule_state *rule_state)
{
- return utarray_len(compile_state->indirect_hit_groups);
+ return utarray_len(rule_state->indirect_hit_groups);
}
-size_t compile_state_get_last_hit_groups(struct compile_state *compile_state,
+size_t rule_state_get_last_hit_groups(struct rule_state *rule_state,
struct maat_hit_group *group_array,
size_t array_size)
{
size_t i = 0;
- for (i = 0; i < utarray_len(compile_state->last_hit_groups) && i < array_size; i++) {
+ for (i = 0; i < utarray_len(rule_state->last_hit_groups) && i < array_size; i++) {
group_array[i] =
- *(struct maat_hit_group *)utarray_eltptr(compile_state->last_hit_groups, i);
+ *(struct maat_hit_group *)utarray_eltptr(rule_state->last_hit_groups, i);
}
return i;
}
-size_t compile_state_get_last_hit_group_cnt(struct compile_state *compile_state)
+size_t rule_state_get_last_hit_group_cnt(struct rule_state *rule_state)
{
- return utarray_len(compile_state->last_hit_groups);
+ return utarray_len(rule_state->last_hit_groups);
}
-size_t compile_state_get_direct_hit_groups(struct compile_state *compile_state,
+size_t rule_state_get_direct_hit_groups(struct rule_state *rule_state,
struct maat_hit_group *group_array,
size_t array_size)
{
- UT_array *direct_hit_group = compile_state->direct_hit_groups;
+ UT_array *direct_hit_group = rule_state->direct_hit_groups;
size_t i = 0;
struct maat_hit_group *group = NULL;
@@ -2656,18 +2656,18 @@ size_t compile_state_get_direct_hit_groups(struct compile_state *compile_state,
group_array[i].vtable_id = group->vtable_id;
}
- utarray_clear(compile_state->direct_hit_groups);
+ utarray_clear(rule_state->direct_hit_groups);
return i;
}
-size_t compile_state_get_direct_hit_group_cnt(struct compile_state *compile_state)
+size_t rule_state_get_direct_hit_group_cnt(struct rule_state *rule_state)
{
- return utarray_len(compile_state->direct_hit_groups);
+ return utarray_len(rule_state->direct_hit_groups);
}
-size_t compile_state_get_internal_hit_paths(struct compile_state *compile_state,
- struct compile_runtime *compile_rt,
+size_t rule_state_get_internal_hit_paths(struct rule_state *rule_state,
+ struct rule_runtime *rule_rt,
struct group2group_runtime *g2g_rt,
struct maat_hit_path *hit_path_array,
size_t array_size)
@@ -2675,15 +2675,15 @@ size_t compile_state_get_internal_hit_paths(struct compile_state *compile_state,
size_t hit_path_cnt = 0;
struct internal_hit_path *internal_path = NULL;
- for (int i = 0; i < utarray_len(compile_state->internal_hit_paths); i++) {
+ for (int i = 0; i < utarray_len(rule_state->internal_hit_paths); i++) {
internal_path =
- (struct internal_hit_path *)utarray_eltptr(compile_state->internal_hit_paths, i);
+ (struct internal_hit_path *)utarray_eltptr(rule_state->internal_hit_paths, i);
/*
NOTE: maybe one item has been deleted, but it's item_id still exist in internal_hit_paths
*/
long long super_group_ids[MAX_HIT_GROUP_NUM];
UT_array *valid_super_group_ids;
- utarray_new(valid_super_group_ids, &ut_compile_group_id_icd);
+ utarray_new(valid_super_group_ids, &ut_rule_group_id_icd);
size_t super_group_cnt =
group2group_runtime_get_super_groups(g2g_rt, &(internal_path->group_id), 1,
@@ -2693,7 +2693,7 @@ size_t compile_state_get_internal_hit_paths(struct compile_state *compile_state,
}
/*
- internal_path->group_id can be referenced directly by compile,
+ internal_path->group_id can be referenced directly by rule,
so add it to hit_path which super_group_ids is -1
------------------------------------------------------------------------------
NOTE: Add the hit path as long as the item is hit
@@ -2715,12 +2715,12 @@ size_t compile_state_get_internal_hit_paths(struct compile_state *compile_state,
tmp_path.vtable_id = internal_path->vtable_id;
tmp_path.NOT_flag = internal_path->NOT_flag;
tmp_path.clause_index = -1;
- tmp_path.compile_id = -1;
+ tmp_path.rule_id = -1;
/* check if internal_path is duplicated from hit_path_array[]
* element */
if (hit_path_cnt > 0) {
- if (maat_compile_is_hit_path_existed(hit_path_array, hit_path_cnt,
+ if (maat_rule_is_hit_path_existed(hit_path_array, hit_path_cnt,
&tmp_path)) {
continue;
}
diff --git a/src/maat_stat.c b/src/maat_stat.c
index 8ed28e8..972806c 100644
--- a/src/maat_stat.c
+++ b/src/maat_stat.c
@@ -16,7 +16,7 @@
#include "fieldstat/fieldstat_easy.h"
#include "alignment.h"
#include "maat_ip.h"
-#include "maat_compile.h"
+#include "maat_rule.h"
#include "maat_group.h"
#include "maat_plugin.h"
#include "maat_expr.h"
@@ -31,10 +31,10 @@ enum MAAT_FS_STATUS {
STATUS_PLUGIN_ACC_NUM,
STATUS_CLAUSE_REF_NOT_NUM,
STATUS_GROUP_REF_EXCL_NUM, //group reference exclude group num
- STATUS_HIT_COMPILE_NUM,
+ STATUS_HIT_RULE_NUM,
STATUS_MAAT_STATE_NUM,
STATUS_MAAT_PER_STATE_MEM,
- STATUS_COMPILE_STATE_NUM,
+ STATUS_RULE_STATE_NUM,
STATUS_GARBAGE_QUEUE_LEN,
STATUS_UPDATE_ERR_CNT,
STATUS_SCAN_ERR_CNT,
@@ -84,8 +84,8 @@ static void fs_global_metric_register(struct maat_stat *stat)
stat->g_metric_id[STATUS_GARBAGE_QUEUE_LEN] =
fieldstat_easy_register_counter(stat->fs_handle, "garbage_queue_len");
- stat->g_metric_id[STATUS_HIT_COMPILE_NUM] =
- fieldstat_easy_register_counter(stat->fs_handle, "hit_compile_num");
+ stat->g_metric_id[STATUS_HIT_RULE_NUM] =
+ fieldstat_easy_register_counter(stat->fs_handle, "hit_rule_num");
stat->g_metric_id[STATUS_MAAT_STATE_NUM] =
fieldstat_easy_register_counter(stat->fs_handle, "state_num");
@@ -93,8 +93,8 @@ static void fs_global_metric_register(struct maat_stat *stat)
stat->g_metric_id[STATUS_MAAT_PER_STATE_MEM] =
fieldstat_easy_register_counter(stat->fs_handle, "per_state_mem(B)");
- stat->g_metric_id[STATUS_COMPILE_STATE_NUM] =
- fieldstat_easy_register_counter(stat->fs_handle, "compile_state_num");
+ stat->g_metric_id[STATUS_RULE_STATE_NUM] =
+ fieldstat_easy_register_counter(stat->fs_handle, "rule_state_num");
stat->g_metric_id[STATUS_STREAM_NUM] =
fieldstat_easy_register_counter(stat->fs_handle, "stream_num");
@@ -153,9 +153,9 @@ struct maat_stat *maat_stat_new(const char *stat_file, size_t max_thread_num,
stat->logger = logger;
stat->stream_cnt = alignment_int64_array_alloc(max_thread_num);
stat->thread_call_cnt = alignment_int64_array_alloc(max_thread_num);
- stat->hit_compile_cnt = alignment_int64_array_alloc(max_thread_num);
+ stat->hit_rule_cnt = alignment_int64_array_alloc(max_thread_num);
stat->maat_state_cnt = alignment_int64_array_alloc(max_thread_num);
- stat->compile_state_cnt = alignment_int64_array_alloc(max_thread_num);
+ stat->rule_state_cnt = alignment_int64_array_alloc(max_thread_num);
stat->maat_state_free_cnt = alignment_int64_array_alloc(max_thread_num);
stat->maat_state_free_bytes = alignment_int64_array_alloc(max_thread_num);
@@ -178,9 +178,9 @@ void maat_stat_free(struct maat_stat *stat)
stat->thread_call_cnt = NULL;
}
- if (stat->hit_compile_cnt != NULL) {
- alignment_int64_array_free(stat->hit_compile_cnt);
- stat->hit_compile_cnt = NULL;
+ if (stat->hit_rule_cnt != NULL) {
+ alignment_int64_array_free(stat->hit_rule_cnt);
+ stat->hit_rule_cnt = NULL;
}
if (stat->maat_state_cnt != NULL) {
@@ -188,9 +188,9 @@ void maat_stat_free(struct maat_stat *stat)
stat->maat_state_cnt = NULL;
}
- if (stat->compile_state_cnt != NULL) {
- alignment_int64_array_free(stat->compile_state_cnt);
- stat->compile_state_cnt = NULL;
+ if (stat->rule_state_cnt != NULL) {
+ alignment_int64_array_free(stat->rule_state_cnt);
+ stat->rule_state_cnt = NULL;
}
if (stat->maat_state_free_cnt != NULL) {
@@ -272,8 +272,8 @@ static void fs_table_row_refresh(struct maat_stat *stat, int perf_on)
plugin_cache_num += plugin_runtime_cached_row_count(runtime);
plugin_rule_num += plugin_runtime_rule_count(runtime);
break;
- case TABLE_TYPE_GROUP2COMPILE:
- g2c_not_clause_num += group2compile_runtime_not_clause_count(runtime);
+ case TABLE_TYPE_GROUP2RULE:
+ g2c_not_clause_num += group2rule_runtime_not_clause_count(runtime);
break;
case TABLE_TYPE_GROUP2GROUP:
g2g_excl_rule_num += group2group_runtime_exclude_rule_count(runtime);
@@ -437,14 +437,14 @@ void maat_stat_refresh(struct maat_stat *stat, struct table_manager *tbl_mgr,
long long stream_num =
alignment_int64_array_sum(stat->stream_cnt, stat->nr_worker_thread);
- long long hit_compile_num =
- alignment_int64_array_sum(stat->hit_compile_cnt, stat->nr_worker_thread);
+ long long hit_rule_num =
+ alignment_int64_array_sum(stat->hit_rule_cnt, stat->nr_worker_thread);
long long maat_state_num =
alignment_int64_array_sum(stat->maat_state_cnt, stat->nr_worker_thread);
- long long compile_state_num =
- alignment_int64_array_sum(stat->compile_state_cnt, stat->nr_worker_thread);
+ long long rule_state_num =
+ alignment_int64_array_sum(stat->rule_state_cnt, stat->nr_worker_thread);
long long maat_state_free_num =
alignment_int64_array_sum(stat->maat_state_free_cnt, stat->nr_worker_thread);
@@ -470,8 +470,8 @@ void maat_stat_refresh(struct maat_stat *stat, struct table_manager *tbl_mgr,
stat->g_metric_id[STATUS_TABLE_NUM],
NULL, 0, table_num);
fieldstat_easy_counter_set(stat->fs_handle, 0,
- stat->g_metric_id[STATUS_HIT_COMPILE_NUM],
- NULL, 0, hit_compile_num);
+ stat->g_metric_id[STATUS_HIT_RULE_NUM],
+ NULL, 0, hit_rule_num);
fieldstat_easy_counter_set(stat->fs_handle, 0,
stat->g_metric_id[STATUS_MAAT_STATE_NUM],
NULL, 0, maat_state_num);
@@ -479,8 +479,8 @@ void maat_stat_refresh(struct maat_stat *stat, struct table_manager *tbl_mgr,
stat->g_metric_id[STATUS_MAAT_PER_STATE_MEM],
NULL, 0, per_state_mem);
fieldstat_easy_counter_set(stat->fs_handle, 0,
- stat->g_metric_id[STATUS_COMPILE_STATE_NUM],
- NULL, 0, compile_state_num);
+ stat->g_metric_id[STATUS_RULE_STATE_NUM],
+ NULL, 0, rule_state_num);
fieldstat_easy_counter_set(stat->fs_handle, 0,
stat->g_metric_id[STATUS_CMD_LINE_NUM],
NULL, 0, stat->line_cmd_acc_num);
diff --git a/src/maat_table.c b/src/maat_table.c
index d907e6d..07988e0 100644
--- a/src/maat_table.c
+++ b/src/maat_table.c
@@ -18,7 +18,7 @@
#include "maat_kv.h"
#include "maat_expr.h"
#include "maat_ip.h"
-#include "maat_compile.h"
+#include "maat_rule.h"
#include "maat_group.h"
#include "maat_flag.h"
#include "maat_plugin.h"
@@ -52,7 +52,7 @@ struct table_manager {
size_t n_accept_tag;
enum expr_engine_type engine_type;
- int default_compile_table_id;
+ int default_rule_table_id;
int g2g_table_id;
struct maat_kv_store *tbl_name2id_map;
struct maat_kv_store *conj_tbl_name2id_map;
@@ -278,15 +278,15 @@ struct table_operations table_ops[TABLE_TYPE_MAX] = {
.hit_item_num = virtual_runtime_hit_item_num
},
{
- .type = TABLE_TYPE_COMPILE,
- .new_schema = compile_schema_new,
- .free_schema = compile_schema_free,
- .new_runtime = compile_runtime_new,
- .free_runtime = compile_runtime_free,
- .update_runtime = compile_runtime_update,
- .commit_runtime = compile_runtime_commit,
- .rule_count = compile_runtime_rule_count,
- .update_err_count = compile_runtime_update_err_count
+ .type = TABLE_TYPE_RULE,
+ .new_schema = rule_schema_new,
+ .free_schema = rule_schema_free,
+ .new_runtime = rule_runtime_new,
+ .free_runtime = rule_runtime_free,
+ .update_runtime = rule_runtime_update,
+ .commit_runtime = rule_runtime_commit,
+ .rule_count = rule_runtime_rule_count,
+ .update_err_count = rule_runtime_update_err_count
},
{
.type = TABLE_TYPE_GROUP2GROUP,
@@ -300,15 +300,15 @@ struct table_operations table_ops[TABLE_TYPE_MAX] = {
.update_err_count = group2group_runtime_update_err_count
},
{
- .type = TABLE_TYPE_GROUP2COMPILE,
- .new_schema = group2compile_schema_new,
- .free_schema = group2compile_schema_free,
- .new_runtime = group2compile_runtime_new,
- .free_runtime = group2compile_runtime_free,
- .update_runtime = group2compile_runtime_update,
+ .type = TABLE_TYPE_GROUP2RULE,
+ .new_schema = group2rule_schema_new,
+ .free_schema = group2rule_schema_free,
+ .new_runtime = group2rule_runtime_new,
+ .free_runtime = group2rule_runtime_free,
+ .update_runtime = group2rule_runtime_update,
.commit_runtime = NULL,
- .rule_count = group2compile_runtime_rule_count,
- .update_err_count = group2compile_runtime_update_err_count
+ .rule_count = group2rule_runtime_rule_count,
+ .update_err_count = group2rule_runtime_update_err_count
}
};
@@ -499,8 +499,8 @@ static void maat_table_schema_free(void *schema, enum table_type table_type)
static void register_reserved_word(struct maat_kv_store *reserved_word_map)
{
- maat_kv_register(reserved_word_map, "compile", TABLE_TYPE_COMPILE);
- maat_kv_register(reserved_word_map, "group2compile", TABLE_TYPE_GROUP2COMPILE);
+ maat_kv_register(reserved_word_map, "rule", TABLE_TYPE_RULE);
+ maat_kv_register(reserved_word_map, "group2rule", TABLE_TYPE_GROUP2RULE);
maat_kv_register(reserved_word_map, "group2group", TABLE_TYPE_GROUP2GROUP);
maat_kv_register(reserved_word_map, "flag", TABLE_TYPE_FLAG);
maat_kv_register(reserved_word_map, "flag_plus", TABLE_TYPE_FLAG_PLUS);
@@ -787,9 +787,9 @@ static int register_tbl_name2id(struct maat_kv_store *tbl_name2id_map, cJSON *ro
return 0;
}
-int maat_default_compile_table_id(cJSON *json, struct log_handle *logger)
+int maat_default_rule_table_id(cJSON *json, struct log_handle *logger)
{
- cJSON *item = cJSON_GetObjectItem(json, "default_compile_table");
+ cJSON *item = cJSON_GetObjectItem(json, "default_rule_table");
if (NULL == item || item->type != cJSON_Number) {
return -1;
}
@@ -867,7 +867,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
return NULL;
}
- int default_compile_table_id = -1;
+ int default_rule_table_id = -1;
int g2g_table_id = -1;
struct maat_kv_store *reserved_word_map = maat_kv_store_new();
register_reserved_word(reserved_word_map);
@@ -899,9 +899,9 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
}
}
- if (maat_tbl->table_type == TABLE_TYPE_COMPILE) {
- if (default_compile_table_id < 0) {
- default_compile_table_id = maat_default_compile_table_id(json, logger);
+ if (maat_tbl->table_type == TABLE_TYPE_RULE) {
+ if (default_rule_table_id < 0) {
+ default_rule_table_id = maat_default_rule_table_id(json, logger);
}
}
@@ -926,10 +926,10 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
}
}
- tbl_mgr->default_compile_table_id = default_compile_table_id;
+ tbl_mgr->default_rule_table_id = default_rule_table_id;
tbl_mgr->g2g_table_id = g2g_table_id;
- log_info(logger, MODULE_TABLE, "default compile table id: %d", default_compile_table_id);
+ log_info(logger, MODULE_TABLE, "default rule table id: %d", default_rule_table_id);
log_info(logger, MODULE_TABLE, "group2group table id: %d", g2g_table_id);
next:
FREE(json_buff);
@@ -990,18 +990,18 @@ int table_manager_runtime_create(struct table_manager *tbl_mgr, size_t max_threa
garbage_bin, tbl_mgr->logger);
}
- /* group2compile runtime depends on associated compile runtime,
- must make sure associated compile runtime already exist */
+ /* group2rule runtime depends on associated rule runtime,
+ must make sure associated rule runtime already exist */
for (i = 0; i < MAX_TABLE_NUM; i++) {
table_type = table_manager_get_table_type(tbl_mgr, i);
- if (table_type != TABLE_TYPE_GROUP2COMPILE) {
+ if (table_type != TABLE_TYPE_GROUP2RULE) {
continue;
}
void *schema = table_manager_get_schema(tbl_mgr, i);
if (NULL == schema) {
log_fatal(tbl_mgr->logger, MODULE_TABLE,
- "[%s:%d] group2compile table(table_id:%d) schema is null",
+ "[%s:%d] group2rule table(table_id:%d) schema is null",
__FUNCTION__, __LINE__, i);
continue;
}
@@ -1011,9 +1011,9 @@ int table_manager_runtime_create(struct table_manager *tbl_mgr, size_t max_threa
continue;
}
- int asso_compile_table_id = group2compile_associated_compile_table_id(schema);
- void *compile_updating_rt = table_manager_get_updating_runtime(tbl_mgr, asso_compile_table_id);
- group2compile_runtime_init(g2c_updating_rt, compile_updating_rt);
+ int asso_rule_table_id = group2rule_associated_rule_table_id(schema);
+ void *rule_updating_rt = table_manager_get_updating_runtime(tbl_mgr, asso_rule_table_id);
+ group2rule_runtime_init(g2c_updating_rt, rule_updating_rt);
}
return 0;
@@ -1154,13 +1154,13 @@ enum table_type table_manager_get_table_type(struct table_manager *tbl_mgr, int
return tbl_mgr->tbl[table_id]->table_type;
}
-int table_manager_get_default_compile_table_id(struct table_manager *tbl_mgr)
+int table_manager_get_default_rule_table_id(struct table_manager *tbl_mgr)
{
if (NULL == tbl_mgr) {
return -1;
}
- return tbl_mgr->default_compile_table_id;
+ return tbl_mgr->default_rule_table_id;
}
int table_manager_get_group2group_table_id(struct table_manager *tbl_mgr)
diff --git a/src/version.map b/src/version.map
index 4028108..0a13366 100644
--- a/src/version.map
+++ b/src/version.map
@@ -9,7 +9,7 @@ global:
maat_get_table_schema_tag;
maat_reload_log_level;
maat_table*;
- maat_compile_table*;
+ maat_rule_table*;
maat_plugin_table*;
maat_ip_plugin_table*;
maat_ipport_plugin_table*;
diff --git a/test/benchmark/benchmark_gtest.cpp b/test/benchmark/benchmark_gtest.cpp
index 0beb692..672913d 100644
--- a/test/benchmark/benchmark_gtest.cpp
+++ b/test/benchmark/benchmark_gtest.cpp
@@ -120,7 +120,7 @@ void generate_flag_sample(const char *table_name, int sample_count)
fclose(fp);
}
-void generate_compile_sample(const char *table_name, int sample_count)
+void generate_rule_sample(const char *table_name, int sample_count)
{
FILE *fp = fopen(table_name, "w+");
if (NULL == fp) {
@@ -137,7 +137,7 @@ void generate_compile_sample(const char *table_name, int sample_count)
fclose(fp);
}
-void generate_group2compile_sample(const char *table_name, const char *vtable_name,
+void generate_group2rule_sample(const char *table_name, const char *vtable_name,
int sample_count)
{
FILE *fp = fopen(table_name, "w+");
@@ -526,12 +526,12 @@ protected:
return;
}
fprintf(fp, "REGEX_100\t100\t./regex_rules/REGEX_100\n");
- fprintf(fp, "COMPILE_PERF\t10\t./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF\t10\t./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "REGEX_100", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_100", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -622,8 +622,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("./COMPILE_PERF");
- system_cmd_rmdir("./GROUP2COMPILE_PERF");
+ system_cmd_rmdir("./RULE_PERF");
+ system_cmd_rmdir("./GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -693,12 +693,12 @@ protected:
return;
}
fprintf(fp, "REGEX_200\t200\t./regex_rules/REGEX_200\n");
- fprintf(fp, "COMPILE_PERF\t10\t./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF\t10\t./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "REGEX_200", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_200", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -789,8 +789,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("./COMPILE_PERF");
- system_cmd_rmdir("./GROUP2COMPILE_PERF");
+ system_cmd_rmdir("./RULE_PERF");
+ system_cmd_rmdir("./GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -860,12 +860,12 @@ protected:
return;
}
fprintf(fp, "REGEX_300\t300\t./regex_rules/REGEX_300\n");
- fprintf(fp, "COMPILE_PERF\t10\t./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF\t10\t./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "REGEX_300", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_300", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -956,8 +956,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("./COMPILE_PERF");
- system_cmd_rmdir("./GROUP2COMPILE_PERF");
+ system_cmd_rmdir("./RULE_PERF");
+ system_cmd_rmdir("./GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -1027,12 +1027,12 @@ protected:
return;
}
fprintf(fp, "REGEX_500\t500\t./regex_rules/REGEX_500\n");
- fprintf(fp, "COMPILE_PERF\t10\t./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF\t10\t./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "REGEX_500", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_500", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -1123,8 +1123,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("./COMPILE_PERF");
- system_cmd_rmdir("./GROUP2COMPILE_PERF");
+ system_cmd_rmdir("./RULE_PERF");
+ system_cmd_rmdir("./GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -1194,12 +1194,12 @@ protected:
return;
}
fprintf(fp, "REGEX_1K\t1000\t./regex_rules/REGEX_1K\n");
- fprintf(fp, "COMPILE_PERF\t10\t./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF\t10\t./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "REGEX_1K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_1K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -1290,8 +1290,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("./COMPILE_PERF");
- system_cmd_rmdir("./GROUP2COMPILE_PERF");
+ system_cmd_rmdir("./RULE_PERF");
+ system_cmd_rmdir("./GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -1361,12 +1361,12 @@ protected:
return;
}
fprintf(fp, "REGEX_2K\t2000\t./regex_rules/REGEX_2K\n");
- fprintf(fp, "COMPILE_PERF\t10\t./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF\t10\t./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "REGEX_2K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_2K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -1457,8 +1457,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("./COMPILE_PERF");
- system_cmd_rmdir("./GROUP2COMPILE_PERF");
+ system_cmd_rmdir("./RULE_PERF");
+ system_cmd_rmdir("./GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -1528,12 +1528,12 @@ protected:
return;
}
fprintf(fp, "REGEX_3K\t3000\t./regex_rules/REGEX_3K\n");
- fprintf(fp, "COMPILE_PERF\t10\t./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF\t10\t./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "REGEX_3K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_3K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -1624,8 +1624,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -1695,12 +1695,12 @@ protected:
return;
}
fprintf(fp, "REGEX_5K\t5000\t./regex_rules/REGEX_5K\n");
- fprintf(fp, "COMPILE_PERF\t10\t./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF\t10\t./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "REGEX_5K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_5K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -1791,8 +1791,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -1862,12 +1862,12 @@ protected:
return;
}
fprintf(fp, "REGEX_10K\t10000\t./regex_rules/REGEX_10K\n");
- fprintf(fp, "COMPILE_PERF\t10\t./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF\t10\t./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "REGEX_10K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_10K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -1958,8 +1958,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -2029,12 +2029,12 @@ protected:
return;
}
fprintf(fp, "REGEX_15K\t15000\t./regex_rules/REGEX_15K\n");
- fprintf(fp, "COMPILE_PERF\t10\t./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF\t10\t./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "REGEX_15K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_15K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -2125,8 +2125,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -2197,12 +2197,12 @@ protected:
return;
}
fprintf(fp, "EXPR_LITERAL_1K 1000 ./EXPR_LITERAL_1K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "EXPR_LITERAL_1K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_1K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -2293,8 +2293,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -2365,12 +2365,12 @@ protected:
return;
}
fprintf(fp, "EXPR_LITERAL_5K 5000 ./EXPR_LITERAL_5K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "EXPR_LITERAL_5K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_5K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -2461,8 +2461,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -2533,12 +2533,12 @@ protected:
return;
}
fprintf(fp, "EXPR_LITERAL_10K 10000 ./EXPR_LITERAL_10K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "EXPR_LITERAL_10K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_10K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -2629,8 +2629,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -2701,12 +2701,12 @@ protected:
return;
}
fprintf(fp, "EXPR_LITERAL_50K 50000 ./EXPR_LITERAL_50K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "EXPR_LITERAL_50K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_50K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -2797,8 +2797,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -2869,12 +2869,12 @@ protected:
return;
}
fprintf(fp, "EXPR_LITERAL_100K 100000 ./EXPR_LITERAL_100K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "EXPR_LITERAL_100K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_100K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -2965,8 +2965,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -3037,12 +3037,12 @@ protected:
return;
}
fprintf(fp, "EXPR_LITERAL_500K 500000 ./EXPR_LITERAL_500K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "EXPR_LITERAL_500K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_500K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -3133,8 +3133,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -3205,12 +3205,12 @@ protected:
return;
}
fprintf(fp, "EXPR_LITERAL_1M 1000000 ./EXPR_LITERAL_1M\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "EXPR_LITERAL_1M", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_1M", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -3301,8 +3301,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -3373,12 +3373,12 @@ protected:
return;
}
fprintf(fp, "EXPR_LITERAL_2M 2000000 ./EXPR_LITERAL_2M\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "EXPR_LITERAL_2M", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_2M", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -3469,8 +3469,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -3541,12 +3541,12 @@ protected:
return;
}
fprintf(fp, "STREAM_1K 1000 ./STREAM_1K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "STREAM_1K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_1K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -3634,8 +3634,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -3703,12 +3703,12 @@ protected:
return;
}
fprintf(fp, "STREAM_5K 5000 ./STREAM_5K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "STREAM_5K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_5K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -3796,8 +3796,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -3865,12 +3865,12 @@ protected:
return;
}
fprintf(fp, "STREAM_10K 10000 ./STREAM_10K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "STREAM_10K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_10K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -3958,8 +3958,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -4027,12 +4027,12 @@ protected:
return;
}
fprintf(fp, "STREAM_50K 50000 ./STREAM_50K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "STREAM_50K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_50K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -4120,8 +4120,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -4189,12 +4189,12 @@ protected:
return;
}
fprintf(fp, "STREAM_100K 100000 ./STREAM_100K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "STREAM_100K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_100K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -4282,8 +4282,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -4351,12 +4351,12 @@ protected:
return;
}
fprintf(fp, "STREAM_500K 500000 ./STREAM_500K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "STREAM_500K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_500K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -4444,8 +4444,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -4513,12 +4513,12 @@ protected:
return;
}
fprintf(fp, "STREAM_1M 1000000 ./STREAM_1M\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "STREAM_1M", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_1M", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -4606,8 +4606,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -4675,12 +4675,12 @@ protected:
return;
}
fprintf(fp, "STREAM_2M 2000000 ./STREAM_2M\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "STREAM_2M", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_2M", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -4768,8 +4768,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -4837,12 +4837,12 @@ protected:
return;
}
fprintf(fp, "IP_1K 1000 ./IP_1K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "IP_1K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "IP_1K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -4855,8 +4855,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -4927,12 +4927,12 @@ protected:
return;
}
fprintf(fp, "IP_5K 5000 ./IP_5K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "IP_5K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "IP_5K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -4945,8 +4945,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -5017,12 +5017,12 @@ protected:
return;
}
fprintf(fp, "IP_10K 10000 ./IP_10K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "IP_10K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "IP_10K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5035,8 +5035,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -5107,12 +5107,12 @@ protected:
return;
}
fprintf(fp, "IP_50K 50000 ./IP_50K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "IP_50K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "IP_50K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5125,8 +5125,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -5197,12 +5197,12 @@ protected:
return;
}
fprintf(fp, "IP_100K 100000 ./IP_100K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "IP_100K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "IP_100K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5215,8 +5215,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -5287,12 +5287,12 @@ protected:
return;
}
fprintf(fp, "IP_500K 500000 ./IP_500K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "IP_500K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "IP_500K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5305,8 +5305,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -5377,12 +5377,12 @@ protected:
return;
}
fprintf(fp, "IP_1M 1000000 ./IP_1M\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "IP_1M", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "IP_1M", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5395,8 +5395,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -5467,12 +5467,12 @@ protected:
return;
}
fprintf(fp, "IP_5M 5000000 ./IP_5M\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "IP_5M", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "IP_5M", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5485,8 +5485,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -5557,12 +5557,12 @@ protected:
return;
}
fprintf(fp, "IP_10M 10000000 ./IP_10M\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "IP_10M", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "IP_10M", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5575,8 +5575,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -5647,12 +5647,12 @@ protected:
return;
}
fprintf(fp, "INTEGER_1K 1000 ./INTEGER_1K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "INTEGER_1K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "INTEGER_1K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5665,8 +5665,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -5737,12 +5737,12 @@ protected:
return;
}
fprintf(fp, "INTEGER_5K 5000 ./INTEGER_5K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "INTEGER_5K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "INTEGER_5K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5755,8 +5755,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -5827,12 +5827,12 @@ protected:
return;
}
fprintf(fp, "INTEGER_10K 10000 ./INTEGER_10K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "INTEGER_10K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "INTEGER_10K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5845,8 +5845,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -5917,12 +5917,12 @@ protected:
return;
}
fprintf(fp, "FLAG_1K 1000 ./FLAG_1K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "FLAG_1K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "FLAG_1K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5935,8 +5935,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -6007,12 +6007,12 @@ protected:
return;
}
fprintf(fp, "FLAG_5K 5000 ./FLAG_5K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "FLAG_5K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "FLAG_5K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -6025,8 +6025,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
@@ -6097,12 +6097,12 @@ protected:
return;
}
fprintf(fp, "FLAG_10K 10000 ./FLAG_10K\n");
- fprintf(fp, "COMPILE_PERF 10 ./COMPILE_PERF\n");
- fprintf(fp, "GROUP2COMPILE_PERF 10 ./GROUP2COMPILE_PERF\n");
+ fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
+ fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
fclose(fp);
- generate_compile_sample("COMPILE_PERF", 10);
- generate_group2compile_sample("GROUP2COMPILE_PERF", "FLAG_10K", 10);
+ generate_rule_sample("RULE_PERF", 10);
+ generate_group2rule_sample("GROUP2RULE_PERF", "FLAG_10K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -6115,8 +6115,8 @@ protected:
static void TearDownTestCase() {
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
- system_cmd_rmdir("COMPILE_PERF");
- system_cmd_rmdir("GROUP2COMPILE_PERF");
+ system_cmd_rmdir("RULE_PERF");
+ system_cmd_rmdir("GROUP2RULE_PERF");
}
static struct log_handle *logger;
diff --git a/test/benchmark/benchmark_table_info.conf b/test/benchmark/benchmark_table_info.conf
index 051dcf7..755eb2e 100644
--- a/test/benchmark/benchmark_table_info.conf
+++ b/test/benchmark/benchmark_table_info.conf
@@ -553,25 +553,25 @@
},
{
"table_id":39,
- "table_name":"COMPILE_PERF",
- "table_type":"compile",
- "default_compile_table":39,
+ "table_name":"RULE_PERF",
+ "table_type":"rule",
+ "default_rule_table":39,
"valid_column":9,
"custom": {
- "compile_id":1,
+ "rule_id":1,
"tags":6,
"clause_num":8
}
},
{
"table_id":40,
- "table_name":"GROUP2COMPILE_PERF",
- "table_type":"group2compile",
- "associated_compile_table_id":39,
+ "table_name":"GROUP2RULE_PERF",
+ "table_type":"group2rule",
+ "associated_rule_table_id":39,
"valid_column":6,
"custom": {
"group_id":1,
- "compile_id":2,
+ "rule_id":2,
"not_flag":3,
"virtual_table_name":4,
"clause_index":5
diff --git a/test/file_test_tableinfo.conf b/test/file_test_tableinfo.conf
index 305d3f5..1385d2c 100644
--- a/test/file_test_tableinfo.conf
+++ b/test/file_test_tableinfo.conf
@@ -1,35 +1,35 @@
[
{
"table_id":0,
- "table_name": "NTC_COMPILE",
- "table_type":"compile",
+ "table_name": "NTC_RULE",
+ "table_type":"rule",
"valid_column":8,
"custom": {
- "compile_id":1,
+ "rule_id":1,
"tags":6,
"clause_num":9
}
},
{
"table_id":1,
- "table_name": "WHITE_LIST_COMPILE",
- "table_type":"compile",
+ "table_name": "WHITE_LIST_RULE",
+ "table_type":"rule",
"valid_column":8,
"custom": {
- "compile_id":1,
+ "rule_id":1,
"tags":6,
"clause_num":9
}
},
{
"table_id":2,
- "table_name": "FILE_COMPILE",
- "db_tables": ["NTC_COMPILE", "WHITE_LIST_COMPILE"],
- "default_compile_table":2,
- "table_type":"compile",
+ "table_name": "FILE_RULE",
+ "db_tables": ["NTC_RULE", "WHITE_LIST_RULE"],
+ "default_rule_table":2,
+ "table_type":"rule",
"valid_column":8,
"custom": {
- "compile_id":1,
+ "rule_id":1,
"tags":6,
"clause_num":9
}
@@ -47,13 +47,13 @@
},
{
"table_id":4,
- "table_name":"NTC_GROUP2COMPILE",
- "table_type":"group2compile",
- "associated_compile_table_id":2,
+ "table_name":"NTC_GROUP2RULE",
+ "table_type":"group2rule",
+ "associated_rule_table_id":2,
"valid_column":3,
"custom": {
"group_id":1,
- "compile_id":2,
+ "rule_id":2,
"not_flag":4,
"virtual_table_name":5,
"clause_index":6
diff --git a/test/json_update/corrupted.json b/test/json_update/corrupted.json
index fb491db..0427a91 100644
--- a/test/json_update/corrupted.json
+++ b/test/json_update/corrupted.json
@@ -1,9 +1,9 @@
{
- "compile_table": "COMPILE_DEFAULT",
+ "rule_table": "RULE_DEFAULT",
"group_table": "GROUP",
"rules": [
{
- "compile_id": 1
+ "rule_id": 1,
"service": 1,
"action": 1,
"do_blacklist": 1,
diff --git a/test/json_update/new.json b/test/json_update/new.json
index 07e3156..b99272e 100644
--- a/test/json_update/new.json
+++ b/test/json_update/new.json
@@ -1,10 +1,10 @@
{
- "compile_table": "COMPILE_DEFAULT",
- "group2compile_table": "GROUP2COMPILE_DEFAULT",
+ "rule_table": "RULE_DEFAULT",
+ "group2rule_table": "GROUP2RULE_DEFAULT",
"group2group_table": "GROUP2GROUP",
"rules": [
{
- "compile_id": 2,
+ "rule_id": 2,
"service": 1,
"action": 1,
"do_blacklist": 1,
diff --git a/test/json_update/old.json b/test/json_update/old.json
index 278272b..bddc415 100644
--- a/test/json_update/old.json
+++ b/test/json_update/old.json
@@ -1,10 +1,10 @@
{
- "compile_table": "COMPILE_DEFAULT",
- "group2compile_table": "GROUP2COMPILE_DEFAULT",
+ "rule_table": "RULE_DEFAULT",
+ "group2rule_table": "GROUP2RULE_DEFAULT",
"group2group_table": "GROUP2GROUP",
"rules": [
{
- "compile_id": 1,
+ "rule_id": 1,
"service": 1,
"action": 1,
"do_blacklist": 1,
diff --git a/test/maat_framework_gtest.cpp b/test/maat_framework_gtest.cpp
index f666972..18936da 100644
--- a/test/maat_framework_gtest.cpp
+++ b/test/maat_framework_gtest.cpp
@@ -27,7 +27,7 @@ size_t g_thread_num = 4;
int test_add_expr_command(struct maat *maat_inst, const char *expr_table,
- long long compile_id, int timeout,
+ long long rule_id, int timeout,
const char *keywords)
{
char huge_serv_def[1024 * 2] = {0};
@@ -35,13 +35,13 @@ int test_add_expr_command(struct maat *maat_inst, const char *expr_table,
memset(huge_serv_def, 's', sizeof(huge_serv_def) - 1);
huge_serv_def[sizeof(huge_serv_def) - 1] = '\0';
- int ret = compile_table_set_line(maat_inst, "COMPILE_DEFAULT", MAAT_OP_ADD,
- compile_id, huge_serv_def, 1, timeout);
+ int ret = rule_table_set_line(maat_inst, "RULE_DEFAULT", MAAT_OP_ADD,
+ rule_id, huge_serv_def, 1, timeout);
EXPECT_EQ(ret, 1);
long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, "GROUP2COMPILE_DEFAULT", MAAT_OP_ADD,
- group_id, compile_id, 0, expr_table, 1, timeout);
+ ret = group2rule_table_set_line(maat_inst, "GROUP2RULE_DEFAULT", MAAT_OP_ADD,
+ group_id, rule_id, 0, expr_table, 1, timeout);
EXPECT_EQ(ret, 1);
long long item_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
@@ -52,10 +52,10 @@ int test_add_expr_command(struct maat *maat_inst, const char *expr_table,
return ret;
}
-int del_command(struct maat *maat_inst, int compile_id)
+int del_command(struct maat *maat_inst, int rule_id)
{
- return compile_table_set_line(maat_inst, "COMPILE_DEFAULT", MAAT_OP_DEL,
- compile_id, "null", 1, 0);
+ return rule_table_set_line(maat_inst, "RULE_DEFAULT", MAAT_OP_DEL,
+ rule_id, "null", 1, 0);
}
const char *watched_json = "./json_update/maat.json";
@@ -221,7 +221,7 @@ TEST_F(FlagScan, basic) {
struct maat *maat_inst = FlagScan::_shared_maat_inst;
int flag_table_id = maat_get_table_id(maat_inst, flag_table_name);
- //compile_id:192 flag: 0000 0001 mask: 0000 0011
+ //rule_id:192 flag: 0000 0001 mask: 0000 0011
//scan_data: 0000 1001 or 0000 1101 should hit
long long scan_data = 9;
long long results[ARRAY_SIZE] = {0};
@@ -284,7 +284,7 @@ TEST_F(FlagScan, withExprRegion) {
int flag_table_id = maat_get_table_id(maat_inst, flag_table_name);
int expr_table_id = maat_get_table_id(maat_inst, expr_table_name);
- //compile_id:193 flag: 0000 0010 mask: 0000 0011
+ //rule_id:193 flag: 0000 0010 mask: 0000 0011
//scan_data: 0000 0010 or 0000 0100 should hit
long long flag_scan_data = 2;
long long results[ARRAY_SIZE] = {0};
@@ -322,14 +322,14 @@ TEST_F(FlagScan, withExprRegion) {
state = NULL;
}
-TEST_F(FlagScan, hitMultiCompile) {
+TEST_F(FlagScan, hitMultiRule) {
const char *flag_table_name = "FLAG_CONFIG";
struct maat *maat_inst = FlagScan::_shared_maat_inst;
int flag_table_id = maat_get_table_id(maat_inst, flag_table_name);
- //compile_id:192 flag: 0000 0001 mask: 0000 0011
- //compile_id:194 flag: 0001 0101 mask: 0001 1111
- //scan_data: 0001 0101 should hit compile192 and compile194
+ //rule_id:192 flag: 0000 0001 mask: 0000 0011
+ //rule_id:194 flag: 0001 0101 mask: 0001 1111
+ //scan_data: 0001 0101 should hit rule192 and rule194
long long flag_scan_data = 21;
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
@@ -366,7 +366,7 @@ TEST_F(FlagScan, hitMultiCompile) {
state = NULL;
}
-TEST_F(FlagScan, hitRepeatedCompile) {
+TEST_F(FlagScan, hitRepeatedRule) {
const char *flag_table_name = "FLAG_CONFIG";
struct maat *maat_inst = FlagScan::_shared_maat_inst;
@@ -376,7 +376,7 @@ TEST_F(FlagScan, hitRepeatedCompile) {
int thread_id = 0;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- //compile_id:192 flag: 0000 0001 mask: 0000 0011
+ //rule_id:192 flag: 0000 0001 mask: 0000 0011
//scan_data: 0000 1001 or 0000 1101 should hit
long long flag_scan_data1 = 9;
int ret = maat_scan_flag(maat_inst, flag_table_id, flag_scan_data1, results,
@@ -390,9 +390,9 @@ TEST_F(FlagScan, hitRepeatedCompile) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
- //compile_id:192 flag: 0000 0001 mask: 0000 0011
- //compile_id:194 flag: 0001 0101 mask: 0001 1111
- //scan_data: 0001 0101 should hit compile192 and compile194
+ //rule_id:192 flag: 0000 0001 mask: 0000 0011
+ //rule_id:194 flag: 0001 0101 mask: 0001 1111
+ //scan_data: 0001 0101 should hit rule192 and rule194
long long flag_scan_data2 = 21;
memset(results, 0, sizeof(results));
ret = maat_scan_flag(maat_inst, flag_table_id, flag_scan_data2, results,
@@ -429,7 +429,7 @@ TEST_F(FlagScan, FlagPlus) {
struct maat *maat_inst = FlagScan::_shared_maat_inst;
int flag_table_id = maat_get_table_id(maat_inst, flag_table_name);
- //compile_id:196 flag: 0001 1111 mask: 0000 1111
+ //rule_id:196 flag: 0001 1111 mask: 0000 1111
//scan_data: 0000 1111 or 0001 1111 should hit
long long scan_data1 = 15;
long long results[ARRAY_SIZE] = {0};
@@ -671,19 +671,19 @@ TEST_F(HsStringScan, BackslashR_N_Escape_IncUpdate) {
EXPECT_EQ(ret, MAAT_SCAN_OK);
maat_state_reset(state);
- const char *compile_table_name = "COMPILE_DEFAULT";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
- /* compile table add line */
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile_id, "null", 1, 0);
+ /* rule table add line */
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2compile table add line */
+ /* group2rule table add line */
long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, compile_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* expr table add line */
@@ -702,7 +702,7 @@ TEST_F(HsStringScan, BackslashR_N_Escape_IncUpdate) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 2);
EXPECT_EQ(results[0], 234);
- EXPECT_EQ(results[1], compile_id);
+ EXPECT_EQ(results[1], rule_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -1444,19 +1444,19 @@ TEST_F(HsStringScan, dynamic_config) {
maat_state_reset(state);
- const char *compile_table_name = "COMPILE_DEFAULT";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
- /* compile table add line */
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile_id, "null", 1, 0);
+ /* rule table add line */
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2compile table add line */
+ /* group2rule table add line */
long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, compile_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* expr table add line */
@@ -1474,7 +1474,7 @@ TEST_F(HsStringScan, dynamic_config) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile_id);
+ EXPECT_EQ(results[0], rule_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -1487,14 +1487,14 @@ TEST_F(HsStringScan, dynamic_config) {
group_id, keywords, NULL, 1, 0);
EXPECT_EQ(ret, 1);
- /* group2compile table del line */
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group_id, compile_id, 0, table_name, 1, 0);
+ /* group2rule table del line */
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ group_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- /* compile table del line */
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_DEL,
- compile_id, "null", 1, 0);
+ /* rule table del line */
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
+ rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -1709,19 +1709,19 @@ TEST_F(RsStringScan, BackslashR_N_Escape_IncUpdate) {
EXPECT_EQ(ret, MAAT_SCAN_OK);
maat_state_reset(state);
- const char *compile_table_name = "COMPILE_DEFAULT";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
- /* compile table add line */
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile_id, "null", 1, 0);
+ /* rule table add line */
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2compile table add line */
+ /* group2rule table add line */
long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, compile_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* expr table add line */
@@ -1740,7 +1740,7 @@ TEST_F(RsStringScan, BackslashR_N_Escape_IncUpdate) {
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 2);
EXPECT_EQ(results[0], 234);
- EXPECT_EQ(results[1], compile_id);
+ EXPECT_EQ(results[1], rule_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -2489,19 +2489,19 @@ TEST_F(RsStringScan, dynamic_config) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
- const char *compile_table_name = "COMPILE_DEFAULT";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
- /* compile table add line */
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile_id, "null", 1, 0);
+ /* rule table add line */
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2compile table add line */
+ /* group2rule table add line */
long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, compile_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* expr table add line */
@@ -2519,7 +2519,7 @@ TEST_F(RsStringScan, dynamic_config) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile_id);
+ EXPECT_EQ(results[0], rule_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -2532,14 +2532,14 @@ TEST_F(RsStringScan, dynamic_config) {
group_id, keywords, NULL, 1, 0);
EXPECT_EQ(ret, 1);
- /* group2compile table del line */
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group_id, compile_id, 0, table_name, 1, 0);
+ /* group2rule table del line */
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ group_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- /* compile table del line */
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_DEL,
- compile_id, table_name, 1, 0);
+ /* rule table del line */
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
+ rule_id, table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -2606,8 +2606,8 @@ TEST_F(HsStreamScan, dynamic_config) {
struct maat_state *state = maat_state_new(maat_inst, thread_id);
// STEP 1: add keywords1 and wait scan stream to hit
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = test_add_expr_command(maat_inst, table_name, compile1_id, 0, keywords1);
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = test_add_expr_command(maat_inst, table_name, rule1_id, 0, keywords1);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -2630,7 +2630,7 @@ TEST_F(HsStreamScan, dynamic_config) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -2640,22 +2640,22 @@ TEST_F(HsStreamScan, dynamic_config) {
// STEP 2: Inc config update, use same stream to scan and wait old expr_runtime invalid
random_keyword_generate(keyword_buf, sizeof(keyword_buf));
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = test_add_expr_command(maat_inst, table_name, compile_id, 0, keyword_buf);
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = test_add_expr_command(maat_inst, table_name, rule_id, 0, keyword_buf);
EXPECT_EQ(ret, 1);
- // Inc config has not yet taken effect, stream scan can hit compile
+ // Inc config has not yet taken effect, stream scan can hit rule
ret = maat_stream_scan(sp, scan_data2, strlen(scan_data2), results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
maat_state_reset(state);
sleep(WAIT_FOR_EFFECTIVE_S);
- // Inc config has taken effect, stream reference old expr_runtime, should not hit compile
+ // Inc config has taken effect, stream reference old expr_runtime, should not hit rule
ret = maat_stream_scan(sp, scan_data2, strlen(scan_data2), results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
@@ -2720,8 +2720,8 @@ TEST_F(RsStreamScan, dynamic_config) {
struct maat_state *state = maat_state_new(maat_inst, thread_id);
// STEP 1: add keywords1 and wait scan stream to hit
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = test_add_expr_command(maat_inst, table_name, compile1_id, 0, keywords1);
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = test_add_expr_command(maat_inst, table_name, rule1_id, 0, keywords1);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -2744,7 +2744,7 @@ TEST_F(RsStreamScan, dynamic_config) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -2754,16 +2754,16 @@ TEST_F(RsStreamScan, dynamic_config) {
// STEP 2: Inc config update, use same stream to scan and wait old expr_runtime invalid
random_keyword_generate(keyword_buf, sizeof(keyword_buf));
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = test_add_expr_command(maat_inst, table_name, compile_id, 0, keyword_buf);
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = test_add_expr_command(maat_inst, table_name, rule_id, 0, keyword_buf);
EXPECT_EQ(ret, 1);
- // Inc config has not yet taken effect, stream scan can hit compile
+ // Inc config has not yet taken effect, stream scan can hit rule
ret = maat_stream_scan(sp, scan_data2, strlen(scan_data2), results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -2773,7 +2773,7 @@ TEST_F(RsStreamScan, dynamic_config) {
sleep(WAIT_FOR_EFFECTIVE_S);
- // Inc config has taken effect, stream reference old expr_runtime, should not hit compile
+ // Inc config has taken effect, stream reference old expr_runtime, should not hit rule
ret = maat_stream_scan(sp, scan_data2, strlen(scan_data2), results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
@@ -3183,19 +3183,19 @@ TEST_F(IPScan, RuleUpdates) {
maat_state_reset(state);
- const char *compile_table_name = "COMPILE_DEFAULT";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
- /* compile table add line */
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile_id, "null", 1, 0);
+ /* rule table add line */
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2compile table add line */
+ /* group2rule table add line */
long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, compile_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* ip table add line */
@@ -3210,7 +3210,7 @@ TEST_F(IPScan, RuleUpdates) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile_id);
+ EXPECT_EQ(results[0], rule_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -3223,14 +3223,14 @@ TEST_F(IPScan, RuleUpdates) {
group_id, "100.100.100.100", 0);
EXPECT_EQ(ret, 1);
- /* group2compile table del line */
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group_id, compile_id, 0, table_name, 1, 0);
+ /* group2rule table del line */
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ group_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- /* compile table del line */
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_DEL,
- compile_id, "null", 1, 0);
+ /* rule table del line */
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
+ rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -3256,19 +3256,19 @@ TEST_F(IPScan, RuleChangeClauseId) {
int thread_id = 0;
int ret;
- const char *compile_table_name = "COMPILE_DEFAULT";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
- /* compile table add line */
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile_id, "null", 2, 0);
+ /* rule table add line */
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- /* group2compile table add line */
+ /* group2rule table add line */
long long group_id1 = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id1, compile_id, 0, src_table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group_id1, rule_id, 0, src_table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* ip table add line */
@@ -3277,10 +3277,10 @@ TEST_F(IPScan, RuleChangeClauseId) {
group_id1, "1.1.1.1", 0);
EXPECT_EQ(ret, 1);
- /* group2compile table add line */
+ /* group2rule table add line */
long long group_id2 = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id2, compile_id, 0, dst_table_name, 2, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group_id2, rule_id, 0, dst_table_name, 2, 0);
EXPECT_EQ(ret, 1);
/* ip table add line */
@@ -3319,33 +3319,33 @@ TEST_F(IPScan, RuleChangeClauseId) {
EXPECT_EQ(n_hit_result, 0);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_DEL,
- compile_id, "null", 2, 0);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
+ rule_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile_id, "null", 2, 0);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- /* group2compile table del line */
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group_id1, compile_id, 0, src_table_name, 1, 0);
+ /* group2rule table del line */
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ group_id1, rule_id, 0, src_table_name, 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group_id2, compile_id, 0, dst_table_name, 2, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ group_id2, rule_id, 0, dst_table_name, 2, 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id1, compile_id, 0, src_table_name, 2, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group_id1, rule_id, 0, src_table_name, 2, 0);
EXPECT_EQ(ret, 1);
const char *app_id_table_name = "APP_ID";
int app_id_table_id = maat_get_table_id(maat_inst, app_id_table_name);
- /* group2compile table add line */
+ /* group2rule table add line */
long long group_id3 = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id3, compile_id, 0, app_id_table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group_id3, rule_id, 0, app_id_table_name, 1, 0);
EXPECT_EQ(ret, 1);
@@ -3603,7 +3603,7 @@ TEST_F(GroupScan, VirtualTable) {
sleep(2);
}
-TEST_F(GroupScan, SetScanCompileTable) {
+TEST_F(GroupScan, SetScanRuleTable) {
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
@@ -3614,10 +3614,10 @@ TEST_F(GroupScan, SetScanCompileTable) {
int table_id = maat_get_table_id(maat_inst, table_name);
ASSERT_GE(table_id, 0);
- const char *compile_table_name = "COMPILE_FIREWALL_CONJUNCTION";
- int compile_table_id = maat_get_table_id(maat_inst, compile_table_name);
+ const char *rule_table_name = "RULE_FIREWALL_CONJUNCTION";
+ int rule_table_id = maat_get_table_id(maat_inst, rule_table_name);
- int ret = maat_state_set_scan_compile_table(state, compile_table_id);
+ int ret = maat_state_set_scan_rule_table(state, rule_table_id);
EXPECT_EQ(ret, 0);
struct maat_hit_group hit_group;
@@ -3737,7 +3737,7 @@ TEST_F(NOTLogic, ScanNotAtLast) {
int hit_table_id = maat_get_table_id(maat_inst, hit_table_name);
ASSERT_GT(hit_table_id, 0);
- // scan string_should_hit(HTTP_URL_FILTER) & string_should_not_hit(HTTP_RESPONSE_KEYWORDS) => not hit compile
+ // scan string_should_hit(HTTP_URL_FILTER) & string_should_not_hit(HTTP_RESPONSE_KEYWORDS) => not hit rule
int ret = maat_scan_string(maat_inst, hit_table_id, string_should_hit,
strlen(string_should_hit), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -3762,7 +3762,7 @@ TEST_F(NOTLogic, ScanNotAtLast) {
maat_state_reset(state);
- //scan string_should_hit(HTTP_URL_FILTER) & nothing(HTTP_RESPONSE_KEYWORDS) => hit compile144
+ //scan string_should_hit(HTTP_URL_FILTER) & nothing(HTTP_RESPONSE_KEYWORDS) => hit rule144
ret = maat_scan_string(maat_inst, hit_table_id, string_should_hit,
strlen(string_should_hit), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -3947,7 +3947,7 @@ TEST_F(NOTLogic, ScanNotIP) {
int hit_table_id = maat_get_table_id(maat_inst, hit_table_name);
ASSERT_GT(hit_table_id, 0);
- // scan string_should_hit(HTTP_URL) & hit ip(VIRTUAL_IP_CONFIG) => not hit compile
+ // scan string_should_hit(HTTP_URL) & hit ip(VIRTUAL_IP_CONFIG) => not hit rule
int ret = maat_scan_string(maat_inst, hit_table_id, string_should_hit,
strlen(string_should_hit), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -3975,7 +3975,7 @@ TEST_F(NOTLogic, ScanNotIP) {
maat_state_reset(state);
- // scan string_should_hit(HTTP_URL) & not hit ip(VIRTUAL_IP_CONFIG) => hit compile145
+ // scan string_should_hit(HTTP_URL) & not hit ip(VIRTUAL_IP_CONFIG) => hit rule145
ret = maat_scan_string(maat_inst, hit_table_id, string_should_hit,
strlen(string_should_hit), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -4010,7 +4010,7 @@ TEST_F(NOTLogic, ScanNotWithDistrict) {
int url_table_id = maat_get_table_id(maat_inst, url_table_name);
ASSERT_GT(url_table_id, 0);
- // scan string1(HTTP_URL) & string2(HTTP_REQUEST_HEADER) => not hit compile
+ // scan string1(HTTP_URL) & string2(HTTP_REQUEST_HEADER) => not hit rule
int ret = maat_scan_string(maat_inst, url_table_id, string1,
strlen(string1), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -4033,7 +4033,7 @@ TEST_F(NOTLogic, ScanNotWithDistrict) {
maat_state_reset(state);
- // scan string1(HTTP_URL) & string3(HTTP_REQUEST_HEADER) => hit compile221
+ // scan string1(HTTP_URL) & string3(HTTP_REQUEST_HEADER) => hit rule221
ret = maat_scan_string(maat_inst, url_table_id, string1,
strlen(string1), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -4074,7 +4074,7 @@ TEST_F(NOTLogic, NotUrlAndNotIp) {
int url_table_id = maat_get_table_id(maat_inst, url_table_name);
ASSERT_GT(url_table_id, 0);
- //scan string_should_half_hit(HTTP_URL_FILTER) & hit ip(VIRTUAL_IP_CONFIG) => not hit compile
+ //scan string_should_half_hit(HTTP_URL_FILTER) & hit ip(VIRTUAL_IP_CONFIG) => not hit rule
int ret = maat_scan_string(maat_inst, url_table_id, string_should_half_hit,
strlen(string_should_half_hit), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -4100,7 +4100,7 @@ TEST_F(NOTLogic, NotUrlAndNotIp) {
maat_state_reset(state);
- // scan string_should_half_hit(HTTP_RESPONSE_KEYWORDS) & not hit ip(VIRTUAL_IP_CONFIG) => not hit compile
+ // scan string_should_half_hit(HTTP_RESPONSE_KEYWORDS) & not hit ip(VIRTUAL_IP_CONFIG) => not hit rule
int http_table_id = maat_get_table_id(maat_inst, http_table_name);
ASSERT_GT(http_table_id, 0);
@@ -4124,7 +4124,7 @@ TEST_F(NOTLogic, NotUrlAndNotIp) {
maat_state_reset(state);
- // scan scan string_should_half_hit(HTTP_URL_FILTER) & not hit ip(VIRTUAL_IP_CONFIG) => hit compile146
+ // scan scan string_should_half_hit(HTTP_URL_FILTER) & not hit ip(VIRTUAL_IP_CONFIG) => hit rule146
ret = maat_scan_string(maat_inst, url_table_id, string_should_half_hit,
strlen(string_should_half_hit), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -4155,8 +4155,8 @@ TEST_F(NOTLogic, NotUrlAndNotIp) {
}
TEST_F(NOTLogic, NotPhysicalTable) {
- const char *string1 = "This string ONLY contains not_logic_compile_224_1.";
- const char *string2 = "This string ONLY contains not_logic_compile_224_2.";
+ const char *string1 = "This string ONLY contains not_logic_rule_224_1.";
+ const char *string2 = "This string ONLY contains not_logic_rule_224_2.";
const char *string3 = "This string ONLY contains nothing.";
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
@@ -4172,7 +4172,7 @@ TEST_F(NOTLogic, NotPhysicalTable) {
int vtable_id = maat_get_table_id(maat_inst, vtable_name);
ASSERT_GT(vtable_id, 0);
- // scan hit string1(KEYWORDS_TABLE) & hit string2(HTTP_RESPONSE_KEYWORDS) => not hit compile
+ // scan hit string1(KEYWORDS_TABLE) & hit string2(HTTP_RESPONSE_KEYWORDS) => not hit rule
int ret = maat_scan_string(maat_inst, phy_table_id, string1,
strlen(string1), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -4188,7 +4188,7 @@ TEST_F(NOTLogic, NotPhysicalTable) {
maat_state_reset(state);
- //scan not hit string1(KEYWORDS_TABLE) & hit string2(HTTP_RESPONSE_KEYWORDS) => hit compile224
+ //scan not hit string1(KEYWORDS_TABLE) & hit string2(HTTP_RESPONSE_KEYWORDS) => hit rule224
ret = maat_scan_string(maat_inst, phy_table_id, string3, strlen(string3),
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
@@ -4380,7 +4380,7 @@ TEST_F(NOTLogic, NotClauseAndExcludeGroup1) {
TEST_F(NOTLogic, NotClauseAndExcludeGroup2) {
const char *string1 = "This string ONLY contains mail.string-of-rule-217.com";
const char *string2= "This string ONLY contains www.string-of-rule-217.com";
- const char *string_keywords = "This string contain keywords-for-compile-217";
+ const char *string_keywords = "This string contain keywords-for-rule-217";
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
@@ -4450,7 +4450,7 @@ TEST_F(NOTLogic, SingleNotClause) {
int table_id = maat_get_table_id(maat_inst, table_name);
ASSERT_GT(table_id, 0);
- //string_should_hit(HTTP_NOT_LOGIC_1) => not hit compile
+ //string_should_hit(HTTP_NOT_LOGIC_1) => not hit rule
int ret = maat_scan_string(maat_inst, table_id, string_should_hit,
strlen(string_should_hit), results, ARRAY_SIZE,
&n_hit_result, state);
@@ -4462,7 +4462,7 @@ TEST_F(NOTLogic, SingleNotClause) {
maat_state_reset(state);
- //string nothing(HTTP_NOT_LOGIC_1) => hit compile222
+ //string nothing(HTTP_NOT_LOGIC_1) => hit rule222
ret = maat_scan_string(maat_inst, table_id, string_nothing, strlen(string_nothing),
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
@@ -4479,9 +4479,9 @@ TEST_F(NOTLogic, SingleNotClause) {
TEST_F(NOTLogic, MultiNotClauses) {
const char *string_nothing = "nothing string";
- const char *string1 = "string has not_logic_compile_223_1";
- const char *string2 = "string has not_logic_compile_223_1";
- const char *string3 = "string has not_logic_compile_223_1";
+ const char *string1 = "string has not_logic_rule_223_1";
+ const char *string2 = "string has not_logic_rule_223_1";
+ const char *string3 = "string has not_logic_rule_223_1";
const char *table_name = "HTTP_NOT_LOGIC";
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
@@ -4492,7 +4492,7 @@ TEST_F(NOTLogic, MultiNotClauses) {
int table_id = maat_get_table_id(maat_inst, table_name);
ASSERT_GT(table_id, 0);
- // compile223 = !string1 & !string2 & !string3
+ // rule223 = !string1 & !string2 & !string3
//Case1: scan string1 & !string2 & !string3
int ret = maat_scan_string(maat_inst, table_id, string1, strlen(string1),
results, ARRAY_SIZE, &n_hit_result, state);
@@ -4568,7 +4568,7 @@ TEST_F(NOTLogic, MultiGroupsInOneNotClause) {
struct maat_state *state = maat_state_new(maat_inst, thread_id);
//--------------------------------------
- // Source ASN1 & Dest ASN => not hit compile
+ // Source ASN1 & Dest ASN => not hit rule
//--------------------------------------
int src_table_id = maat_get_table_id(maat_inst, src_asn_table_name);
ASSERT_GT(src_table_id, 0);
@@ -4591,7 +4591,7 @@ TEST_F(NOTLogic, MultiGroupsInOneNotClause) {
maat_state_reset(state);
//--------------------------------------
- // Source ASN2 & Dest ASN => not hit compile
+ // Source ASN2 & Dest ASN => not hit rule
//--------------------------------------
ret = maat_scan_string(maat_inst, src_table_id, src_asn2, strlen(src_asn2),
results, ARRAY_SIZE, &n_hit_result, state);
@@ -4608,7 +4608,7 @@ TEST_F(NOTLogic, MultiGroupsInOneNotClause) {
maat_state_reset(state);
//--------------------------------------
- // Source ASN3 & Dest ASN => not hit compile
+ // Source ASN3 & Dest ASN => not hit rule
//--------------------------------------
ret = maat_scan_string(maat_inst, src_table_id, src_asn3, strlen(src_asn3),
results, ARRAY_SIZE, &n_hit_result, state);
@@ -4624,7 +4624,7 @@ TEST_F(NOTLogic, MultiGroupsInOneNotClause) {
maat_state_reset(state);
- // Source nothing & Dest ASN => hit compile177
+ // Source nothing & Dest ASN => hit rule177
ret = maat_scan_string(maat_inst, src_table_id, src_asn_nothing,
strlen(src_asn_nothing),results, ARRAY_SIZE,
&n_hit_result, state);
@@ -6195,59 +6195,59 @@ protected:
struct maat *TableSchemaTag::_shared_maat_inst;
struct log_handle *TableSchemaTag::logger;
-TEST_F(TableSchemaTag, CompileTable) {
- const char *compile1_table_name = "COMPILE_DEFAULT";
- const char *compile2_table_name = "COMPILE_ALIAS";
- const char *compile3_table_name = "COMPILE_CONJUNCTION";
- const char *g2c_table_name = "GROUP2COMPILE";
+TEST_F(TableSchemaTag, RuleTable) {
+ const char *rule1_table_name = "RULE_DEFAULT";
+ const char *rule2_table_name = "RULE_ALIAS";
+ const char *rule3_table_name = "RULE_CONJUNCTION";
+ const char *g2c_table_name = "GROUP2RULE";
struct maat *maat_inst = TableSchemaTag::_shared_maat_inst;
- //COMPILE_DEFAULT
- int compile1_table_id = maat_get_table_id(maat_inst, compile1_table_name);
- EXPECT_EQ(compile1_table_id, 0);
+ //RULE_DEFAULT
+ int rule1_table_id = maat_get_table_id(maat_inst, rule1_table_name);
+ EXPECT_EQ(rule1_table_id, 0);
- const char *tag1 = maat_get_table_schema_tag(maat_inst, compile1_table_id);
+ const char *tag1 = maat_get_table_schema_tag(maat_inst, rule1_table_id);
EXPECT_TRUE(tag1 == NULL);
- //COMPILE_ALIAS
- int compile2_table_id = maat_get_table_id(maat_inst, compile2_table_name);
- EXPECT_EQ(compile2_table_id, 1);
+ //RULE_ALIAS
+ int rule2_table_id = maat_get_table_id(maat_inst, rule2_table_name);
+ EXPECT_EQ(rule2_table_id, 1);
- const char *tag2 = maat_get_table_schema_tag(maat_inst, compile2_table_id);
+ const char *tag2 = maat_get_table_schema_tag(maat_inst, rule2_table_id);
EXPECT_TRUE(tag2 != NULL);
- int ret = strcmp(tag2, "{\"compile_alias\": \"compile\"}");
+ int ret = strcmp(tag2, "{\"rule_alias\": \"rule\"}");
EXPECT_EQ(ret, 0);
- //COMPILE_CONJUNCTION
- int compile3_table_id = maat_get_table_id(maat_inst, compile3_table_name);
- EXPECT_EQ(compile3_table_id, 2);
+ //RULE_CONJUNCTION
+ int rule3_table_id = maat_get_table_id(maat_inst, rule3_table_name);
+ EXPECT_EQ(rule3_table_id, 2);
- const char *tag3 = maat_get_table_schema_tag(maat_inst, compile3_table_id);
+ const char *tag3 = maat_get_table_schema_tag(maat_inst, rule3_table_id);
EXPECT_TRUE(tag3 != NULL);
- ret = strcmp(tag3, "{\"compile_conjunction\": \"compile\"}");
+ ret = strcmp(tag3, "{\"rule_conjunction\": \"rule\"}");
EXPECT_EQ(ret, 0);
- //GROUP2COMPILE
+ //GROUP2RULE
int g2c_table_id = maat_get_table_id(maat_inst, g2c_table_name);
EXPECT_EQ(g2c_table_id, 3);
const char *tag4 = maat_get_table_schema_tag(maat_inst, g2c_table_id);
EXPECT_TRUE(tag4 != NULL);
- ret = strcmp(tag4, "{\"group2compile\": \"group2compile\"}");
+ ret = strcmp(tag4, "{\"group2rule\": \"group2rule\"}");
EXPECT_EQ(ret, 0);
- //COMPILE_PLUGIN
- const char *plugin_table_name = "COMPILE_PLUGIN";
+ //RULE_PLUGIN
+ const char *plugin_table_name = "RULE_PLUGIN";
int plugin_table_id = maat_get_table_id(maat_inst, plugin_table_name);
EXPECT_EQ(plugin_table_id, 8);
const char *tag5 = maat_get_table_schema_tag(maat_inst, plugin_table_id);
EXPECT_TRUE(tag5 != NULL);
- ret = strcmp(tag5, "{\"compile_plugin\": \"plugin\"}");
+ ret = strcmp(tag5, "{\"rule_plugin\": \"plugin\"}");
EXPECT_EQ(ret, 0);
//HTTP_REGION
@@ -6301,7 +6301,7 @@ TEST_F(TableSchemaTag, CompileTable) {
EXPECT_EQ(ret, 0);
}
-class CompileTable : public testing::Test
+class RuleTable : public testing::Test
{
protected:
static void SetUpTestCase() {
@@ -6331,7 +6331,7 @@ protected:
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
log_fatal(logger, MODULE_FRAMEWORK_GTEST,
- "[%s:%d] create maat instance in CompileTable failed.",
+ "[%s:%d] create maat instance in RuleTable failed.",
__FUNCTION__, __LINE__);
}
}
@@ -6345,15 +6345,15 @@ protected:
static struct maat *_shared_maat_inst;
};
-struct maat *CompileTable::_shared_maat_inst;
-struct log_handle *CompileTable::logger;
+struct maat *RuleTable::_shared_maat_inst;
+struct log_handle *RuleTable::logger;
struct rule_ex_param {
char name[NAME_MAX];
int id;
};
-void compile_ex_param_new(const char *table_name, int table_id, const char *key,
+void rule_ex_param_new(const char *table_name, int table_id, const char *key,
const char *table_line, void **ad, long argl, void *argp)
{
int *counter = (int *)argp;
@@ -6361,7 +6361,7 @@ void compile_ex_param_new(const char *table_name, int table_id, const char *key,
struct rule_ex_param *param = ALLOC(struct rule_ex_param, 1);
- int compile_id = 0;
+ int rule_id = 0;
int service_id = 0;
int action = 0;
int do_blacklist = 0;
@@ -6369,14 +6369,14 @@ void compile_ex_param_new(const char *table_name, int table_id, const char *key,
char tags[1024] = {0};
sscanf(table_line, "%d\t%d\t%d\t%d\t%d\t%s\t%*[^:]:%[^,],%d",
- &compile_id, &service_id, &action, &do_blacklist, &do_log,
+ &rule_id, &service_id, &action, &do_blacklist, &do_log,
tags, param->name, &(param->id));
(*counter)++;
*ad = param;
}
-void compile_ex_param_free(int table_id, void **ad, long argl, void *argp)
+void rule_ex_param_free(int table_id, void **ad, long argl, void *argp)
{
if (*ad == NULL) {
return;
@@ -6387,35 +6387,35 @@ void compile_ex_param_free(int table_id, void **ad, long argl, void *argp)
free(param);
}
-void compile_ex_param_dup(int table_id, void **to, void **from, long argl, void *argp)
+void rule_ex_param_dup(int table_id, void **to, void **from, long argl, void *argp)
{
struct rule_ex_param *from_param = *((struct rule_ex_param **)from);
*((struct rule_ex_param**)to) = from_param;
}
-TEST_F(CompileTable, CompileRuleUpdate) {
- struct maat *maat_inst = CompileTable::_shared_maat_inst;
+TEST_F(RuleTable, RuleRuleUpdate) {
+ struct maat *maat_inst = RuleTable::_shared_maat_inst;
- const char *compile_table_name = "COMPILE_DEFAULT";
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name,
- MAAT_OP_ADD, compile_id, "null", 1, 0);
+ const char *rule_table_name = "RULE_DEFAULT";
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name,
+ MAAT_OP_ADD, rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- ret = compile_table_set_line(maat_inst, compile_table_name,
- MAAT_OP_DEL, compile_id, "null", 1, 0);
+ ret = rule_table_set_line(maat_inst, rule_table_name,
+ MAAT_OP_DEL, rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
}
-TEST_F(CompileTable, Conjunction1) {
+TEST_F(RuleTable, Conjunction1) {
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
const char *scan_data = "i.ytimg.com/vi/OtCNcustg_I/hqdefault.jpg?sqp=-oaymwEZCNAC"
"ELwBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLDOp_5fHMaCA9XZuJdCRv4DNDorMg";
const char *table_name = "HTTP_URL";
- struct maat *maat_inst = CompileTable::_shared_maat_inst;
+ struct maat *maat_inst = RuleTable::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
int table_id = maat_get_table_id(maat_inst, table_name);
ASSERT_GT(table_id, 0);
@@ -6439,14 +6439,14 @@ TEST_F(CompileTable, Conjunction1) {
state = NULL;
}
-TEST_F(CompileTable, Conjunction2) {
+TEST_F(RuleTable, Conjunction2) {
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
const char *scan_data = "i.ytimg.com/vi/OtCNcustg_I/hqdefault.jpg?sqp=-oaymwEZCNACELw"
"BSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLDOp_5fHMaCA9XZuJdCRv4DNDorMg";
const char *table_name = "HTTP_URL";
- struct maat *maat_inst = CompileTable::_shared_maat_inst;
+ struct maat *maat_inst = RuleTable::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
int table_id = maat_get_table_id(maat_inst, table_name);
@@ -6582,7 +6582,7 @@ TEST_F(Policy, PluginRuleTags2) {
EXPECT_EQ(callback_times, 2);
}
-TEST_F(Policy, CompileRuleTags) {
+TEST_F(Policy, RuleRuleTags) {
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
@@ -6617,13 +6617,13 @@ TEST_F(Policy, CompileRuleTags) {
state = NULL;
}
-TEST_F(Policy, CompileEXData) {
+TEST_F(Policy, RuleEXData) {
const char *url = "firewall should hit";
const char *table_name = "HTTP_URL";
- const char *plugin_table_name = "COMPILE_FIREWALL_PLUGIN";
- const char *conj_compile_table_name = "COMPILE_FIREWALL_CONJUNCTION";
- const char *phy_compile_table_name = "COMPILE_FIREWALL_DEFAULT";
+ const char *plugin_table_name = "RULE_FIREWALL_PLUGIN";
+ const char *conj_rule_table_name = "RULE_FIREWALL_CONJUNCTION";
+ const char *phy_rule_table_name = "RULE_FIREWALL_DEFAULT";
const char *expect_name = "I have a name";
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
@@ -6633,19 +6633,19 @@ TEST_F(Policy, CompileEXData) {
int table_id = maat_get_table_id(maat_inst, table_name);
int plugin_table_id = maat_get_table_id(maat_inst, plugin_table_name);
- int conj_compile_table_id = maat_get_table_id(maat_inst, conj_compile_table_name);
- int phy_compile_table_id = maat_get_table_id(maat_inst, phy_compile_table_name);
+ int conj_rule_table_id = maat_get_table_id(maat_inst, conj_rule_table_name);
+ int phy_rule_table_id = maat_get_table_id(maat_inst, phy_rule_table_name);
int ex_data_counter = 0;
int ret = maat_plugin_table_ex_schema_register(maat_inst, plugin_table_name,
- compile_ex_param_new,
- compile_ex_param_free,
- compile_ex_param_dup,
+ rule_ex_param_new,
+ rule_ex_param_free,
+ rule_ex_param_dup,
0, &ex_data_counter);
ASSERT_TRUE(ret == 0);
EXPECT_EQ(ex_data_counter, 2);
- ret = maat_state_set_scan_compile_table(state, conj_compile_table_id);
+ ret = maat_state_set_scan_rule_table(state, conj_rule_table_id);
EXPECT_EQ(ret, 0);
ret = maat_scan_string(maat_inst, table_id, url, strlen(url),
@@ -6658,10 +6658,10 @@ TEST_F(Policy, CompileEXData) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
- int compile_table_ids[ARRAY_SIZE];
- ret = maat_state_get_compile_table_ids(state, results, 1, compile_table_ids);
+ int rule_table_ids[ARRAY_SIZE];
+ ret = maat_state_get_rule_table_ids(state, results, 1, rule_table_ids);
EXPECT_EQ(ret, 1);
- EXPECT_EQ(compile_table_ids[0], phy_compile_table_id);
+ EXPECT_EQ(rule_table_ids[0], phy_rule_table_id);
void *ex_data = maat_plugin_table_get_ex_data(maat_inst, plugin_table_id,
(char *)&results[0], sizeof(long long));
@@ -6710,13 +6710,13 @@ TEST_F(Policy, SubGroup) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
- const char *compile_table_name = "COMPILE_DEFAULT";
- int phy_compile_table_id = maat_get_table_id(maat_inst, compile_table_name);
+ const char *rule_table_name = "RULE_DEFAULT";
+ int phy_rule_table_id = maat_get_table_id(maat_inst, rule_table_name);
- int compile_table_ids[ARRAY_SIZE];
- ret = maat_state_get_compile_table_ids(state, results, 1, compile_table_ids);
+ int rule_table_ids[ARRAY_SIZE];
+ ret = maat_state_get_rule_table_ids(state, results, 1, rule_table_ids);
EXPECT_EQ(ret, 1);
- EXPECT_EQ(compile_table_ids[0], phy_compile_table_id);
+ EXPECT_EQ(rule_table_ids[0], phy_rule_table_id);
maat_state_free(state);
}
@@ -6749,37 +6749,37 @@ TEST_F(Policy, EvaluationOrder) {
EXPECT_EQ(hit_path[0].sub_group_id, 158);
EXPECT_EQ(hit_path[0].top_group_id, 158);
EXPECT_EQ(hit_path[0].clause_index, 2);
- EXPECT_EQ(hit_path[0].compile_id, 168);
+ EXPECT_EQ(hit_path[0].rule_id, 168);
EXPECT_EQ(hit_path[1].vtable_id, table_id);
EXPECT_EQ(hit_path[1].sub_group_id, 157);
EXPECT_EQ(hit_path[1].top_group_id, 157);
EXPECT_EQ(hit_path[1].clause_index, 0);
- EXPECT_EQ(hit_path[1].compile_id, 166);
+ EXPECT_EQ(hit_path[1].rule_id, 166);
EXPECT_EQ(hit_path[2].vtable_id, table_id);
EXPECT_EQ(hit_path[2].sub_group_id, 155);
EXPECT_EQ(hit_path[2].top_group_id, -1);
EXPECT_EQ(hit_path[2].clause_index, -1);
- EXPECT_EQ(hit_path[2].compile_id, -1);
+ EXPECT_EQ(hit_path[2].rule_id, -1);
EXPECT_EQ(hit_path[3].vtable_id, table_id);
EXPECT_EQ(hit_path[3].sub_group_id, 158);
EXPECT_EQ(hit_path[3].top_group_id, 158);
EXPECT_EQ(hit_path[3].clause_index, 6);
- EXPECT_EQ(hit_path[3].compile_id, 168);
+ EXPECT_EQ(hit_path[3].rule_id, 168);
EXPECT_EQ(hit_path[4].vtable_id, table_id);
EXPECT_EQ(hit_path[4].sub_group_id, 158);
EXPECT_EQ(hit_path[4].top_group_id, 158);
EXPECT_EQ(hit_path[4].clause_index, 1);
- EXPECT_EQ(hit_path[4].compile_id, 167);
+ EXPECT_EQ(hit_path[4].rule_id, 167);
EXPECT_EQ(hit_path[5].vtable_id, table_id);
EXPECT_EQ(hit_path[5].sub_group_id, 158);
EXPECT_EQ(hit_path[5].top_group_id, 158);
EXPECT_EQ(hit_path[5].clause_index, 3);
- EXPECT_EQ(hit_path[5].compile_id, 167);
+ EXPECT_EQ(hit_path[5].rule_id, 167);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -6849,7 +6849,7 @@ TEST_F(Policy, NotClauseHitPath) {
EXPECT_EQ(hit_path[0].clause_index, 1);
EXPECT_EQ(hit_path[0].sub_group_id, 249);
EXPECT_EQ(hit_path[0].top_group_id, 249);
- EXPECT_EQ(hit_path[0].compile_id, 228);
+ EXPECT_EQ(hit_path[0].rule_id, 228);
EXPECT_EQ(hit_path[1].Nth_scan, 2);
EXPECT_EQ(hit_path[1].vtable_id, ip_table_id);
@@ -6857,7 +6857,7 @@ TEST_F(Policy, NotClauseHitPath) {
EXPECT_EQ(hit_path[1].clause_index, -1);
EXPECT_EQ(hit_path[1].sub_group_id, 100);
EXPECT_EQ(hit_path[1].top_group_id, 144);
- EXPECT_EQ(hit_path[1].compile_id, -1);
+ EXPECT_EQ(hit_path[1].rule_id, -1);
EXPECT_EQ(hit_path[2].Nth_scan, 2);
EXPECT_EQ(hit_path[2].vtable_id, ip_table_id);
@@ -6865,7 +6865,7 @@ TEST_F(Policy, NotClauseHitPath) {
EXPECT_EQ(hit_path[2].clause_index, -1);
EXPECT_EQ(hit_path[2].sub_group_id, 100);
EXPECT_EQ(hit_path[2].top_group_id, -1);
- EXPECT_EQ(hit_path[2].compile_id, -1);
+ EXPECT_EQ(hit_path[2].rule_id, -1);
EXPECT_EQ(hit_path[3].Nth_scan, 2);
EXPECT_EQ(hit_path[3].vtable_id, ip_table_id);
@@ -6873,7 +6873,7 @@ TEST_F(Policy, NotClauseHitPath) {
EXPECT_EQ(hit_path[3].clause_index, 2);
EXPECT_EQ(hit_path[3].sub_group_id, 250);
EXPECT_EQ(hit_path[3].top_group_id, 250);
- EXPECT_EQ(hit_path[3].compile_id, 228);
+ EXPECT_EQ(hit_path[3].rule_id, 228);
maat_state_free(state);
}
@@ -7482,22 +7482,22 @@ TEST_F(MaatCmd, SetIP) {
size_t n_hit_result = 0;
int thread_id = 0;
const char *ip_table_name = "IP_CONFIG";
- const char *compile_table_name = "COMPILE_DEFAULT";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
maat_reload_log_level(maat_inst, LOG_LEVEL_INFO);
- /* compile table add line */
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile_id, "null", 1, 0);
+ /* rule table add line */
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2compile table add line */
+ /* group2rule table add line */
long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, compile_id, 0, ip_table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group_id, rule_id, 0, ip_table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* item table add line */
@@ -7520,7 +7520,7 @@ TEST_F(MaatCmd, SetIP) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile_id);
+ EXPECT_EQ(results[0], rule_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -7537,7 +7537,7 @@ TEST_F(MaatCmd, SetExpr) {
const char *keywords1 = "Hiredis";
const char *keywords2 = "C Client";
- const char *compile_table_name = "COMPILE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
char keywords[512];
long long results[ARRAY_SIZE] = {0};
@@ -7547,10 +7547,10 @@ TEST_F(MaatCmd, SetExpr) {
struct maat_state *state = maat_state_new(maat_inst, thread_id);
snprintf(keywords, sizeof(keywords), "%s&%s", keywords1, keywords2);
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 2);
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 2);
- test_add_expr_command(maat_inst, table_name, compile_id - 1, 0, keywords);
- test_add_expr_command(maat_inst, table_name, compile_id, 0, keywords);
+ test_add_expr_command(maat_inst, table_name, rule_id - 1, 0, keywords);
+ test_add_expr_command(maat_inst, table_name, rule_id, 0, keywords);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -7561,7 +7561,7 @@ TEST_F(MaatCmd, SetExpr) {
int ret = maat_scan_string(maat_inst, table_id, scan_data, strlen(scan_data),
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
- EXPECT_TRUE(results[0] == compile_id || results[0] == (compile_id - 1));
+ EXPECT_TRUE(results[0] == rule_id || results[0] == (rule_id - 1));
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -7569,10 +7569,10 @@ TEST_F(MaatCmd, SetExpr) {
maat_state_reset(state);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_DEL, compile_id-1,
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL, rule_id-1,
"null", 1, 0);
EXPECT_EQ(ret, 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_DEL, compile_id,
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL, rule_id,
"null", 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -7588,8 +7588,8 @@ TEST_F(MaatCmd, SetExpr) {
maat_state_reset(state);
int timeout = 1;
- compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- test_add_expr_command(maat_inst, table_name, compile_id, timeout, keywords);
+ rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ test_add_expr_command(maat_inst, table_name, rule_id, timeout, keywords);
sleep(timeout + 1);
ret = maat_scan_string(maat_inst, table_id, scan_data, strlen(scan_data),
results, ARRAY_SIZE, &n_hit_result, state);
@@ -7607,8 +7607,8 @@ TEST_F(MaatCmd, SetExpr8) {
const char *scan_data8 = "string1, string2, string3, string4, string5, string6, string7, string8";
const char *scan_data7 = "string1, string2, string3, string4, string5, string6, string7";
- const char *compile_table_name = "COMPILE_DEFAULT";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
const char *table_name = "KEYWORDS_TABLE";
const char *keywords8 = "string1&string2&string3&string4&string5&string6&string7&string8";
@@ -7620,16 +7620,16 @@ TEST_F(MaatCmd, SetExpr8) {
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- /* compile table add line */
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile_id, "null", 1, 0);
+ /* rule table add line */
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2compile table add line */
+ /* group2rule table add line */
long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, compile_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* EXPR_TYPE_AND MATCH_METHOD_SUB */
@@ -7647,7 +7647,7 @@ TEST_F(MaatCmd, SetExpr8) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile_id);
+ EXPECT_EQ(results[0], rule_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -7669,7 +7669,7 @@ TEST_F(MaatCmd, SetExpr8) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile_id);
+ EXPECT_EQ(results[0], rule_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -7684,24 +7684,24 @@ TEST_F(MaatCmd, GroupScan) {
size_t n_hit_result = 0;
int thread_id = 0;
const char *table_name = "HTTP_URL";
- const char *compile_table_name = "COMPILE_DEFAULT";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
int table_id = maat_get_table_id(maat_inst, table_name);
ASSERT_GE(table_id, 0);
- /* compile table add line */
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile_id, "null", 1, 0);
+ /* rule table add line */
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2compile table add line */
+ /* group2rule table add line */
long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, compile_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -7713,7 +7713,7 @@ TEST_F(MaatCmd, GroupScan) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile_id);
+ EXPECT_EQ(results[0], rule_id);
maat_state_free(state);
state = NULL;
@@ -7721,14 +7721,14 @@ TEST_F(MaatCmd, GroupScan) {
/**
* Filter such as URL: http://filtermenot.com => {vtable_id, group_id}
- One compile reference this filter twice, the compile should be hit.
+ One rule reference this filter twice, the rule should be hit.
*/
-TEST_F(MaatCmd, SameFilterRefByOneCompile) {
+TEST_F(MaatCmd, SameFilterRefByOneRule) {
const char *vtable_name = "HTTP_URL_FILTER";
const char *scan_data = "http://filtermenot.com";
const char *keywords = "menot.com";
- const char *compile_table_name = "COMPILE_DEFAULT";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
@@ -7738,19 +7738,19 @@ TEST_F(MaatCmd, SameFilterRefByOneCompile) {
int table_id = maat_get_table_id(maat_inst, vtable_name);
ASSERT_GT(table_id, 0);
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile_id, "null", 2, 0); // compile has two clause
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule_id, "null", 2, 0); // rule has two clause
EXPECT_EQ(ret, 1);
//clause1 & clause2 has same filter => {vtable_id, group_id}
long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, compile_id, 0, vtable_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group_id, rule_id, 0, vtable_name, 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, compile_id, 0, vtable_name, 2, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group_id, rule_id, 0, vtable_name, 2, 0);
EXPECT_EQ(ret, 1);
long long item_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
@@ -7764,7 +7764,7 @@ TEST_F(MaatCmd, SameFilterRefByOneCompile) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile_id);
+ EXPECT_EQ(results[0], rule_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -7879,8 +7879,8 @@ TEST_F(MaatCmd, ReturnRuleIDWithDescendingOrder) {
TEST_F(MaatCmd, SubGroup) {
const char *table_name = "HTTP_URL";
- const char *compile_table_name = "COMPILE_DEFAULT";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
const char *g2g_table_name = "GROUP2GROUP";
const char *scan_data1 = "www.v2ex.com/t/573028#程序员的核心竞争力是什么";
const char *keyword1 = "程序员&核心竞争力";
@@ -7895,40 +7895,40 @@ TEST_F(MaatCmd, SubGroup) {
int table_id = maat_get_table_id(maat_inst, table_name);
ASSERT_GT(table_id, 0);
- /* compile table add line */
- //compile1
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 1, 0);
+ /* rule table add line */
+ //rule1
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //compile2
- long long compile2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile2_id, "null", 1, 0);
+ //rule2
+ long long rule2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule2_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2compile table add line */
- //group1 -> compile1
+ /* group2rule table add line */
+ //group1 -> rule1
long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile1_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- //group1 -> compile2
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile2_id, 0, table_name, 1, 0);
+ //group1 -> rule2
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule2_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- //group2 -> group1 -> compile1
+ //group2 -> group1 -> rule1
long long group2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
ret = group2group_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
group1_id, group2_id, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group2 -> group1 -> compile1
+ /* item1 -> group2 -> group1 -> rule1
\
- \ _ compile2
+ \ _ rule2
*/
long long item_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item_id,
@@ -7942,8 +7942,8 @@ TEST_F(MaatCmd, SubGroup) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 2);
- EXPECT_EQ(results[0], compile2_id);
- EXPECT_EQ(results[1], compile1_id);
+ EXPECT_EQ(results[0], rule2_id);
+ EXPECT_EQ(results[1], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -7951,12 +7951,12 @@ TEST_F(MaatCmd, SubGroup) {
maat_state_reset(state);
- /* item1 -> group2 -> group1 -> compile1
+ /* item1 -> group2 -> group1 -> rule1
\
- \_ X -> compile2
+ \_ X -> rule2
*/
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group1_id, compile2_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ group1_id, rule2_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -7964,7 +7964,7 @@ TEST_F(MaatCmd, SubGroup) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -7974,17 +7974,17 @@ TEST_F(MaatCmd, SubGroup) {
/* item1 -> group2 -> group1 -> X
\
- \_ -> compile2
+ \_ -> rule2
*/
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group1_id, compile1_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ group1_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_DEL,
- compile1_id, "null", 1, 0);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
+ rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, compile2_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group2_id, rule2_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -7992,7 +7992,7 @@ TEST_F(MaatCmd, SubGroup) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile2_id);
+ EXPECT_EQ(results[0], rule2_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -8002,7 +8002,7 @@ TEST_F(MaatCmd, SubGroup) {
/* item1 -> group2 -> group1 -> X
\
- \_ -> compile2
+ \_ -> rule2
item2 -> group3
*/
long long group3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
@@ -8026,21 +8026,21 @@ TEST_F(MaatCmd, SubGroup) {
/* item1 -> group2 -> group1 -> X
\
- \_ -> compile2
+ \_ -> rule2
item2 -> group3
*/
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 1, 0);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile1_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_DEL,
- compile1_id, "null", 1, 0);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
+ rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group1_id, compile1_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ group1_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -8048,7 +8048,7 @@ TEST_F(MaatCmd, SubGroup) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile2_id);
+ EXPECT_EQ(results[0], rule2_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -8060,8 +8060,8 @@ TEST_F(MaatCmd, SubGroup) {
TEST_F(MaatCmd, RefGroup) {
const char *table_name = "HTTP_URL";
- const char* compile_table_name = "COMPILE_DEFAULT";
- const char* g2c_table_name = "GROUP2COMPILE_DEFAULT";
+ const char* rule_table_name = "RULE_DEFAULT";
+ const char* g2c_table_name = "GROUP2RULE_DEFAULT";
const char* scan_data1 = "m.facebook.com/help/2297503110373101?helpref=hc_nav&refid=69";
const char* keyword1 = "something-should-not-hit";
const char* keyword2 = "facebook.com/help/2297503110373101";
@@ -8073,18 +8073,18 @@ TEST_F(MaatCmd, RefGroup) {
ASSERT_GT(table_id, 0);
//TODO: value=0 MAAT_OPT_ENABLE_UPDATE
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 1, 0);
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //group1 -> compile1
+ //group1 -> rule1
long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile1_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> compile1
+ //item1 -> group1 -> rule1
long long item1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item1_id,
group1_id, keyword1, NULL, 1, 0); /* EXPR_TYPE_AND MATCH_METHOD_SUB */
@@ -8092,14 +8092,14 @@ TEST_F(MaatCmd, RefGroup) {
sleep(WAIT_FOR_EFFECTIVE_S);
- /* item1 -> group1 -> X -> compile1
+ /* item1 -> group1 -> X -> rule1
/
/
item2 -> group2
*/
long long group2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, compile1_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group2_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
long long item2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
@@ -8107,17 +8107,17 @@ TEST_F(MaatCmd, RefGroup) {
group2_id, keyword2, NULL, 1, 0);/* EXPR_TYPE_AND MATCH_METHOD_SUB */
EXPECT_EQ(ret, 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_DEL,
- compile1_id, "null", 1, 0);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
+ rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 1, 0);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group1_id, compile1_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ group1_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, compile1_id, 0, table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group2_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -8128,7 +8128,7 @@ TEST_F(MaatCmd, RefGroup) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -8139,42 +8139,42 @@ TEST_F(MaatCmd, RefGroup) {
}
TEST_F(MaatCmd, VirtualTable) {
- const char* compile_table_name = "COMPILE_DEFAULT";
- const char* g2c_table_name = "GROUP2COMPILE_DEFAULT";
+ const char* rule_table_name = "RULE_DEFAULT";
+ const char* g2c_table_name = "GROUP2RULE_DEFAULT";
const char* table_name="HTTP_SIGNATURE";
int thread_id = 0;
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 2, 0);
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- //group1 -> compile1
+ //group1 -> rule1
long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile1_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule1_id, 0,
"HTTP_REQUEST_HEADER", 1, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> compile1
+ //item1 -> group1 -> rule1
long long item1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item1_id,
group1_id, "AppleWebKit", "User-Agent", 0, 0);/*EXPR_TYPE_STRING MATCH_METHOD_SUB */
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
group2_/
*/
long long group2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, compile1_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group2_id, rule1_id, 0,
"HTTP_RESPONSE_HEADER", 2, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
item2 -> group2/
*/
@@ -8221,7 +8221,7 @@ TEST_F(MaatCmd, VirtualTable) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -8230,15 +8230,15 @@ TEST_F(MaatCmd, VirtualTable) {
maat_state_reset(state);
//delete group1
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group1_id, compile1_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ group1_id, rule1_id, 0,
"HTTP_REQUEST_HEADER", 1, 0);
EXPECT_EQ(ret, 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_DEL,
- compile1_id, "null", 2, 0);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
+ rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 1, 0);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -8255,7 +8255,7 @@ TEST_F(MaatCmd, VirtualTable) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -8548,49 +8548,49 @@ void plugin_ex_dup_cb(int table_id, void **to, void **from, long argl, void *arg
*to = u;
}
-TEST_F(MaatCmd, CompileEXData) {
- const char *plugin_table_name = "COMPILE_FIREWALL_PLUGIN";
- const char *compile_table_name = "COMPILE_FIREWALL_DEFAULT";
+TEST_F(MaatCmd, RuleEXData) {
+ const char *plugin_table_name = "RULE_FIREWALL_PLUGIN";
+ const char *rule_table_name = "RULE_FIREWALL_DEFAULT";
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
int *ex_data_counter = MaatCmd::_ex_data_counter;
int plugin_table_id = maat_get_table_id(maat_inst, plugin_table_name);
EXPECT_GT(plugin_table_id, 0);
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "test:compile1,1111", 1, 0);
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "test:rule1,1111", 1, 0);
EXPECT_EQ(ret, 1);
- long long compile2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile2_id, "test:compile2,2222", 1, 0);
+ long long rule2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule2_id, "test:rule2,2222", 1, 0);
sleep(WAIT_FOR_EFFECTIVE_S);
*ex_data_counter = 0;
ret = maat_plugin_table_ex_schema_register(maat_inst, plugin_table_name,
- compile_ex_param_new,
- compile_ex_param_free,
- compile_ex_param_dup,
+ rule_ex_param_new,
+ rule_ex_param_free,
+ rule_ex_param_dup,
0, ex_data_counter);
ASSERT_TRUE(ret == 0);
EXPECT_EQ(*ex_data_counter, 2);
void *ex_data = maat_plugin_table_get_ex_data(maat_inst, plugin_table_id,
- (char *)&compile1_id,
+ (char *)&rule1_id,
sizeof(long long));
ASSERT_TRUE(ex_data != NULL);
struct rule_ex_param *param = (struct rule_ex_param *)ex_data;
EXPECT_EQ(param->id, 1111);
ex_data = maat_plugin_table_get_ex_data(maat_inst, plugin_table_id,
- (char *)&compile2_id,
+ (char *)&rule2_id,
sizeof(long long));
ASSERT_TRUE(ex_data != NULL);
param = (struct rule_ex_param *)ex_data;
EXPECT_EQ(param->id, 2222);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_DEL,
- compile2_id, "test:compile2,2222", 1, 0);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
+ rule2_id, "test:rule2,2222", 1, 0);
sleep(WAIT_FOR_EFFECTIVE_S);
EXPECT_EQ(param->id, 2222);
sleep(2);
@@ -8933,10 +8933,10 @@ TEST_F(MaatCmd, UpdateBoolPlugin) {
//exceed gc_timeout_s, the data pointed by results[idx] has been freed
}
-#define COMPILE_ID_NUMS 1000
-TEST_F(MaatCmd, GroupInMassCompiles) {
- const char* g2c_table_name = "GROUP2COMPILE_DEFAULT";
- const char* compile_table_name = "COMPILE_DEFAULT";
+#define RULE_ID_NUMS 1000
+TEST_F(MaatCmd, GroupInMassRules) {
+ const char* g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char* rule_table_name = "RULE_DEFAULT";
const char* table_url = "HTTP_URL";
const char* table_appid = "APP_ID";
int thread_id = 0;
@@ -8964,42 +8964,42 @@ TEST_F(MaatCmd, GroupInMassCompiles) {
group3_id, "100", NULL, 0);
EXPECT_EQ(ret, 1);
- /* item_url1 -> group1 -> compile[0 ~ COMPILE_ID_NUMS]
+ /* item_url1 -> group1 -> rule[0 ~ RULE_ID_NUMS]
/
item_appid -> group3_/
*/
int i = 0;
- long long compile_id[COMPILE_ID_NUMS] = {0};
- for (i = 0; i < COMPILE_ID_NUMS; i++) {
- compile_id[i] = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile_id[i], "mass_compile", 2, 0);
+ long long rule_id[RULE_ID_NUMS] = {0};
+ for (i = 0; i < RULE_ID_NUMS; i++) {
+ rule_id[i] = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule_id[i], "mass_rule", 2, 0);
EXPECT_EQ(ret, 1);
}
- for (i = 0; i < COMPILE_ID_NUMS; i++) {
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile_id[i], 0, table_url, 0, 0);
+ for (i = 0; i < RULE_ID_NUMS; i++) {
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule_id[i], 0, table_url, 0, 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group3_id, compile_id[i], 0, table_appid, 2, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group3_id, rule_id[i], 0, table_appid, 2, 0);
EXPECT_EQ(ret, 1);
}
- /* item_url2 -> group2 -> target_compile
+ /* item_url2 -> group2 -> target_rule
/
item_appid -> group3_/
*/
- long long target_compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- target_compile_id, "null", 2, 0);
+ long long target_rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ target_rule_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, target_compile_id, 0, table_url, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group2_id, target_rule_id, 0, table_url, 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group3_id, target_compile_id, 0, table_appid, 2, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group3_id, target_rule_id, 0, table_appid, 2, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -9028,7 +9028,7 @@ TEST_F(MaatCmd, GroupInMassCompiles) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], target_compile_id);
+ EXPECT_EQ(results[0], target_rule_id);
ret = maat_scan_not_logic(maat_inst, appid_table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -9058,8 +9058,8 @@ TEST_F(MaatCmd, GroupInMassCompiles) {
}
TEST_F(MaatCmd, HitGroup) {
- const char *compile_table_name = "COMPILE_DEFAULT";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
const char *g2g_table_name = "GROUP2GROUP";
const char *http_sig_table_name = "HTTP_SIGNATURE";
const char *ip_table_name = "IP_CONFIG";
@@ -9068,37 +9068,37 @@ TEST_F(MaatCmd, HitGroup) {
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- /* compile1 */
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 2, 0);
+ /* rule1 */
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- //group1 -> compile1
+ //group1 -> rule1
long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile1_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule1_id, 0,
"HTTP_REQUEST_HEADER", 1, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> compile1
+ //item1 -> group1 -> rule1
long long item1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, http_sig_table_name, MAAT_OP_ADD,
item1_id, group1_id, "hit group item first",
"URL", 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
group21_/
*/
long long group21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group21_id, compile1_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group21_id, rule1_id, 0,
"HTTP_RESPONSE_HEADER", 2, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
group2 -> group21 _/
*/
@@ -9107,7 +9107,7 @@ TEST_F(MaatCmd, HitGroup) {
group21_id, group2_id, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
item2 -> group2 -> group21 _/
*/
@@ -9120,7 +9120,7 @@ TEST_F(MaatCmd, HitGroup) {
/*
item1 -> group1 -> group11
\
- \ -> compile1
+ \ -> rule1
/
item2 -> group2 -> group21 _/
*/
@@ -9129,14 +9129,14 @@ TEST_F(MaatCmd, HitGroup) {
group11_id, group1_id, 0);
EXPECT_EQ(ret, 1);
- //item3 -> group3, group3 is not referenced by any compile.
+ //item3 -> group3, group3 is not referenced by any rule.
long long item3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
long long group3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
ret = ip_table_set_line(maat_inst, ip_table_name, MAAT_OP_ADD, item3_id,
group3_id, "220.181.38.150-220.181.38.151", 0);
EXPECT_EQ(ret, 1);
- //item4 -> group4, group4 is not referenced by any compile.
+ //item4 -> group4, group4 is not referenced by any rule.
long long item4_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
long long group4_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
ret = expr_table_set_line(maat_inst, keywords_table_name, MAAT_OP_ADD,
@@ -9146,7 +9146,7 @@ TEST_F(MaatCmd, HitGroup) {
/*
item1 -> group1 -> group11
/ \
- item5 -> / \ -> compile1
+ item5 -> / \ -> rule1
/
item2 -> group2 -> group21 _/
*/
@@ -9223,7 +9223,7 @@ TEST_F(MaatCmd, HitGroup) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
scan_times = maat_state_get_scan_count(state);
EXPECT_EQ(scan_times, 2);
@@ -9338,8 +9338,8 @@ TEST_F(MaatCmd, HitGroup) {
TEST_F(MaatCmd, HitPathBasic) {
const char *g2g_table_name = "GROUP2GROUP";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
- const char *compile_table_name = "COMPILE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
const char *http_sig_table_name = "HTTP_SIGNATURE";
const char *ip_table_name = "IP_CONFIG";
const char *keywords_table_name = "KEYWORDS_TABLE";
@@ -9347,37 +9347,37 @@ TEST_F(MaatCmd, HitPathBasic) {
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- /* compile1 */
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 2, 0);
+ /* rule1 */
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- //group1 -> compile1
+ //group1 -> rule1
long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile1_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule1_id, 0,
"HTTP_REQUEST_HEADER", 1, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> compile1
+ //item1 -> group1 -> rule1
long long item1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, http_sig_table_name, MAAT_OP_ADD,
item1_id, group1_id, "graph_theory", "URL",
0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
group21_/
*/
long long group21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group21_id, compile1_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group21_id, rule1_id, 0,
"HTTP_RESPONSE_HEADER", 2, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
group2 -> group21 _/
*/
@@ -9386,7 +9386,7 @@ TEST_F(MaatCmd, HitPathBasic) {
group21_id, group2_id, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
item2 -> group2 -> group21 _/
*/
@@ -9399,7 +9399,7 @@ TEST_F(MaatCmd, HitPathBasic) {
/*
item1 -> group1 -> group11
\
- \ -> compile1
+ \ -> rule1
/
item2 -> group2 -> group21 _/
*/
@@ -9408,14 +9408,14 @@ TEST_F(MaatCmd, HitPathBasic) {
group11_id, group1_id, 0);
EXPECT_EQ(ret, 1);
- //item3 -> group3, group3 is not referenced by any compile.
+ //item3 -> group3, group3 is not referenced by any rule.
long long item3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
long long group3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
ret = ip_table_set_line(maat_inst, ip_table_name, MAAT_OP_ADD, item3_id,
group3_id, "220.181.38.148-220.181.38.149", 0);
EXPECT_EQ(ret, 1);
- //item4 -> group4, group4 is not referenced by any compile.
+ //item4 -> group4, group4 is not referenced by any rule.
long long item4_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
long long group4_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
ret = expr_table_set_line(maat_inst, keywords_table_name, MAAT_OP_ADD,
@@ -9463,7 +9463,7 @@ TEST_F(MaatCmd, HitPathBasic) {
EXPECT_EQ(hit_path[path_idx].sub_group_id, group1_id);
EXPECT_EQ(hit_path[path_idx].top_group_id, group11_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, http_req_table_id);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
path_idx++;
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
@@ -9471,7 +9471,7 @@ TEST_F(MaatCmd, HitPathBasic) {
EXPECT_EQ(hit_path[path_idx].sub_group_id, group1_id);
EXPECT_EQ(hit_path[path_idx].top_group_id, -1);
EXPECT_EQ(hit_path[path_idx].vtable_id, http_req_table_id);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
int http_res_table_id = maat_get_table_id(maat_inst, "HTTP_RESPONSE_HEADER");
ASSERT_GT(http_res_table_id, 0);
@@ -9486,7 +9486,7 @@ TEST_F(MaatCmd, HitPathBasic) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, http_res_table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -9503,7 +9503,7 @@ TEST_F(MaatCmd, HitPathBasic) {
EXPECT_EQ(hit_path[path_idx].item_id, item1_id);
EXPECT_EQ(hit_path[path_idx].sub_group_id, group1_id);
EXPECT_EQ(hit_path[path_idx].top_group_id, group11_id);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
path_idx++;
ASSERT_EQ(path_idx, 1);
@@ -9511,7 +9511,7 @@ TEST_F(MaatCmd, HitPathBasic) {
EXPECT_EQ(hit_path[path_idx].item_id, item1_id);
EXPECT_EQ(hit_path[path_idx].sub_group_id, group1_id);
EXPECT_EQ(hit_path[path_idx].top_group_id, group1_id);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile1_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
path_idx++;
ASSERT_EQ(path_idx, 2);
@@ -9520,7 +9520,7 @@ TEST_F(MaatCmd, HitPathBasic) {
EXPECT_EQ(hit_path[path_idx].sub_group_id, group2_id);
EXPECT_EQ(hit_path[path_idx].top_group_id, group21_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, http_res_table_id);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile1_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
path_idx++;
ASSERT_EQ(path_idx, 3);
@@ -9529,7 +9529,7 @@ TEST_F(MaatCmd, HitPathBasic) {
EXPECT_EQ(hit_path[path_idx].sub_group_id, group2_id);
EXPECT_EQ(hit_path[path_idx].top_group_id, -1);
EXPECT_EQ(hit_path[path_idx].vtable_id, http_res_table_id);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
const char* keywords1="In graph theory, a path in a graph is a finite or infinite \
sequence of edges which joins a sequence of vertices which, by most definitions,\
are all distinct (and since the vertices are distinct, so are the edges). ";
@@ -9563,7 +9563,7 @@ that the edges be all directed in the same direction.";
EXPECT_EQ(hit_path[path_idx].sub_group_id, group4_id);
EXPECT_EQ(hit_path[path_idx].top_group_id, -1);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
int ip_table_id = maat_get_table_id(maat_inst, ip_table_name);
ASSERT_GT(ip_table_id, 0);
@@ -9593,7 +9593,7 @@ that the edges be all directed in the same direction.";
EXPECT_EQ(hit_path[path_idx].sub_group_id, group3_id);
EXPECT_EQ(hit_path[path_idx].top_group_id, -1);
EXPECT_EQ(hit_path[path_idx].vtable_id, ip_table_id);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
Nth_scan++;
ret = maat_stream_scan(stream, keywords2, strlen(keywords2), results,
@@ -9617,67 +9617,67 @@ that the edges be all directed in the same direction.";
EXPECT_EQ(hit_path[path_idx].sub_group_id, group4_id);
EXPECT_EQ(hit_path[path_idx].top_group_id, -1);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
maat_stream_free(stream);
maat_state_free(state);
state = NULL;
}
-/* same group in multi compile */
+/* same group in multi rule */
/*
- item1 -> group1 -> compile1
+ item1 -> group1 -> rule1
/
/
item2 -> group2 -> group21
\
\
- item3 -> group3 -> compile2
+ item3 -> group3 -> rule2
\
- \--> compile3
+ \--> rule3
/
item4 -> group4 -/
*/
TEST_F(MaatCmd, HitPathAdvanced) {
const char *g2g_table_name = "GROUP2GROUP";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
- const char *compile_table_name = "COMPILE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
const char *ip_table_name = "IP_CONFIG";
const char *keywords_table_name = "KEYWORDS_TABLE";
int thread_id = 0;
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- /* compile1 */
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 2, 0);
+ /* rule1 */
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- //group1 -> compile1
+ //group1 -> rule1
long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile1_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule1_id, 0,
"KEYWORDS_TABLE", 1, 0); //clause_index:1
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> compile1
+ //item1 -> group1 -> rule1
long long item1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, keywords_table_name, MAAT_OP_ADD,
item1_id, group1_id, "computer_theory", NULL,
0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
group21_/
*/
long long group21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group21_id, compile1_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group21_id, rule1_id, 0,
"KEYWORDS_TABLE", 2, 0); //clause_index:2
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
group2 -> group21 _/
*/
@@ -9686,7 +9686,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
group21_id, group2_id, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
item2 -> group2 -> group21 _/
*/
@@ -9696,30 +9696,30 @@ TEST_F(MaatCmd, HitPathAdvanced) {
0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- //compile2
- long long compile2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile2_id, "null", 2, 0);
+ //rule2
+ long long rule2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule2_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
item2 -> group2 -> group21 _/
\
\
- compile2
+ rule2
*/
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group21_id, compile2_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group21_id, rule2_id, 0,
"KEYWORDS_TABLE", 3, 0); //clause_index:3
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
item2 -> group2 -> group21 _/
\
\
- item3 -> group3 -> compile2
+ item3 -> group3 -> rule2
*/
long long item3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
long long group3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
@@ -9727,40 +9727,40 @@ TEST_F(MaatCmd, HitPathAdvanced) {
group3_id, "220.181.38.168-220.181.38.169", 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group3_id, compile2_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group3_id, rule2_id, 0,
"IP_CONFIG", 4, 0); //clause_index:4
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
item2 -> group2 -> group21 _/
\
\
- item3 -> group3 -> compile2
+ item3 -> group3 -> rule2
\
- \ --> compile3
+ \ --> rule3
*/
- long long compile3_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile3_id, "null", 2, 0);
+ long long rule3_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule3_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group3_id, compile3_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group3_id, rule3_id, 0,
"IP_CONFIG", 5, 0); //clause_index:5
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
/
item2 -> group2 -> group21
\
\
- item3 -> group3 -> compile2
+ item3 -> group3 -> rule2
\
\
- compile3
+ rule3
/
/
item4 -> group4
@@ -9773,8 +9773,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group4_id, compile3_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group4_id, rule3_id, 0,
"KEYWORDS_TABLE", 6, 0); //clause_index:6
EXPECT_EQ(ret, 1);
@@ -9805,14 +9805,14 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, -1);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, -1);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
ret = maat_scan_string(maat_inst, keywords_table_id, http_url_social,
strlen(http_url_social), results, ARRAY_SIZE,
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
n_read = maat_state_get_hit_paths(state, hit_path, sizeof(hit_path));
EXPECT_EQ(n_read, 3);
@@ -9824,7 +9824,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, group1_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, 1);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile1_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
path_idx++;
ASSERT_EQ(path_idx, 1);
@@ -9834,7 +9834,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, group21_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, 2);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile1_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
path_idx++;
ASSERT_EQ(path_idx, 2);
@@ -9844,7 +9844,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, -1);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, -1);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
uint32_t ip_addr;
inet_pton(AF_INET, "220.181.38.168", &ip_addr);
@@ -9856,7 +9856,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile2_id);
+ EXPECT_EQ(results[0], rule2_id);
memset(hit_path, 0, sizeof(hit_path));
n_read = maat_state_get_hit_paths(state, hit_path, sizeof(hit_path));
@@ -9869,7 +9869,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, group1_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, 1);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile1_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
path_idx++;
ASSERT_EQ(path_idx, 1);
@@ -9879,7 +9879,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, group21_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, 3);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile2_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule2_id);
path_idx++;
ASSERT_EQ(path_idx, 2);
@@ -9889,7 +9889,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, -1);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, -1);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
path_idx++;
ASSERT_EQ(path_idx, 3);
@@ -9899,7 +9899,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, group3_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, ip_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, 4);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile2_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule2_id);
path_idx++;
ASSERT_EQ(path_idx, 4);
@@ -9909,7 +9909,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, group21_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, 2);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile1_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
const char *keywords1 = "In theory, basic and advanced is common";
ret = maat_scan_string(maat_inst, keywords_table_id, keywords1,
@@ -9917,7 +9917,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile3_id);
+ EXPECT_EQ(results[0], rule3_id);
memset(hit_path, 0, sizeof(hit_path));
n_read = maat_state_get_hit_paths(state, hit_path, sizeof(hit_path));
@@ -9930,7 +9930,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, group1_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, 1);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile1_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
path_idx++;
ASSERT_EQ(path_idx, 1);
@@ -9940,7 +9940,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, group21_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, 3);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile2_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule2_id);
path_idx++;
ASSERT_EQ(path_idx, 2);
@@ -9950,7 +9950,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, -1);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, -1);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
path_idx++;
ASSERT_EQ(path_idx, 3);
@@ -9960,7 +9960,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, group3_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, ip_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, 5);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile3_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule3_id);
path_idx++;
ASSERT_EQ(path_idx, 4);
@@ -9970,7 +9970,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, group4_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, 6);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile3_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule3_id);
path_idx++;
ASSERT_EQ(path_idx, 5);
@@ -9980,7 +9980,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, group3_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, ip_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, 4);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile2_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule2_id);
path_idx++;
ASSERT_EQ(path_idx, 6);
@@ -9990,7 +9990,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
EXPECT_EQ(hit_path[path_idx].top_group_id, group21_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].clause_index, 2);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile1_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
maat_state_free(state);
state = NULL;
@@ -9998,8 +9998,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
TEST_F(MaatCmd, HitPathHasNotGroup) {
const char *g2g_table_name = "GROUP2GROUP";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
- const char *compile_table_name = "COMPILE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
const char *http_sig_table_name = "HTTP_SIGNATURE";
const char *ip_table_name = "IP_CONFIG";
const char *keywords_table_name = "KEYWORDS_TABLE";
@@ -10007,36 +10007,36 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- /* compile1 */
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 2, 0);
+ /* rule1 */
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- // !group1 -> compile1
+ // !group1 -> rule1
long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile1_id, 1,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule1_id, 1,
"HTTP_REQUEST_HEADER", 1, 0);
EXPECT_EQ(ret, 1);
- // !(item1 -> group1) -> compile1
+ // !(item1 -> group1) -> rule1
long long item1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, http_sig_table_name, MAAT_OP_ADD,
item1_id, group1_id, "math_theory", "URL", 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* !(item1 -> group1) -> compile1
+ /* !(item1 -> group1) -> rule1
/
group21_/
*/
long long group21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group21_id, compile1_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group21_id, rule1_id, 0,
"HTTP_RESPONSE_HEADER", 2, 0);
EXPECT_EQ(ret, 1);
- /* !(item1 -> group1) -> compile1
+ /* !(item1 -> group1) -> rule1
/
group2 -> group21 _/
*/
@@ -10045,7 +10045,7 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
group21_id, group2_id, 0);
EXPECT_EQ(ret, 1);
- /* !(item1 -> group1) -> compile1
+ /* !(item1 -> group1) -> rule1
/
item2 -> group2 -> group21 _/
*/
@@ -10058,7 +10058,7 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
/*
item1 -> group1 -> group11
- !(item1 -> group1) -> compile1
+ !(item1 -> group1) -> rule1
/
item2 -> group2 -> group21 _/
*/
@@ -10067,14 +10067,14 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
group11_id, group1_id, 0);
EXPECT_EQ(ret, 1);
- //item3 -> group3, group3 is not referenced by any compile.
+ //item3 -> group3, group3 is not referenced by any rule.
long long item3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
long long group3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
ret = ip_table_set_line(maat_inst, ip_table_name, MAAT_OP_ADD, item3_id,
group3_id, "220.181.38.158-220.181.38.159", 0);
EXPECT_EQ(ret, 1);
- //item4 -> group4, group4 is not referenced by any compile.
+ //item4 -> group4, group4 is not referenced by any rule.
long long item4_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
long long group4_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
ret = expr_table_set_line(maat_inst, keywords_table_name, MAAT_OP_ADD,
@@ -10123,7 +10123,7 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
EXPECT_EQ(hit_path[path_idx].top_group_id, group11_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, http_req_table_id);
EXPECT_EQ(hit_path[path_idx].NOT_flag, 1);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
path_idx++;
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
@@ -10132,7 +10132,7 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
EXPECT_EQ(hit_path[path_idx].top_group_id, -1);
EXPECT_EQ(hit_path[path_idx].vtable_id, http_req_table_id);
EXPECT_EQ(hit_path[path_idx].NOT_flag, 1);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
int http_res_table_id = maat_get_table_id(maat_inst, "HTTP_RESPONSE_HEADER");
ASSERT_GT(http_res_table_id, 0);
@@ -10147,7 +10147,7 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, http_res_table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -10165,7 +10165,7 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
EXPECT_EQ(hit_path[path_idx].sub_group_id, group1_id);
EXPECT_EQ(hit_path[path_idx].top_group_id, group11_id);
EXPECT_EQ(hit_path[path_idx].NOT_flag, 1);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
path_idx++;
ASSERT_EQ(path_idx, 1);
@@ -10174,7 +10174,7 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
EXPECT_EQ(hit_path[path_idx].sub_group_id, group1_id);
EXPECT_EQ(hit_path[path_idx].top_group_id, group1_id);
EXPECT_EQ(hit_path[path_idx].NOT_flag, 1);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile1_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
path_idx++;
ASSERT_EQ(path_idx, 2);
@@ -10184,7 +10184,7 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
EXPECT_EQ(hit_path[path_idx].top_group_id, group21_id);
EXPECT_EQ(hit_path[path_idx].vtable_id, http_res_table_id);
EXPECT_EQ(hit_path[path_idx].NOT_flag, 0);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile1_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
path_idx++;
ASSERT_EQ(path_idx, 3);
@@ -10194,7 +10194,7 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
EXPECT_EQ(hit_path[path_idx].top_group_id, -1);
EXPECT_EQ(hit_path[path_idx].vtable_id, http_res_table_id);
EXPECT_EQ(hit_path[path_idx].NOT_flag, 0);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
const char *keywords1 = "In math theory, a finite and infinite come up all the time.";
const char *keywords2= "a finite and infinite come up again.";
@@ -10226,7 +10226,7 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
EXPECT_EQ(hit_path[path_idx].top_group_id, -1);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].NOT_flag, 0);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
int ip_table_id = maat_get_table_id(maat_inst, ip_table_name);
ASSERT_GT(ip_table_id, 0);
@@ -10256,7 +10256,7 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
EXPECT_EQ(hit_path[path_idx].top_group_id, -1);
EXPECT_EQ(hit_path[path_idx].vtable_id, ip_table_id);
EXPECT_EQ(hit_path[path_idx].NOT_flag, 0);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
Nth_scan++;
ret = maat_stream_scan(stream, keywords2, strlen(keywords2), results,
@@ -10281,30 +10281,30 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
EXPECT_EQ(hit_path[path_idx].top_group_id, -1);
EXPECT_EQ(hit_path[path_idx].vtable_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].NOT_flag, 0);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
maat_stream_free(stream);
maat_state_free(state);
state = NULL;
}
-TEST_F(MaatCmd, SameSuperGroupRefByMultiCompile) {
+TEST_F(MaatCmd, SameSuperGroupRefByMultiRule) {
int thread_id = 0;
const char *g2g_table_name = "GROUP2GROUP";
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
- const char *compile_table_name = "COMPILE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
const char *http_sig_table_name = "HTTP_SIGNATURE";
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
- /* item5 -> group5 -> group52 -> compile2
+ /* item5 -> group5 -> group52 -> rule2
\
- \ -> compile3
+ \ -> rule3
*/
long long item5_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
long long group5_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
int ret = expr_table_set_line(maat_inst, http_sig_table_name, MAAT_OP_ADD,
item5_id, group5_id,
- "same supergroup referenced by multi compile",
+ "same supergroup referenced by multi rule",
"KEY", 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
@@ -10313,23 +10313,23 @@ TEST_F(MaatCmd, SameSuperGroupRefByMultiCompile) {
group52_id, group5_id, 0);
EXPECT_EQ(ret, 1);
- long long compile2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile2_id, "HTTP_RESPONSE_HEADER", 1, 0);
+ long long rule2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule2_id, "HTTP_RESPONSE_HEADER", 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group52_id, compile2_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group52_id, rule2_id, 0,
"HTTP_RESPONSE_HEADER", 0, 0);
EXPECT_EQ(ret, 1);
- long long compile3_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile3_id, "HTTP_RESPONSE_HEADER", 1, 0);
+ long long rule3_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule3_id, "HTTP_RESPONSE_HEADER", 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group52_id, compile3_id, 0,
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group52_id, rule3_id, 0,
"HTTP_RESPONSE_HEADER", 0, 0);
EXPECT_EQ(ret, 1);
@@ -10342,7 +10342,7 @@ TEST_F(MaatCmd, SameSuperGroupRefByMultiCompile) {
ret = maat_state_set_scan_district(state, http_res_table_id, "KEY", strlen("KEY"));
EXPECT_EQ(ret, 0);
- const char *http_res_key_str = "same supergroup referenced by multi compile";
+ const char *http_res_key_str = "same supergroup referenced by multi rule";
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
struct maat_hit_path hit_path[128];
@@ -10352,8 +10352,8 @@ TEST_F(MaatCmd, SameSuperGroupRefByMultiCompile) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 2);
- EXPECT_EQ(results[0], compile3_id);
- EXPECT_EQ(results[1], compile2_id);
+ EXPECT_EQ(results[0], rule3_id);
+ EXPECT_EQ(results[1], rule2_id);
ret = maat_scan_not_logic(maat_inst, http_res_table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -10368,47 +10368,47 @@ TEST_F(MaatCmd, SameSuperGroupRefByMultiCompile) {
EXPECT_EQ(hit_path[path_idx].item_id, item5_id);
EXPECT_EQ(hit_path[path_idx].sub_group_id, group5_id);
EXPECT_EQ(hit_path[path_idx].top_group_id, group52_id);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile3_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule3_id);
path_idx++;
EXPECT_EQ(hit_path[path_idx].Nth_scan, 1);
EXPECT_EQ(hit_path[path_idx].item_id, item5_id);
EXPECT_EQ(hit_path[path_idx].sub_group_id, group5_id);
EXPECT_EQ(hit_path[path_idx].top_group_id, -1);
- EXPECT_EQ(hit_path[path_idx].compile_id, -1);
+ EXPECT_EQ(hit_path[path_idx].rule_id, -1);
path_idx++;
EXPECT_EQ(hit_path[path_idx].Nth_scan, 1);
EXPECT_EQ(hit_path[path_idx].item_id, item5_id);
EXPECT_EQ(hit_path[path_idx].sub_group_id, group5_id);
EXPECT_EQ(hit_path[path_idx].top_group_id, group52_id);
- EXPECT_EQ(hit_path[path_idx].compile_id, compile2_id);
+ EXPECT_EQ(hit_path[path_idx].rule_id, rule2_id);
maat_state_free(state);
state = NULL;
}
TEST_F(MaatCmd, SameScanStatusWhenClauseUpdate_TSG6419) {
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
- const char* compile_table_name = "COMPILE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char* rule_table_name = "RULE_DEFAULT";
const char* ip_table_name = "IP_PLUS_CONFIG";
const char *app_id_table_name = "APP_ID";
int thread_id = 0;
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 2, 0);
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- /* item11 -> group11 -> clause1 -> compile1
+ /* item11 -> group11 -> clause1 -> rule1
/
item21 -> group21 -> clause2 _/
*/
long long group11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group11_id, compile1_id, 0, ip_table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group11_id, rule1_id, 0, ip_table_name, 1, 0);
EXPECT_EQ(ret, 1);
long long item11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
@@ -10417,8 +10417,8 @@ TEST_F(MaatCmd, SameScanStatusWhenClauseUpdate_TSG6419) {
EXPECT_EQ(ret, 1);
long long group21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group21_id, compile1_id, 0, app_id_table_name, 2, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group21_id, rule1_id, 0, app_id_table_name, 2, 0);
EXPECT_EQ(ret, 1);
long long item21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
@@ -10451,21 +10451,21 @@ TEST_F(MaatCmd, SameScanStatusWhenClauseUpdate_TSG6419) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
- /* item11 -> group11 -> clause1 -> compile1
+ /* item11 -> group11 -> clause1 -> rule1
/
item21 -> group21 -> clause2 _/
item22 -> group22 -> clause3 _/
*/
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_DEL,
- compile1_id, "null", 2, 0);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
+ rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 3, 0);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 3, 0);
EXPECT_EQ(ret, 1);
long long group22_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group22_id, compile1_id, 0, app_id_table_name, 3, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group22_id, rule1_id, 0, app_id_table_name, 3, 0);
EXPECT_EQ(ret, 1);
long long item22_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
@@ -10488,7 +10488,7 @@ TEST_F(MaatCmd, SameScanStatusWhenClauseUpdate_TSG6419) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -10499,25 +10499,25 @@ TEST_F(MaatCmd, SameScanStatusWhenClauseUpdate_TSG6419) {
}
TEST_F(MaatCmd, GroupEdit) {
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
- const char *compile_table_name = "COMPILE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
const char *ip_table_name = "IP_PLUS_CONFIG";
const char *app_id_table_name = "APP_ID";
int thread_id = 0;
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 2, 0);
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- /* item11 -> group11 -> clause1 -> compile1
+ /* item11 -> group11 -> clause1 -> rule1
item21 -> group21 -> clause2 _/
*/
long long group11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group11_id, compile1_id, 0, ip_table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group11_id, rule1_id, 0, ip_table_name, 1, 0);
EXPECT_EQ(ret, 1);
long long item11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
@@ -10526,8 +10526,8 @@ TEST_F(MaatCmd, GroupEdit) {
EXPECT_EQ(ret, 1);
long long group21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group21_id, compile1_id, 0, app_id_table_name, 2, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group21_id, rule1_id, 0, app_id_table_name, 2, 0);
EXPECT_EQ(ret, 1);
long long item21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
@@ -10568,7 +10568,7 @@ TEST_F(MaatCmd, GroupEdit) {
maat_state_reset(state);
- /* item11 -> group11 -> clause1 -> compile1
+ /* item11 -> group11 -> clause1 -> rule1
item21 -> group21 -> clause2 _/
item22 -> /
*/
@@ -10595,7 +10595,7 @@ TEST_F(MaatCmd, GroupEdit) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -10608,7 +10608,7 @@ TEST_F(MaatCmd, GroupEdit) {
EXPECT_EQ(n_read, 2);
maat_state_reset(state);
- /* item11 -> group11 -> clause1 -> compile1
+ /* item11 -> group11 -> clause1 -> rule1
item21 -> group21 -> clause2 _/
*/
ret = interval_table_set_line(maat_inst, app_id_table_name, MAAT_OP_DEL,
@@ -10640,23 +10640,23 @@ TEST_F(MaatCmd, GroupEdit) {
state = NULL;
}
-TEST_F(MaatCmd, CompileDelete_TSG6548) {
- const char* g2c_table_name = "GROUP2COMPILE_DEFAULT";
- const char* compile_table_name = "COMPILE_DEFAULT";
+TEST_F(MaatCmd, RuleDelete_TSG6548) {
+ const char* g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char* rule_table_name = "RULE_DEFAULT";
const char* ip_table_name = "IP_PLUS_CONFIG";
int thread_id = 0;
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 1, 0);
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //item11 -> group11 -> clause1 -> compile1
+ //item11 -> group11 -> clause1 -> rule1
long long group11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group11_id, compile1_id, 0, ip_table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group11_id, rule1_id, 0, ip_table_name, 1, 0);
EXPECT_EQ(ret, 1);
long long item11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
@@ -10679,18 +10679,18 @@ TEST_F(MaatCmd, CompileDelete_TSG6548) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_DEL,
- compile1_id, "null", 1, 0);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
+ rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group11_id, compile1_id, 0, ip_table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ group11_id, rule1_id, 0, ip_table_name, 1, 0);
EXPECT_EQ(ret, 1);
int hit_cnt = 0;
@@ -10702,7 +10702,7 @@ TEST_F(MaatCmd, CompileDelete_TSG6548) {
ARRAY_SIZE, &n_hit_result, state);
if (ret == MAAT_SCAN_HIT) {
hit_cnt++;
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
}
if (ret == MAAT_SCAN_HALF_HIT) {
miss_cnt++;
@@ -10716,25 +10716,25 @@ TEST_F(MaatCmd, CompileDelete_TSG6548) {
}
TEST_F(MaatCmd, UpdateDeadLockDetection) {
- const char* g2c_table_name = "GROUP2COMPILE_DEFAULT";
- const char* compile_table_name = "COMPILE_DEFAULT";
+ const char* g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char* rule_table_name = "RULE_DEFAULT";
const char* table_http_url = "HTTP_URL";
int thread_id = 0;
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 1, 0);
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //group1 -> compile1
+ //group1 -> rule1
long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile1_id, 0, table_http_url, 0, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule1_id, 0, table_http_url, 0, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> compile1
+ //item1 -> group1 -> rule1
long long item1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, table_http_url, MAAT_OP_ADD, item1_id,
group1_id, "part-1", NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
@@ -10755,24 +10755,24 @@ TEST_F(MaatCmd, UpdateDeadLockDetection) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
- long long compile2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile2_id, "null", 1, 0);
+ long long rule2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule2_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //group2 -> compile2
+ //group2 -> rule2
long long group2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, compile2_id, 0, table_http_url, 0, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group2_id, rule2_id, 0, table_http_url, 0, 0);
EXPECT_EQ(ret, 1);
- //item2 -> group2 -> compile2
+ //item2 -> group2 -> rule2
long long item2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, table_http_url, MAAT_OP_ADD, item2_id,
group2_id, "part-2", NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
@@ -10801,22 +10801,22 @@ TEST_F(MaatCmd, UpdateDeadLockDetection) {
}
TEST_F(MaatCmd, StreamScanWhenExprTableIncUpdate) {
- const char* g2c_table_name = "GROUP2COMPILE_DEFAULT";
- const char* compile_table_name = "COMPILE_DEFAULT";
+ const char* g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char* rule_table_name = "RULE_DEFAULT";
const char* scan_table_name = "KEYWORDS_TABLE";
int thread_id = 0;
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 1, 0);
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //group1 -> compile1
+ //group1 -> rule1
long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile1_id, 0, scan_table_name, 0, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule1_id, 0, scan_table_name, 0, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -10837,7 +10837,7 @@ TEST_F(MaatCmd, StreamScanWhenExprTableIncUpdate) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
- //item1 -> group1 -> compile1
+ //item1 -> group1 -> rule1
long long item1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, scan_table_name, MAAT_OP_ADD,
item1_id, group1_id, "stream-keywords-001-inc-update",
@@ -10864,7 +10864,7 @@ TEST_F(MaatCmd, StreamScanWhenExprTableIncUpdate) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -10876,25 +10876,25 @@ TEST_F(MaatCmd, StreamScanWhenExprTableIncUpdate) {
}
TEST_F(MaatCmd, StreamScanSegfaultWhenVersionRollBack_TSG6324) {
- const char* g2c_table_name = "GROUP2COMPILE_DEFAULT";
- const char* compile_table_name = "COMPILE_DEFAULT";
+ const char* g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char* rule_table_name = "RULE_DEFAULT";
const char* scan_table_name = "KEYWORDS_TABLE";
int thread_id = 0;
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 1, 0);
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //group1 -> compile1
+ //group1 -> rule1
long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile1_id, 0, scan_table_name, 0, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule1_id, 0, scan_table_name, 0, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> compile1
+ //item1 -> group1 -> rule1
long long item1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, scan_table_name, MAAT_OP_ADD, item1_id,
group1_id, "stream-keywords-002", NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
@@ -10914,7 +10914,7 @@ TEST_F(MaatCmd, StreamScanSegfaultWhenVersionRollBack_TSG6324) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
@@ -10923,7 +10923,7 @@ TEST_F(MaatCmd, StreamScanSegfaultWhenVersionRollBack_TSG6324) {
//DON'T DO THIS!!!
//Roll back version, trigger full update.
//This operation generates FATAL logs in test_maat_redis.log.yyyy-mm-dd.
- //For example: Add group 22 vt_id 0 to clause 2 of compile 979 failed, group is already existed
+ //For example: Add group 22 vt_id 0 to clause 2 of rule 979 failed, group is already existed
maat_cmd_incrby(maat_inst, "MAAT_VERSION", -100);
//Wating for scanner garbage collect expiration.
@@ -10943,32 +10943,32 @@ TEST_F(MaatCmd, StreamScanSegfaultWhenVersionRollBack_TSG6324) {
}
TEST_F(MaatCmd, IPAndStreamScanWhenIncUpdate) {
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
- const char *compile_table_name = "COMPILE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
const char *expr_table_name = "KEYWORDS_TABLE";
const char *ip_table_name = "IP_PLUS_CONFIG";
int thread_id = 0;
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 2, 0);
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- //group1 -> compile1
+ //group1 -> rule1
long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile1_id, 0, expr_table_name, 0, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule1_id, 0, expr_table_name, 0, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> compile1
+ //item1 -> group1 -> rule1
long long item1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, expr_table_name, MAAT_OP_ADD, item1_id,
group1_id, "stream-keywords-003", NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
item2 -> group2 --/
*/
@@ -10978,8 +10978,8 @@ TEST_F(MaatCmd, IPAndStreamScanWhenIncUpdate) {
group2_id, "100.100.100.1", 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, compile1_id, 0, ip_table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group2_id, rule1_id, 0, ip_table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -11002,10 +11002,10 @@ TEST_F(MaatCmd, IPAndStreamScanWhenIncUpdate) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
- //add compile2 for compile runtime inc update
- long long compile2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile2_id, "null", 1, 0);
+ //add rule2 for rule runtime inc update
+ long long rule2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule2_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -11019,14 +11019,14 @@ TEST_F(MaatCmd, IPAndStreamScanWhenIncUpdate) {
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
/*
- becase compile1_id has been returned, maat_scan_xx will not return duplicate compile_id again
+ becase rule1_id has been returned, maat_scan_xx will not return duplicate rule_id again
*/
table_id = maat_get_table_id(maat_inst, ip_table_name);
ASSERT_GT(table_id, 0);
@@ -11044,33 +11044,33 @@ TEST_F(MaatCmd, IPAndStreamScanWhenIncUpdate) {
}
TEST_F(MaatCmd, IPAndStreamScanWhenFullUpdate) {
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
- const char *compile_table_name = "COMPILE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
const char *ip_table_name = "IP_PLUS_CONFIG";
const char *expr_table_name = "KEYWORDS_TABLE";
int thread_id = 0;
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 1, 0);
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //group1 -> compile1
+ //group1 -> rule1
long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile1_id, 0, expr_table_name, 0, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule1_id, 0, expr_table_name, 0, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> compile1
+ //item1 -> group1 -> rule1
long long item1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, expr_table_name, MAAT_OP_ADD,
item1_id, group1_id, "stream-keywords-004",
NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
item2 -> group2 --/
*/
@@ -11080,8 +11080,8 @@ TEST_F(MaatCmd, IPAndStreamScanWhenFullUpdate) {
item2_id, group2_id, "100.100.100.2", 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, compile1_id, 0, ip_table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group2_id, rule1_id, 0, ip_table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -11124,8 +11124,8 @@ TEST_F(MaatCmd, IPAndStreamScanWhenFullUpdate) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
- /* maat_state keep the compile_rt version when maat_state_new().
- After full updating, new compile_rt version is different from that of maat_state,
+ /* maat_state keep the rule_rt version when maat_state_new().
+ After full updating, new rule_rt version is different from that of maat_state,
so MAAT_SCAN_HIT will never happen.
*/
table_id = maat_get_table_id(maat_inst, ip_table_name);
@@ -11144,8 +11144,8 @@ TEST_F(MaatCmd, IPAndStreamScanWhenFullUpdate) {
}
TEST_F(MaatCmd, IPAndStringScanWhenIncUpdate) {
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
- const char *compile_table_name = "COMPILE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
const char *expr_table_name = "HTTP_URL";
const char *ip_table_name = "IP_PLUS_CONFIG";
const char *keywords = "IP&stringinc";
@@ -11153,24 +11153,24 @@ TEST_F(MaatCmd, IPAndStringScanWhenIncUpdate) {
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 2, 0);
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- //group1 -> compile1
+ //group1 -> rule1
long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile1_id, 0, expr_table_name, 0, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule1_id, 0, expr_table_name, 0, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> compile1
+ //item1 -> group1 -> rule1
long long item1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, expr_table_name, MAAT_OP_ADD, item1_id,
group1_id, keywords, NULL, 1, 0); /*EXPR_TYPE_AND MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
item2 -> group2 --/
*/
@@ -11180,8 +11180,8 @@ TEST_F(MaatCmd, IPAndStringScanWhenIncUpdate) {
group2_id, "100.100.100.1", 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, compile1_id, 0, ip_table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group2_id, rule1_id, 0, ip_table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -11204,10 +11204,10 @@ TEST_F(MaatCmd, IPAndStringScanWhenIncUpdate) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
- //add compile2 for compile runtime inc update
- long long compile2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile2_id, "null", 1, 0);
+ //add rule2 for rule runtime inc update
+ long long rule2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule2_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -11220,14 +11220,14 @@ TEST_F(MaatCmd, IPAndStringScanWhenIncUpdate) {
results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
- EXPECT_EQ(results[0], compile1_id);
+ EXPECT_EQ(results[0], rule1_id);
ret = maat_scan_not_logic(maat_inst, table_id, results, ARRAY_SIZE,
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
/*
- becase compile1_id has been returned, maat_scan_xx will not return duplicate compile_id again
+ becase rule1_id has been returned, maat_scan_xx will not return duplicate rule_id again
*/
table_id = maat_get_table_id(maat_inst, ip_table_name);
ASSERT_GT(table_id, 0);
@@ -11244,8 +11244,8 @@ TEST_F(MaatCmd, IPAndStringScanWhenIncUpdate) {
}
TEST_F(MaatCmd, IPAndStringScanWhenFullupdate) {
- const char *g2c_table_name = "GROUP2COMPILE_DEFAULT";
- const char *compile_table_name = "COMPILE_DEFAULT";
+ const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *rule_table_name = "RULE_DEFAULT";
const char *ip_table_name = "IP_PLUS_CONFIG";
const char *expr_table_name = "HTTP_URL";
const char *keywords = "IP&string";
@@ -11253,24 +11253,24 @@ TEST_F(MaatCmd, IPAndStringScanWhenFullupdate) {
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- long long compile1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, compile_table_name, MAAT_OP_ADD,
- compile1_id, "null", 1, 0);
+ long long rule1_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
+ rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //group1 -> compile1
+ //group1 -> rule1
long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, compile1_id, 0, expr_table_name, 0, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group1_id, rule1_id, 0, expr_table_name, 0, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> compile1
+ //item1 -> group1 -> rule1
long long item1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, expr_table_name, MAAT_OP_ADD, item1_id,
group1_id, keywords, "null", 1, 0); /*EXPR_TYPE_AND MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> compile1
+ /* item1 -> group1 -> rule1
/
item2 -> group2 --/
*/
@@ -11280,8 +11280,8 @@ TEST_F(MaatCmd, IPAndStringScanWhenFullupdate) {
group2_id, "100.100.100.3", 0);
EXPECT_EQ(ret, 1);
- ret = group2compile_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, compile1_id, 0, ip_table_name, 1, 0);
+ ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ group2_id, rule1_id, 0, ip_table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -11323,8 +11323,8 @@ TEST_F(MaatCmd, IPAndStringScanWhenFullupdate) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
- /* maat_state keep the compile_rt version when maat_state_new().
- After full updating, new compile_rt version is different from that of maat_state,
+ /* maat_state keep the rule_rt version when maat_state_new().
+ After full updating, new rule_rt version is different from that of maat_state,
so MAAT_SCAN_HIT will never happen.
*/
table_id = maat_get_table_id(maat_inst, ip_table_name);
diff --git a/test/maat_framework_perf_gtest.cpp b/test/maat_framework_perf_gtest.cpp
index fee8c9e..6dcc07f 100644
--- a/test/maat_framework_perf_gtest.cpp
+++ b/test/maat_framework_perf_gtest.cpp
@@ -34,15 +34,15 @@ static void
test_add_expr_command(struct maat *maat_inst, const char *table_name,
const char *keywords)
{
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, "COMPILE_DEFAULT",
- MAAT_OP_ADD, compile_id, "null",
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, "RULE_DEFAULT",
+ MAAT_OP_ADD, rule_id, "null",
1, 0);
EXPECT_EQ(ret, 1);
long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, "GROUP2COMPILE_DEFAULT",
- MAAT_OP_ADD, group_id, compile_id,
+ ret = group2rule_table_set_line(maat_inst, "GROUP2RULE_DEFAULT",
+ MAAT_OP_ADD, group_id, rule_id,
0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
@@ -56,15 +56,15 @@ static void
test_add_ip_command(struct maat *maat_inst, const char *table_name,
const char *ip)
{
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, "COMPILE_DEFAULT",
- MAAT_OP_ADD, compile_id, "null",
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, "RULE_DEFAULT",
+ MAAT_OP_ADD, rule_id, "null",
1, 0);
EXPECT_EQ(ret, 1);
long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, "GROUP2COMPILE_DEFAULT",
- MAAT_OP_ADD, group_id, compile_id,
+ ret = group2rule_table_set_line(maat_inst, "GROUP2RULE_DEFAULT",
+ MAAT_OP_ADD, group_id, rule_id,
0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
@@ -78,15 +78,15 @@ static void
test_add_integer_command(struct maat *maat_inst, const char *table_name,
int low_boundary, int up_boundary)
{
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, "COMPILE_DEFAULT",
- MAAT_OP_ADD, compile_id, "null",
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, "RULE_DEFAULT",
+ MAAT_OP_ADD, rule_id, "null",
1, 0);
EXPECT_EQ(ret, 1);
long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, "GROUP2COMPILE_DEFAULT",
- MAAT_OP_ADD, group_id, compile_id,
+ ret = group2rule_table_set_line(maat_inst, "GROUP2RULE_DEFAULT",
+ MAAT_OP_ADD, group_id, rule_id,
0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
@@ -102,15 +102,15 @@ static void
test_add_flag_command(struct maat *maat_inst, const char *table_name,
long long flag, long long flag_mask)
{
- long long compile_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
- int ret = compile_table_set_line(maat_inst, "COMPILE_DEFAULT",
- MAAT_OP_ADD, compile_id, "null",
+ long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
+ int ret = rule_table_set_line(maat_inst, "RULE_DEFAULT",
+ MAAT_OP_ADD, rule_id, "null",
1, 0);
EXPECT_EQ(ret, 1);
long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2compile_table_set_line(maat_inst, "GROUP2COMPILE_DEFAULT",
- MAAT_OP_ADD, group_id, compile_id,
+ ret = group2rule_table_set_line(maat_inst, "GROUP2RULE_DEFAULT",
+ MAAT_OP_ADD, group_id, rule_id,
0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
diff --git a/test/maat_json.json b/test/maat_json.json
index c9961e3..234091f 100644
--- a/test/maat_json.json
+++ b/test/maat_json.json
@@ -1,6 +1,6 @@
{
- "compile_table": "COMPILE_DEFAULT",
- "group2compile_table": "GROUP2COMPILE_DEFAULT",
+ "rule_table": "RULE_DEFAULT",
+ "group2rule_table": "GROUP2RULE_DEFAULT",
"group2group_table": "GROUP2GROUP",
"groups": [
{
@@ -210,7 +210,7 @@
],
"rules": [
{
- "compile_id": 123,
+ "rule_id": 123,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -257,7 +257,7 @@
]
},
{
- "compile_id": 124,
+ "rule_id": 124,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -286,7 +286,7 @@
]
},
{
- "compile_id": 125,
+ "rule_id": 125,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -312,7 +312,7 @@
]
},
{
- "compile_id": 126,
+ "rule_id": 126,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -352,7 +352,7 @@
]
},
{
- "compile_id": 128,
+ "rule_id": 128,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -379,7 +379,7 @@
]
},
{
- "compile_id": 129,
+ "rule_id": 129,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -405,7 +405,7 @@
]
},
{
- "compile_id": 130,
+ "rule_id": 130,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -431,7 +431,7 @@
]
},
{
- "compile_id": 131,
+ "rule_id": 131,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -457,7 +457,7 @@
]
},
{
- "compile_id": 132,
+ "rule_id": 132,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -483,7 +483,7 @@
]
},
{
- "compile_id": 133,
+ "rule_id": 133,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -509,7 +509,7 @@
]
},
{
- "compile_id": 134,
+ "rule_id": 134,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -535,7 +535,7 @@
]
},
{
- "compile_id": 136,
+ "rule_id": 136,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -561,7 +561,7 @@
]
},
{
- "compile_id": 137,
+ "rule_id": 137,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -587,7 +587,7 @@
]
},
{
- "compile_id": 138,
+ "rule_id": 138,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -615,7 +615,7 @@
]
},
{
- "compile_id": 139,
+ "rule_id": 139,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -643,7 +643,7 @@
]
},
{
- "compile_id": 140,
+ "rule_id": 140,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -669,17 +669,17 @@
]
},
{
- "compile_id": 141,
+ "rule_id": 141,
"service": 1,
"action": 1,
"do_blacklist": 1,
"do_log": 1,
"user_region": "Something:I\\bhave\\ba\\bname,7799",
- "compile_table_name": "COMPILE_ALIAS",
+ "rule_table_name": "RULE_ALIAS",
"is_valid": "yes",
"groups": [
{
- "g2c_table_name": "GROUP2COMPILE_ALIAS",
+ "g2c_table_name": "GROUP2RULE_ALIAS",
"virtual_table": "HTTP_URL",
"group_name": "141_url_group",
"group_id": 119,
@@ -697,7 +697,7 @@
]
},
{
- "compile_id": 142,
+ "rule_id": 142,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -723,7 +723,7 @@
]
},
{
- "compile_id": 143,
+ "rule_id": 143,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -766,7 +766,7 @@
]
},
{
- "compile_id": 144,
+ "rule_id": 144,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -809,7 +809,7 @@
]
},
{
- "compile_id": 145,
+ "rule_id": 145,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -841,7 +841,7 @@
]
},
{
- "compile_id": 146,
+ "rule_id": 146,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -892,7 +892,7 @@
]
},
{
- "compile_id": 147,
+ "rule_id": 147,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -911,7 +911,7 @@
"table_name": "KEYWORDS_TABLE",
"table_type": "expr",
"table_content": {
- "keywords": "clause0-in-compile-147",
+ "keywords": "clause0-in-rule-147",
"expr_type": "and"
}
}
@@ -928,7 +928,7 @@
"table_name": "KEYWORDS_TABLE",
"table_type": "expr",
"table_content": {
- "keywords": "clause1-in-compile-147",
+ "keywords": "clause1-in-rule-147",
"expr_type": "and"
}
}
@@ -945,7 +945,7 @@
"table_name": "KEYWORDS_TABLE",
"table_type": "expr",
"table_content": {
- "keywords": "clause2-in-compile-147",
+ "keywords": "clause2-in-rule-147",
"expr_type": "and"
}
}
@@ -962,7 +962,7 @@
"table_name": "KEYWORDS_TABLE",
"table_type": "expr",
"table_content": {
- "keywords": "clause3-in-compile-147",
+ "keywords": "clause3-in-rule-147",
"expr_type": "and"
}
}
@@ -979,7 +979,7 @@
"table_name": "KEYWORDS_TABLE",
"table_type": "expr",
"table_content": {
- "keywords": "clause4-in-compile-147",
+ "keywords": "clause4-in-rule-147",
"expr_type": "and"
}
}
@@ -996,7 +996,7 @@
"table_name": "KEYWORDS_TABLE",
"table_type": "expr",
"table_content": {
- "keywords": "clause5-in-compile-147",
+ "keywords": "clause5-in-rule-147",
"expr_type": "and"
}
}
@@ -1013,7 +1013,7 @@
"table_name": "KEYWORDS_TABLE",
"table_type": "expr",
"table_content": {
- "keywords": "clause6-in-compile-147",
+ "keywords": "clause6-in-rule-147",
"expr_type": "and"
}
}
@@ -1030,7 +1030,7 @@
"table_name": "KEYWORDS_TABLE",
"table_type": "expr",
"table_content": {
- "keywords": "clause7-in-compile-147",
+ "keywords": "clause7-in-rule-147",
"expr_type": "and"
}
}
@@ -1039,7 +1039,7 @@
]
},
{
- "compile_id": 148,
+ "rule_id": 148,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -1065,7 +1065,7 @@
]
},
{
- "compile_id": 149,
+ "rule_id": 149,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1092,7 +1092,7 @@
]
},
{
- "compile_id": 150,
+ "rule_id": 150,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1133,7 +1133,7 @@
]
},
{
- "compile_id": 151,
+ "rule_id": 151,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1159,7 +1159,7 @@
]
},
{
- "compile_id": 152,
+ "rule_id": 152,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1203,7 +1203,7 @@
]
},
{
- "compile_id": 153,
+ "rule_id": 153,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1246,7 +1246,7 @@
]
},
{
- "compile_id": 154,
+ "rule_id": 154,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1272,7 +1272,7 @@
]
},
{
- "compile_id": 155,
+ "rule_id": 155,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1298,7 +1298,7 @@
]
},
{
- "compile_id": 156,
+ "rule_id": 156,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -1325,7 +1325,7 @@
]
},
{
- "compile_id": 157,
+ "rule_id": 157,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1351,7 +1351,7 @@
]
},
{
- "compile_id": 158,
+ "rule_id": 158,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1376,7 +1376,7 @@
]
},
{
- "compile_id": 159,
+ "rule_id": 159,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1401,7 +1401,7 @@
]
},
{
- "compile_id": 160,
+ "rule_id": 160,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1433,7 +1433,7 @@
]
},
{
- "compile_id": 161,
+ "rule_id": 161,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1487,7 +1487,7 @@
]
},
{
- "compile_id": 162,
+ "rule_id": 162,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1508,7 +1508,7 @@
]
},
{
- "compile_id": 163,
+ "rule_id": 163,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1529,7 +1529,7 @@
]
},
{
- "compile_id": 164,
+ "rule_id": 164,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -1555,7 +1555,7 @@
]
},
{
- "compile_id": 165,
+ "rule_id": 165,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -1597,7 +1597,7 @@
]
},
{
- "compile_id": 166,
+ "rule_id": 166,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -1624,7 +1624,7 @@
]
},
{
- "compile_id": 167,
+ "rule_id": 167,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -1658,7 +1658,7 @@
]
},
{
- "compile_id": 168,
+ "rule_id": 168,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -1682,7 +1682,7 @@
]
},
{
- "compile_id": 169,
+ "rule_id": 169,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1709,7 +1709,7 @@
]
},
{
- "compile_id": 170,
+ "rule_id": 170,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1735,7 +1735,7 @@
]
},
{
- "compile_id": 171,
+ "rule_id": 171,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -1761,7 +1761,7 @@
]
},
{
- "compile_id": 177,
+ "rule_id": 177,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -1784,7 +1784,7 @@
]
},
{
- "compile_id": 178,
+ "rule_id": 178,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -1807,7 +1807,7 @@
]
},
{
- "compile_id": 179,
+ "rule_id": 179,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -1833,7 +1833,7 @@
]
},
{
- "compile_id": 180,
+ "rule_id": 180,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -1862,7 +1862,7 @@
]
},
{
- "compile_id": 181,
+ "rule_id": 181,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -1891,7 +1891,7 @@
]
},
{
- "compile_id": 182,
+ "rule_id": 182,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -1917,7 +1917,7 @@
]
},
{
- "compile_id": 184,
+ "rule_id": 184,
"user_region": "APP_ID=6006740;Liumengyan-Bugreport-20210515",
"description": "Hulu",
"is_valid": "yes",
@@ -1943,7 +1943,7 @@
]
},
{
- "compile_id": 185,
+ "rule_id": 185,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -1984,7 +1984,7 @@
]
},
{
- "compile_id": 186,
+ "rule_id": 186,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -2026,7 +2026,7 @@
]
},
{
- "compile_id": 187,
+ "rule_id": 187,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -2068,7 +2068,7 @@
]
},
{
- "compile_id": 188,
+ "rule_id": 188,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -2110,7 +2110,7 @@
]
},
{
- "compile_id": 189,
+ "rule_id": 189,
"is_valid": "yes",
"do_log": 0,
"action": 0,
@@ -2137,7 +2137,7 @@
]
},
{
- "compile_id": 190,
+ "rule_id": 190,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -2164,7 +2164,7 @@
]
},
{
- "compile_id": 191,
+ "rule_id": 191,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -2190,7 +2190,7 @@
]
},
{
- "compile_id": 192,
+ "rule_id": 192,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -2216,7 +2216,7 @@
]
},
{
- "compile_id": 193,
+ "rule_id": 193,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -2257,7 +2257,7 @@
]
},
{
- "compile_id": 194,
+ "rule_id": 194,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -2283,7 +2283,7 @@
]
},
{
- "compile_id": 195,
+ "rule_id": 195,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -2325,7 +2325,7 @@
]
},
{
- "compile_id": 196,
+ "rule_id": 196,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -2352,7 +2352,7 @@
]
},
{
- "compile_id": 197,
+ "rule_id": 197,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -2378,17 +2378,17 @@
]
},
{
- "compile_id": 198,
+ "rule_id": 198,
"service": 1,
"action": 1,
"do_blacklist": 1,
"do_log": 1,
"user_region": "Something:I have a name,7799",
- "compile_table_name": "COMPILE_FIREWALL_DEFAULT",
+ "rule_table_name": "RULE_FIREWALL_DEFAULT",
"is_valid": "yes",
"groups": [
{
- "g2c_table_name": "GROUP2COMPILE_FIREWALL",
+ "g2c_table_name": "GROUP2RULE_FIREWALL",
"virtual_table": "HTTP_URL",
"group_name": "198_url_group",
"group_id": 187,
@@ -2406,7 +2406,7 @@
]
},
{
- "compile_id": 199,
+ "rule_id": 199,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -2456,7 +2456,7 @@
]
},
{
- "compile_id": 200,
+ "rule_id": 200,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -2508,7 +2508,7 @@
]
},
{
- "compile_id": 202,
+ "rule_id": 202,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -2569,7 +2569,7 @@
]
},
{
- "compile_id": 203,
+ "rule_id": 203,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -2649,7 +2649,7 @@
]
},
{
- "compile_id": 204,
+ "rule_id": 204,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -2751,7 +2751,7 @@
]
},
{
- "compile_id": 205,
+ "rule_id": 205,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -2777,7 +2777,7 @@
]
},
{
- "compile_id": 206,
+ "rule_id": 206,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -2803,7 +2803,7 @@
]
},
{
- "compile_id": 207,
+ "rule_id": 207,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -2829,7 +2829,7 @@
]
},
{
- "compile_id": 208,
+ "rule_id": 208,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -2855,7 +2855,7 @@
]
},
{
- "compile_id": 209,
+ "rule_id": 209,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -2881,7 +2881,7 @@
]
},
{
- "compile_id": 210,
+ "rule_id": 210,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -2906,7 +2906,7 @@
]
},
{
- "compile_id": 211,
+ "rule_id": 211,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -2932,7 +2932,7 @@
]
},
{
- "compile_id": 212,
+ "rule_id": 212,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -2957,7 +2957,7 @@
]
},
{
- "compile_id": 213,
+ "rule_id": 213,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -2983,7 +2983,7 @@
]
},
{
- "compile_id": 214,
+ "rule_id": 214,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -3009,7 +3009,7 @@
]
},
{
- "compile_id": 215,
+ "rule_id": 215,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -3035,7 +3035,7 @@
]
},
{
- "compile_id": 216,
+ "rule_id": 216,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -3060,7 +3060,7 @@
"table_name": "KEYWORDS_TABLE",
"table_type": "expr",
"table_content": {
- "keywords": "keywords-for-compile-211",
+ "keywords": "keywords-for-rule-211",
"expr_type": "and"
}
}
@@ -3069,7 +3069,7 @@
]
},
{
- "compile_id": 217,
+ "rule_id": 217,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -3127,7 +3127,7 @@
"table_name": "KEYWORDS_TABLE",
"table_type": "expr",
"table_content": {
- "keywords": "keywords-for-compile-217",
+ "keywords": "keywords-for-rule-217",
"expr_type": "and"
}
}
@@ -3136,7 +3136,7 @@
]
},
{
- "compile_id": 218,
+ "rule_id": 218,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -3161,7 +3161,7 @@
]
},
{
- "compile_id": 219,
+ "rule_id": 219,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -3308,7 +3308,7 @@
]
},
{
- "compile_id": 220,
+ "rule_id": 220,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -3370,7 +3370,7 @@
]
},
{
- "compile_id": 221,
+ "rule_id": 221,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -3414,7 +3414,7 @@
]
},
{
- "compile_id": 222,
+ "rule_id": 222,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -3442,7 +3442,7 @@
]
},
{
- "compile_id": 223,
+ "rule_id": 223,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -3461,7 +3461,7 @@
"table_name": "KEYWORDS_TABLE",
"table_type": "expr",
"table_content": {
- "keywords": "not_logic_compile_223_1",
+ "keywords": "not_logic_rule_223_1",
"expr_type": "and"
}
}
@@ -3478,7 +3478,7 @@
"table_name": "KEYWORDS_TABLE",
"table_type": "expr",
"table_content": {
- "keywords": "not_logic_compile_223_2",
+ "keywords": "not_logic_rule_223_2",
"expr_type": "and"
}
}
@@ -3495,7 +3495,7 @@
"table_name": "KEYWORDS_TABLE",
"table_type": "expr",
"table_content": {
- "keywords": "not_logic_compile_223_3",
+ "keywords": "not_logic_rule_223_3",
"expr_type": "and"
}
}
@@ -3504,7 +3504,7 @@
]
},
{
- "compile_id": 224,
+ "rule_id": 224,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -3523,7 +3523,7 @@
"table_name": "KEYWORDS_TABLE",
"table_type": "expr",
"table_content": {
- "keywords": "not_logic_compile_224_1",
+ "keywords": "not_logic_rule_224_1",
"expr_type": "and"
}
}
@@ -3540,7 +3540,7 @@
"table_name": "KEYWORDS_TABLE",
"table_type": "expr",
"table_content": {
- "keywords": "not_logic_compile_224_2",
+ "keywords": "not_logic_rule_224_2",
"expr_type": "and"
}
}
@@ -3549,7 +3549,7 @@
]
},
{
- "compile_id": 225,
+ "rule_id": 225,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -3577,7 +3577,7 @@
]
},
{
- "compile_id": 226,
+ "rule_id": 226,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -3593,25 +3593,25 @@
]
},
{
- "compile_id": 227,
+ "rule_id": 227,
"service": 1,
"action": 1,
"do_blacklist": 1,
"do_log": 1,
"user_region": "maat_scan_group",
- "compile_table_name": "COMPILE_FIREWALL_DEFAULT",
+ "rule_table_name": "RULE_FIREWALL_DEFAULT",
"is_valid": "yes",
"groups": [
{
"virtual_table": "KEYWORDS_TABLE",
"group_name": "227_url_group",
"group_id": 248,
- "g2c_table_name": "GROUP2COMPILE_FIREWALL"
+ "g2c_table_name": "GROUP2RULE_FIREWALL"
}
]
},
{
- "compile_id": 228,
+ "rule_id": 228,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -3655,7 +3655,7 @@
]
},
{
- "compile_id": 229,
+ "rule_id": 229,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -3681,7 +3681,7 @@
]
},
{
- "compile_id": 230,
+ "rule_id": 230,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -3707,7 +3707,7 @@
]
},
{
- "compile_id": 231,
+ "rule_id": 231,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -3733,7 +3733,7 @@
]
},
{
- "compile_id": 232,
+ "rule_id": 232,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -3759,7 +3759,7 @@
]
},
{
- "compile_id": 233,
+ "rule_id": 233,
"service": 1,
"action": 1,
"do_blacklist": 1,
@@ -3775,7 +3775,7 @@
]
},
{
- "compile_id": 234,
+ "rule_id": 234,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -3803,7 +3803,7 @@
]
},
{
- "compile_id": 235,
+ "rule_id": 235,
"service": 0,
"action": 0,
"do_blacklist": 0,
@@ -3831,7 +3831,7 @@
]
},
{
- "compile_id": 236,
+ "rule_id": 236,
"service": 0,
"action": 0,
"do_blacklist": 0,
diff --git a/test/ntcrule/full/2018-10-09/APP_COMPILE.0000050997 b/test/ntcrule/full/2018-10-09/APP_RULE.0000050997
similarity index 100%
rename from test/ntcrule/full/2018-10-09/APP_COMPILE.0000050997
rename to test/ntcrule/full/2018-10-09/APP_RULE.0000050997
diff --git a/test/ntcrule/full/2018-10-09/MM_COMPILE.0000050997 b/test/ntcrule/full/2018-10-09/MM_RULE.0000050997
similarity index 100%
rename from test/ntcrule/full/2018-10-09/MM_COMPILE.0000050997
rename to test/ntcrule/full/2018-10-09/MM_RULE.0000050997
diff --git a/test/ntcrule/full/2018-10-09/NTC_GROUP2COMPILE.0000050997 b/test/ntcrule/full/2018-10-09/NTC_GROUP2RULE.0000050997
similarity index 100%
rename from test/ntcrule/full/2018-10-09/NTC_GROUP2COMPILE.0000050997
rename to test/ntcrule/full/2018-10-09/NTC_GROUP2RULE.0000050997
diff --git a/test/ntcrule/full/2018-10-09/NTC_COMPILE.0000050997 b/test/ntcrule/full/2018-10-09/NTC_RULE.0000050997
similarity index 100%
rename from test/ntcrule/full/2018-10-09/NTC_COMPILE.0000050997
rename to test/ntcrule/full/2018-10-09/NTC_RULE.0000050997
diff --git a/test/ntcrule/full/2018-10-09/WHITE_LIST_COMPILE.0000050997 b/test/ntcrule/full/2018-10-09/WHITE_LIST_RULE.0000050997
similarity index 100%
rename from test/ntcrule/full/2018-10-09/WHITE_LIST_COMPILE.0000050997
rename to test/ntcrule/full/2018-10-09/WHITE_LIST_RULE.0000050997
diff --git a/test/ntcrule/full/index/full_config_index.0000050997 b/test/ntcrule/full/index/full_config_index.0000050997
index 11d2804..921880d 100644
--- a/test/ntcrule/full/index/full_config_index.0000050997
+++ b/test/ntcrule/full/index/full_config_index.0000050997
@@ -1,19 +1,19 @@
-APP_COMPILE 21 ./ntcrule/full/2018-10-09/APP_COMPILE.0000050997
+APP_RULE 21 ./ntcrule/full/2018-10-09/APP_RULE.0000050997
APP_GROUP 37 ./ntcrule/full/2018-10-09/APP_GROUP.0000050997
APP_PAYLOAD 1 ./ntcrule/full/2018-10-09/APP_PAYLOAD.0000050997
APP_POLICY 16 ./ntcrule/full/2018-10-09/APP_POLICY.0000050997
DDOS_PROTECT_TARGET_IP_CB 1 ./ntcrule/full/2018-10-09/DDOS_PROTECT_TARGET_IP_CB.0000050997
MM_AV_URL 1 ./ntcrule/full/2018-10-09/MM_AV_URL.0000050997
-MM_COMPILE 1 ./ntcrule/full/2018-10-09/MM_COMPILE.0000050997
+MM_RULE 1 ./ntcrule/full/2018-10-09/MM_RULE.0000050997
MM_GROUP 1 ./ntcrule/full/2018-10-09/MM_GROUP.0000050997
NTC_ASN_IP 1 ./ntcrule/full/2018-10-09/NTC_ASN_IP.0000050997
NTC_BGP_AS 10 ./ntcrule/full/2018-10-09/NTC_BGP_AS.0000050997
-NTC_COMPILE 78 ./ntcrule/full/2018-10-09/NTC_COMPILE.0000050997
+NTC_RULE 78 ./ntcrule/full/2018-10-09/NTC_RULE.0000050997
NTC_DNS_FAKE_IP_CB 3 ./ntcrule/full/2018-10-09/NTC_DNS_FAKE_IP_CB.0000050997
NTC_DNS_REGION 15 ./ntcrule/full/2018-10-09/NTC_DNS_REGION.0000050997
NTC_DNS_RES_STRATEGY 2 ./ntcrule/full/2018-10-09/NTC_DNS_RES_STRATEGY.0000050997
NTC_FTP_URL 5 ./ntcrule/full/2018-10-09/NTC_FTP_URL.0000050997
-NTC_GROUP2COMPILE 103 ./ntcrule/full/2018-10-09/NTC_GROUP2COMPILE.0000050997
+NTC_GROUP2RULE 103 ./ntcrule/full/2018-10-09/NTC_GROUP2RULE.0000050997
NTC_HTTP_REQ_BODY 4 ./ntcrule/full/2018-10-09/NTC_HTTP_REQ_BODY.0000050997
NTC_HTTP_RES_BODY 14 ./ntcrule/full/2018-10-09/NTC_HTTP_RES_BODY.0000050997
NTC_HTTP_URL 9 ./ntcrule/full/2018-10-09/NTC_HTTP_URL.0000050997
@@ -21,6 +21,6 @@ NTC_MAIL_BODY 2 ./ntcrule/full/2018-10-09/NTC_MAIL_BODY.0000050997
NTC_MAIL_HDR 14 ./ntcrule/full/2018-10-09/NTC_MAIL_HDR.0000050997
NTC_UNIVERSAL_IP 23 ./ntcrule/full/2018-10-09/NTC_UNIVERSAL_IP.0000050997
NTC_UNIVERSAL_PROTO_TYPE 23 ./ntcrule/full/2018-10-09/NTC_UNIVERSAL_PROTO_TYPE.0000050997
-WHITE_LIST_COMPILE 1 ./ntcrule/full/2018-10-09/WHITE_LIST_COMPILE.0000050997
+WHITE_LIST_RULE 1 ./ntcrule/full/2018-10-09/WHITE_LIST_RULE.0000050997
WHITE_LIST_GROUP 1 ./ntcrule/full/2018-10-09/WHITE_LIST_GROUP.0000050997
WHITE_LIST_IP 1 ./ntcrule/full/2018-10-09/WHITE_LIST_IP.0000050997
diff --git a/test/table_info.conf b/test/table_info.conf
index b2d522b..139e84c 100644
--- a/test/table_info.conf
+++ b/test/table_info.conf
@@ -1,52 +1,52 @@
[
{
"table_id":0,
- "table_name":"COMPILE_DEFAULT",
- "table_type":"compile",
+ "table_name":"RULE_DEFAULT",
+ "table_type":"rule",
"valid_column":9,
"custom": {
- "compile_id":1,
+ "rule_id":1,
"tags":6,
"clause_num":8
}
},
{
"table_id":1,
- "table_name":"COMPILE_ALIAS",
- "table_type":"compile",
+ "table_name":"RULE_ALIAS",
+ "table_type":"rule",
"valid_column":9,
- "schema_tag": "{\"compile_alias\": \"compile\"}",
+ "schema_tag": "{\"rule_alias\": \"rule\"}",
"custom": {
- "compile_id":1,
+ "rule_id":1,
"tags":6,
"clause_num":8
}
},
{
"table_id":2,
- "table_name":"COMPILE_CONJUNCTION",
- "db_tables":["COMPILE_DEFAULT", "COMPILE_ALIAS"],
- "default_compile_table":2,
- "table_type":"compile",
+ "table_name":"RULE_CONJUNCTION",
+ "db_tables":["RULE_DEFAULT", "RULE_ALIAS"],
+ "default_rule_table":2,
+ "table_type":"rule",
"valid_column":9,
- "schema_tag": "{\"compile_conjunction\": \"compile\"}",
+ "schema_tag": "{\"rule_conjunction\": \"rule\"}",
"custom": {
- "compile_id":1,
+ "rule_id":1,
"tags":6,
"clause_num":8
}
},
{
"table_id":3,
- "table_name":"GROUP2COMPILE",
- "db_tables":["GROUP2COMPILE_DEFAULT", "GROUP2COMPILE_ALIAS"],
- "table_type":"group2compile",
- "associated_compile_table_id":2,
+ "table_name":"GROUP2RULE",
+ "db_tables":["GROUP2RULE_DEFAULT", "GROUP2RULE_ALIAS"],
+ "table_type":"group2rule",
+ "associated_rule_table_id":2,
"valid_column":6,
- "schema_tag": "{\"group2compile\": \"group2compile\"}",
+ "schema_tag": "{\"group2rule\": \"group2rule\"}",
"custom": {
"group_id":1,
- "compile_id":2,
+ "rule_id":2,
"not_flag":3,
"virtual_table_name":4,
"clause_index":5
@@ -54,36 +54,36 @@
},
{
"table_id":4,
- "table_name":"COMPILE_FIREWALL_DEFAULT",
- "table_type":"compile",
+ "table_name":"RULE_FIREWALL_DEFAULT",
+ "table_type":"rule",
"valid_column":9,
"custom": {
- "compile_id":1,
+ "rule_id":1,
"tags":6,
"clause_num":8
}
},
{
"table_id":5,
- "table_name":"COMPILE_FIREWALL_CONJUNCTION",
- "db_tables":["COMPILE_FIREWALL_DEFAULT"],
- "table_type":"compile",
+ "table_name":"RULE_FIREWALL_CONJUNCTION",
+ "db_tables":["RULE_FIREWALL_DEFAULT"],
+ "table_type":"rule",
"valid_column":9,
"custom": {
- "compile_id":1,
+ "rule_id":1,
"tags":6,
"clause_num":8
}
},
{
"table_id":6,
- "table_name":"GROUP2COMPILE_FIREWALL",
- "table_type":"group2compile",
- "associated_compile_table_id":5,
+ "table_name":"GROUP2RULE_FIREWALL",
+ "table_type":"group2rule",
+ "associated_rule_table_id":5,
"valid_column":6,
"custom": {
"group_id":1,
- "compile_id":2,
+ "rule_id":2,
"not_flag":3,
"virtual_table_name":4,
"clause_index":5
@@ -102,11 +102,11 @@
},
{
"table_id":8,
- "table_name":"COMPILE_PLUGIN",
- "db_tables":["COMPILE_DEFAULT", "COMPILE_ALIAS"],
+ "table_name":"RULE_PLUGIN",
+ "db_tables":["RULE_DEFAULT", "RULE_ALIAS"],
"table_type":"plugin",
"valid_column":8,
- "schema_tag": "{\"compile_plugin\": \"plugin\"}",
+ "schema_tag": "{\"rule_plugin\": \"plugin\"}",
"custom": {
"gc_timeout_s":3,
"key_type":"integer",
@@ -116,8 +116,8 @@
},
{
"table_id":9,
- "table_name":"COMPILE_FIREWALL_PLUGIN",
- "db_tables":["COMPILE_FIREWALL_DEFAULT"],
+ "table_name":"RULE_FIREWALL_PLUGIN",
+ "db_tables":["RULE_FIREWALL_DEFAULT"],
"table_type":"plugin",
"valid_column":8,
"custom": {
diff --git a/test/test_utils.cpp b/test/test_utils.cpp
index 7619566..5ba40bb 100644
--- a/test/test_utils.cpp
+++ b/test/test_utils.cpp
@@ -147,17 +147,17 @@ int write_json_to_redis(const char *json_filename, char *redis_ip, int redis_por
return 0;
}
-int compile_table_set_line(struct maat *maat_inst, const char *table_name,
- enum maat_operation op, long long compile_id,
+int rule_table_set_line(struct maat *maat_inst, const char *table_name,
+ enum maat_operation op, long long rule_id,
const char *user_region, int clause_num,
int expire_after)
{
char table_line[1024 * 16] = {0};
sprintf(table_line, "%lld\t0\t0\t0\t0\t0\t%s\t%d\t%d\t0.0",
- compile_id, user_region, clause_num, op);
+ rule_id, user_region, clause_num, op);
struct maat_cmd_line line_rule;
- line_rule.rule_id = compile_id;
+ line_rule.rule_id = rule_id;
line_rule.table_line = table_line;
line_rule.table_name = table_name;
line_rule.expire_after = expire_after;
@@ -168,18 +168,18 @@ int compile_table_set_line(struct maat *maat_inst, const char *table_name,
#define TO_GROUP2X_KEY(group_id, parent_id, clause_index) \
(((unsigned long)group_id<<32|parent_id) + clause_index)
-int group2compile_table_set_line(struct maat *maat_inst, const char *table_name,
+int group2rule_table_set_line(struct maat *maat_inst, const char *table_name,
enum maat_operation op, long long group_id,
- long long compile_id, int not_flag,
+ long long rule_id, int not_flag,
const char *vtable_name, int clause_index,
int expire_after)
{
char table_line[128] = {0};
sprintf(table_line, "%lld\t%lld\t%d\t%s\t%d\t%d",
- group_id, compile_id, not_flag, vtable_name, clause_index, op);
+ group_id, rule_id, not_flag, vtable_name, clause_index, op);
struct maat_cmd_line line_rule;
- line_rule.rule_id = TO_GROUP2X_KEY(group_id, compile_id, clause_index);
+ line_rule.rule_id = TO_GROUP2X_KEY(group_id, rule_id, clause_index);
line_rule.table_line = table_line;
line_rule.table_name = table_name;
line_rule.expire_after = expire_after;
diff --git a/test/test_utils.h b/test/test_utils.h
index 920e0f4..ff47fe7 100644
--- a/test/test_utils.h
+++ b/test/test_utils.h
@@ -13,14 +13,14 @@ int write_iris_to_redis(const char *iris_path, char *redis_ip, int redis_port,
int write_json_to_iris(const char* json_fn, char *iris_path, size_t path_sz,
struct log_handle *logger);
-int compile_table_set_line(struct maat *maat_inst, const char *table_name,
- enum maat_operation op, long long compile_id,
+int rule_table_set_line(struct maat *maat_inst, const char *table_name,
+ enum maat_operation op, long long rule_id,
const char *user_region, int clause_num,
int expire_after);
-int group2compile_table_set_line(struct maat *maat_inst, const char *table_name,
+int group2rule_table_set_line(struct maat *maat_inst, const char *table_name,
enum maat_operation op, long long group_id,
- long long compile_id, int not_flag,
+ long long rule_id, int not_flag,
const char *vtable_name, int clause_index,
int expire_after);