summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <[email protected]>2024-08-22 10:26:59 +0000
committerroot <[email protected]>2024-08-22 10:26:59 +0000
commit54a70f19d9f5aa50142aed1779132639c34cc5dd (patch)
treecf5fd594f5822c0f49195fbfa97c65f0b1df9839
parent72cf89723d7d751470204c95e633f7b518e5952c (diff)
rename terminology "group" to "object"
-rw-r--r--docs/api_reference.md102
-rw-r--r--docs/configuration_management.md4
-rw-r--r--docs/getting_started.md34
-rw-r--r--docs/group_hierarchy.md158
-rw-r--r--docs/history.md6
-rw-r--r--docs/imgs/NOT-clause-objects.png (renamed from docs/imgs/NOT-clause-groups.png)bin43309 -> 43309 bytes
-rw-r--r--docs/imgs/object-hierarchy1.png (renamed from docs/imgs/group-hierarchy1.png)bin63866 -> 63866 bytes
-rw-r--r--docs/imgs/object-hierarchy2.png (renamed from docs/imgs/group-hierarchy2.png)bin62829 -> 62829 bytes
-rw-r--r--docs/imgs/object-hierarchy3.png (renamed from docs/imgs/group-hierarchy3.png)bin61114 -> 61114 bytes
-rw-r--r--docs/logical_combinations.md92
-rw-r--r--docs/maat_table.md90
-rw-r--r--docs/monitor_tools.md2
-rw-r--r--docs/object_hierarchy.md158
-rw-r--r--docs/overview.md14
-rw-r--r--docs/terminology.md30
-rw-r--r--include/maat.h46
-rw-r--r--readme.md2
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/inc_internal/maat_core.h6
-rw-r--r--src/inc_internal/maat_expr.h4
-rw-r--r--src/inc_internal/maat_flag.h4
-rw-r--r--src/inc_internal/maat_group.h58
-rw-r--r--src/inc_internal/maat_interval.h4
-rw-r--r--src/inc_internal/maat_limits.h4
-rw-r--r--src/inc_internal/maat_object.h58
-rw-r--r--src/inc_internal/maat_rule.h46
-rw-r--r--src/inc_internal/maat_table.h6
-rw-r--r--src/inc_internal/maat_utils.h2
-rw-r--r--src/json2iris.c466
-rw-r--r--src/maat_api.c224
-rw-r--r--src/maat_command.c2
-rw-r--r--src/maat_expr.c30
-rw-r--r--src/maat_flag.c22
-rw-r--r--src/maat_group.c1252
-rw-r--r--src/maat_interval.c22
-rw-r--r--src/maat_ip.c22
-rw-r--r--src/maat_object.c1252
-rw-r--r--src/maat_rule.c570
-rw-r--r--src/maat_stat.c16
-rw-r--r--src/maat_table.c56
-rw-r--r--src/maat_utils.c4
-rw-r--r--test/CMakeLists.txt4
-rw-r--r--test/benchmark/benchmark_gtest.cpp248
-rw-r--r--test/benchmark/benchmark_table_info.conf102
-rw-r--r--test/file_test_tableinfo.conf36
-rw-r--r--test/group_nesting/CMakeLists.txt4
-rw-r--r--test/group_nesting/group_nesting_L3.conf51
-rw-r--r--test/group_nesting/group_nesting_L4.conf76
-rw-r--r--test/group_nesting/group_nesting_exceed.conf56
-rw-r--r--test/group_nesting/group_nesting_gtest.cpp492
-rw-r--r--test/group_nesting/group_nesting_table_info.conf11
-rw-r--r--test/json_update/corrupted.json6
-rw-r--r--test/json_update/new.json6
-rw-r--r--test/json_update/old.json8
-rw-r--r--test/maat_framework_gtest.cpp1450
-rw-r--r--test/maat_framework_perf_gtest.cpp32
-rw-r--r--test/maat_json.json1000
-rw-r--r--test/ntcrule/full/2018-10-09/APP_OBJECT.0000050997 (renamed from test/ntcrule/full/2018-10-09/APP_GROUP.0000050997)0
-rw-r--r--test/ntcrule/full/2018-10-09/MM_OBJECT.0000050997 (renamed from test/ntcrule/full/2018-10-09/MM_GROUP.0000050997)0
-rw-r--r--test/ntcrule/full/2018-10-09/NTC_OBJECT2RULE.0000050997 (renamed from test/ntcrule/full/2018-10-09/NTC_GROUP2RULE.0000050997)0
-rw-r--r--test/ntcrule/full/2018-10-09/WHITE_LIST_OBJECT.0000050997 (renamed from test/ntcrule/full/2018-10-09/WHITE_LIST_GROUP.0000050997)0
-rw-r--r--test/ntcrule/full/index/full_config_index.00000509978
-rw-r--r--test/object_nesting/CMakeLists.txt4
-rw-r--r--test/object_nesting/object_nesting_L3.conf51
-rw-r--r--test/object_nesting/object_nesting_L3.png (renamed from test/group_nesting/group_nesting_L3.png)bin204909 -> 204909 bytes
-rw-r--r--test/object_nesting/object_nesting_L4.conf76
-rw-r--r--test/object_nesting/object_nesting_L4.png (renamed from test/group_nesting/group_nesting_L4.png)bin76281 -> 76281 bytes
-rw-r--r--test/object_nesting/object_nesting_exceed.conf56
-rw-r--r--test/object_nesting/object_nesting_exceed.png (renamed from test/group_nesting/group_nesting_exceed.png)bin47141 -> 47141 bytes
-rw-r--r--test/object_nesting/object_nesting_gtest.cpp492
-rw-r--r--test/object_nesting/object_nesting_table_info.conf11
-rw-r--r--test/table_info.conf72
-rw-r--r--test/test_utils.cpp42
-rw-r--r--test/test_utils.h18
-rw-r--r--test/tsg_table_info.conf2
75 files changed, 4642 insertions, 4642 deletions
diff --git a/docs/api_reference.md b/docs/api_reference.md
index 48c1b29..b5eaab1 100644
--- a/docs/api_reference.md
+++ b/docs/api_reference.md
@@ -16,7 +16,7 @@ After that, call maat_new to create a maat instance. Next, for the two main usag
* 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.
+ * If you are interested in the hit item, object, or path information, you can call the maat_state_get_xx interface as needed.
* Callback Scenario
@@ -55,7 +55,7 @@ After that, call maat_new to create a maat instance. Next, for the two main usag
* [maat_options_set_json_file_decrypt_key](#maat_options_set_json_file_decrypt_key)
* [maat_options_set_expr_engine](#maat_options_set_expr_engine)
* [maat_options_set_hit_path_enabled](#maat_options_set_hit_path_enabled)
-* [maat_options_set_hit_group_enabled](#maat_options_set_hit_group_enabled)
+* [maat_options_set_hit_object_enabled](#maat_options_set_hit_object_enabled)
## maat instance
@@ -72,12 +72,12 @@ After that, call maat_new to create a maat instance. Next, for the two main usag
* [maat_state_get_hit_paths](#maat_state_get_hit_paths)
* [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)
-* [maat_state_get_indirect_hit_groups](#maat_state_get_indirect_hit_groups)
-* [maat_state_get_indirect_hit_group_cnt](#maat_state_get_indirect_hit_group_cnt)
-* [maat_state_get_last_hit_groups](#maat_state_get_last_hit_groups)
-* [maat_state_get_last_hit_group_cnt](#maat_state_get_last_hit_group_cnt)
+* [maat_state_get_direct_hit_objects](#maat_state_get_direct_hit_objects)
+* [maat_state_get_direct_hit_object_cnt](#maat_state_get_direct_hit_object_cnt)
+* [maat_state_get_indirect_hit_objects](#maat_state_get_indirect_hit_objects)
+* [maat_state_get_indirect_hit_object_cnt](#maat_state_get_indirect_hit_object_cnt)
+* [maat_state_get_last_hit_objects](#maat_state_get_last_hit_objects)
+* [maat_state_get_last_hit_object_cnt](#maat_state_get_last_hit_object_cnt)
## maat scan
@@ -86,7 +86,7 @@ After that, call maat_new to create a maat instance. Next, for the two main usag
* [maat_scan_ipv4](#maat_scan_ipv4)
* [maat_scan_ipv6](#maat_scan_ipv6)
* [maat_scan_string](#maat_scan_string)
-* [maat_scan_group](#maat_scan_group)
+* [maat_scan_object](#maat_scan_object)
* [maat_scan_not_logic](#maat_scan_not_logic)
## maat stream
@@ -500,13 +500,13 @@ By default, maat does not store the hit path, and you can call this interface if
**Returns**: success(0), failure(-1)
-### maat_options_set_hit_group_enabled
+### maat_options_set_hit_object_enabled
```c
-int maat_options_set_hit_group_enabled(struct maat_options *opts);
+int maat_options_set_hit_object_enabled(struct maat_options *opts);
```
-By default, maat does not store the hit groups, and you can call this interface if you need to get this information.
+By default, maat does not store the hit objects, and you can call this interface if you need to get this information.
**Parameters**:
* opts - The pointer of maat_options structure.
@@ -548,7 +548,7 @@ Destroy a maat instance.
struct maat_state *maat_state_new(struct maat *instance, int thread_id);
```
-Before performing the actual scanning task, you need to call this interface to create a per-thread maat_state structure, which will be used as an input parameter when calling the maat_scan_xx interface to store the intermediate scanning state. This is especially useful in composite scanning scenarios to accurately provide all hit results from multiple scans. Additionally, hit paths, group_id of hits, and other information generated by the scanning are temporarily stored in it, and can be retrieved through the maat_state_get_xx interface.
+Before performing the actual scanning task, you need to call this interface to create a per-thread maat_state structure, which will be used as an input parameter when calling the maat_scan_xx interface to store the intermediate scanning state. This is especially useful in composite scanning scenarios to accurately provide all hit results from multiple scans. Additionally, hit paths, object_id of hits, and other information generated by the scanning are temporarily stored in it, and can be retrieved through the maat_state_get_xx interface.
**Parameters**:
* instance - Maat instance created by maat_new().
@@ -609,7 +609,7 @@ int maat_state_set_scan_rule_table(struct maat_state *state,
int rule_table_id);
```
-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.
+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 object_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.
@@ -670,106 +670,106 @@ Gets the number of scans since maat state was created.
**Returns**: The number of scans.
-### maat_state_get_direct_hit_groups
+### maat_state_get_direct_hit_objects
```c
-int maat_state_get_direct_hit_groups(struct maat_state *state,
- struct maat_hit_group *group_array,
+int maat_state_get_direct_hit_objects(struct maat_state *state,
+ struct maat_hit_object *object_array,
size_t array_size);
```
-Get the direct hit_groups, including the table_id from the scan input, the item_id and its group_id in the corresponding item table.
+Get the direct hit_objects, including the table_id from the scan input, the item_id and its object_id in the corresponding item table.
-`Note`: hit_groups may be duplicated.
+`Note`: hit_objects may be duplicated.
**Parameters**:
* state - Pointer to the maat state structure.
-* group_array - Array to store the maat_hit_groups.
+* object_array - Array to store the maat_hit_objects.
* array_size - Size of the array.
-**Returns**: The number of direct hit_groups on success, and -1 is returned on failure.
+**Returns**: The number of direct hit_objects on success, and -1 is returned on failure.
-### maat_state_get_direct_hit_group_cnt
+### maat_state_get_direct_hit_object_cnt
```c
-size_t maat_state_get_direct_hit_group_cnt(struct maat_state *state);
+size_t maat_state_get_direct_hit_object_cnt(struct maat_state *state);
```
-Get the number of direct hit_groups.
+Get the number of direct hit_objects.
**Parameters**:
* state - Pointer to the maat state structure.
-**Returns**: The number of direct hit_groups.
+**Returns**: The number of direct hit_objects.
-### maat_state_get_indirect_hit_groups
+### maat_state_get_indirect_hit_objects
```c
-int maat_state_get_indirect_hit_groups(struct maat_state *state,
- struct maat_hit_group *group_array,
+int maat_state_get_indirect_hit_objects(struct maat_state *state,
+ struct maat_hit_object *object_array,
size_t array_size);
```
-Gets the indirect hit_groups, including the table_id from the scan input, the id of the super groups referencing the hit items.
+Gets the indirect hit_objects, including the table_id from the scan input, the id of the super objects referencing the hit items.
-`Note`: hit_groups may be duplicated.
+`Note`: hit_objects may be duplicated.
**Parameters**:
* state - Pointer to the maat state structure.
-* group_array - Array to store the maat_hit_groups.
+* object_array - Array to store the maat_hit_objects.
* array_size - Size of the array.
-**Returns**: The number of indirect hit_groups on success, and -1 is returned on failure.
+**Returns**: The number of indirect hit_objects on success, and -1 is returned on failure.
-### maat_state_get_indirect_hit_group_cnt
+### maat_state_get_indirect_hit_object_cnt
```c
-size_t maat_state_get_indirect_hit_group_cnt(struct maat_state *state);
+size_t maat_state_get_indirect_hit_object_cnt(struct maat_state *state);
```
-Get the number of indirect hit_groups.
+Get the number of indirect hit_objects.
**Parameters**:
* state - Pointer to the maat state structure.
-**Returns**: The number of indirect hit_groups.
+**Returns**: The number of indirect hit_objects.
-### maat_state_get_last_hit_groups
+### maat_state_get_last_hit_objects
```c
-int maat_state_get_last_hit_groups(struct maat_state *state,
- struct maat_hit_group *group_array,
+int maat_state_get_last_hit_objects(struct maat_state *state,
+ struct maat_hit_object *object_array,
size_t array_size);
```
-Get all hit_groups in the latest scan, including the table_id from the scan input, the item_id and its group_id in the corresponding item table, the id of the super groups referencing the hit items.
+Get all hit_objects in the latest scan, including the table_id from the scan input, the item_id and its object_id in the corresponding item table, the id of the super objects referencing the hit items.
-`Note`: hit_groups is not duplicated.
+`Note`: hit_objects is not duplicated.
**Parameters**:
* state - Pointer to the maat state structure.
-* group_array - Array to store the maat_hit_groups.
+* object_array - Array to store the maat_hit_objects.
* array_size - Size of the array.
-**Returns**: The number of all hit_groups in the latest scan on success, and -1 is returned on failure.
+**Returns**: The number of all hit_objects in the latest scan on success, and -1 is returned on failure.
-### maat_state_get_last_hit_group_cnt
+### maat_state_get_last_hit_object_cnt
```c
-size_t maat_state_get_last_hit_group_cnt(struct maat_state *state);
+size_t maat_state_get_last_hit_object_cnt(struct maat_state *state);
```
-Get the number of all hit_groups in the latest scan.
+Get the number of all hit_objects in the latest scan.
**Parameters**:
* state - Pointer to the maat state structure.
-**Returns**: The number of all hit_groups in the latest scan.
+**Returns**: The number of all hit_objects in the latest scan.
### maat_scan_flag
@@ -841,16 +841,16 @@ int maat_scan_string(struct maat *instance, int table_id,
Same as above, the difference is that the data to be scanned is a string.
-### maat_scan_group
+### maat_scan_object
```c
-int maat_scan_group(struct maat *instance, int table_id,
- struct maat_hit_group *groups, size_t n_group,
+int maat_scan_object(struct maat *instance, int table_id,
+ struct maat_hit_object *objects, size_t n_object,
long long *results, size_t n_result,
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 rule_id based on the hit group_id.
+Different from the above interface, the input to this interface is the hit item_id and object_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 object_id.
### maat_scan_not_logic
diff --git a/docs/configuration_management.md b/docs/configuration_management.md
index 513adb7..efa2f6e 100644
--- a/docs/configuration_management.md
+++ b/docs/configuration_management.md
@@ -9,7 +9,7 @@ Maat supports three configuration loading modes:
## 1.<a name='Redis mode'></a> 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 rule, 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, object, and item. Maat will construct these logical relationships internally after loading the configurations from redis.
<img src="./imgs/sync-with-redis.png" width="600" height="300" >
@@ -26,7 +26,7 @@ As shown in the diagram below, the data source is stored in the relational datab
| 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 |
+| SEQUENCE_OBJECT | Object ID generation sequence | INTEGER | Used by producers to generate unique object_id |
| EXPIRE_OP_LOCK | Distributed lock | string "locked" | Ensures that at most one writer performs eviction. |
`Note`: The following api supports writing one line of configuration to redis.
diff --git a/docs/getting_started.md b/docs/getting_started.md
index f87b01e..cc92a95 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, group2rule table, and rule 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, object2rule table, and rule table. If there is also object nesting involved, the schema of the object2object table needs to be configured.
**(1) table schema**
@@ -53,12 +53,12 @@ Table schema is stored in a json file(such as table_info.conf), which is loaded
},
{
"table_id":1,
- "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. */
+ "table_name":"OBJECT2RULE",
+ "table_type":"object2rule",
+ "associated_rule_table_id":0, /* associate rule table_id, object2rule 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,
+ "object_id":1,
"rule_id":2,
"negate_option":4,
"attribute_name":5,
@@ -67,13 +67,13 @@ Table schema is stored in a json file(such as table_info.conf), which is loaded
},
{
"table_id":2,
- "table_name":"GROUP2GROUP",
- "table_type":"group2group",
+ "table_name":"OBJECT2OBJECT",
+ "table_type":"object2object",
"valid_column":4,
"custom": {
- "group_id":1,
- "included_sub_group_ids":2,
- "excluded_sub_group_ids":3
+ "object_id":1,
+ "included_sub_object_ids":2,
+ "excluded_sub_object_ids":3
}
},
{
@@ -83,7 +83,7 @@ Table schema is stored in a json file(such as table_info.conf), which is loaded
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -99,8 +99,8 @@ Configurations are stored in a json file(such as maat_json.json), which is loade
```json
{
"rule_table": "RULE",
- "group2rule_table": "GROUP2RULE",
- "group2group_table": "GROUP2GROUP",
+ "object2rule_table": "OBJECT2RULE",
+ "object2object_table": "OBJECT2OBJECT",
"rules": [
{
"rule_id": 123,
@@ -110,9 +110,9 @@ Configurations are stored in a json file(such as maat_json.json), which is loade
"do_log": 1,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
- "group_name": "Untitled",
+ "object_name": "Untitled",
"regions": [
{
"table_name": "HTTP_URL",
@@ -216,8 +216,8 @@ In the callback scenario, only the schema of the corresponding table needs to be
```json
{
"rule_table": "RULE",
- "group2rule_table": "GROUP2RULE",
- "group2group_table": "GROUP2GROUP",
+ "object2rule_table": "OBJECT2RULE",
+ "object2object_table": "OBJECT2OBJECT",
"plugin_table": {
"table_name": "TEST_IP_PLUGIN_WITH_EXDATA",
"table_content": [
diff --git a/docs/group_hierarchy.md b/docs/group_hierarchy.md
deleted file mode 100644
index 32fa852..0000000
--- a/docs/group_hierarchy.md
+++ /dev/null
@@ -1,158 +0,0 @@
-# Group(Object) hierarchies
-
-A group can reference other groups, and can also be referenced by other groups. For example, group_A references group_B, group_A is the superior group of group_B, and group_B is the subordinate group of group_A. There are two reference relationships between groups: `include` and `exclude`.
-
-## Include
-
-Include is equivalent to the inclusion semantics in set theory. For example, when group_A is included by group_B, if a traffic attribute satisfies group_A, group_B is satisfied.
-
-## Exclude
-
-A group defines a subset of an group type, such as network addresses or port numbers. The definition is made using items, which can be used to add to or exclude from the group definition. Groups can also have subordinate groups whose definitions are included in the superior group.
-
-There are rules of precedence to take into account when defining groups:
-
-- Excluding has precedence over including in the same group.
-
-- Items in a superior group have precedence over items in a subordinate group.
-
-- Items in a superior group are not taken into account in a subordinate group, if the subordinate group is used directly in a rule.
-
-- Peer groups (different subordinate groups of the same superior group) do not affect each other.
-
-In short, to determine the set defined by a group, perform the following calculation:
-
-1. For each subordinate group (remember sibling groups do not affect each other):
- - Add included items.
-
- - Subtract excluded items.
-
-2. Add included items in the group itself, overriding any excludes in the subordinate groups.
-
-3. Subtract excluded items in the group itself.
-
-The following figure shows a group with an included set and an excluded subset.
-
-<img src="./imgs/exclude.png" width="350" height="200" >
-
-Now, consider adding a subordinate group. The subordinate group also has an included set and an excluded subset. If the superior group is used, the result is shown in the following figure “A superior and subordinate group”.
-
-<img src="./imgs/hierarchy-and-exclude.png" width="350" height="230" >
-
-As can be seen, the excluded item in the subordinate group is overwritten since it is in the included set of the superior group. Also, the excluded item from the superior group excludes part of the included item in the subordinate.
-
-If only the subordinate group is used in a rule condition, the superior group items are disregarded, leaving the set shown in the next figure, “The subordinate group”.
-
-<img src="./imgs/sub-exclude.png" width="350" height="230" >
-
-Restrictions:
-
-- A group can only include or exclude groups of the same type.
-
-- A group should include at least one subordinate group. (Exclude only is not allowed)
-
-- Traffic attribute using stream scan cannot allow use object(group) with exclude, i.e., keywords object on HTTP Response Body, Email attachment.
-
-Now, let's see a graph of hierarchy example, where the dotted line means exclude. The matched subordinate groups and activated superiors are listed in the following table.
-
-Now, let's see a graph of hierarchy example, where the dotted line means exclude. If the matched subordinate groups: **{g11, g13}**, then activated superiors: **{g2, g7}**.
-
-<img src="./imgs/group-hierarchy1.png" width="750" height="350" >
-
-The analysis process is as follows:
-
-**matched groups {g11, g13}**
-
-**Level 1**: g11 => incl{g6, g7} excl{null}, g13 => incl{g3} excl{g4}; new matched groups {g6, g7, g3}, `all matched groups` {g11, g13, g6, g7, g3}
-
-**new matched groups {g6, g7, g3}**
-
-**Level 2**: g6 => incl{g1} excl{g2, g3}, g7 => incl{g2, g4} excl{g6}; new matched groups {g1, g2, g4}, `all matched groups` {g11, g13, g7, g1, g2, g4}
-
-**new matched groups {g1, g2, g4}**
-
-**Level 3**: end
-
-Check the validity of `all matched groups` {g11, g13, g7, g1, g2, g4}:
-
-1. g11, g13 are the originally matched nodes, so keep {g11, g13}.
-
-2. g7 is derived from the match of g11, implying that g10 is not matched (if g10 is matched, then g7 is not matched, as the exclude priority is higher), so keep g7.
-
-3. g1 is derived from the match of g6, but since g6 is excluded due to both g11 and g7, and g6 excludes g7 with higher priority, g1 is no longer matched. Therefore, remove g1 from the set.
-
-3. g1 is derived from the match of g6, which in turn is derived from the match of g11. However, since g7 is also matched and g6 excludes g7 with higher priority, g7's match causes g6 to be unmatched, and consequently, g1 is no longer matched. Therefore, g1 is removed from the set.
-
-4. g2 is derived from the match of g7, with the implied condition that g6 is not matched, so keep g2.
-
-5. Finally, `all matched groups` {g11, g13, g7, g2}, `matched super groups` {g2, g7}.
-
-Remove the dotted line from g7 to g6, as shown in the diagram below. If the matched subordinate groups: **{g11, g13}**, then activated groups: **{g1, g6, g7}**.
-
-<img src="./imgs/group-hierarchy2.png" width="750" height="350" >
-
-The analysis process is as follows:
-
-**matched groups {g11, g13}**
-
-**Level 1**: g11 => incl{g6, g7} excl{null}, g13 => incl{g3} excl{g4}; new matched groups {g6, g7, g3}, `all matched groups` {g11, g13, g6, g7, g3}
-
-**new matched groups {g6, g7, g3}**
-
-**Level 2**: g6 => incl{g1} excl{g2, g3}, g7 => incl{g2, g4} excl{null}; new matched groups {g1, g2, g4}, `all matched groups` {g11, g13, g6, g1, g7, g2, g4}
-
-**new matched groups {g1, g2, g4}**
-
-**Level 3**: end
-
-Check the validity of `all matched groups` {g11, g13, g6, g1, g7, g2, g4}:
-
-1. g11, g13 are the originally matched nodes, so keep {g11, g13}.
-
-2. g6 is derived from the match of g11, implying the g10 is not matched(if g10 is matched, then g7 is not matched, as the exclude priority is higher), so keep g6.
-
-3. g1 is derived from the match of g6, which in turn is derived from the match of g11, implying the g5 is not matched, so keep g1.
-
-4. g7 is derived from the match of g11, implying the g10 is not matched, so keep g7.
-
-5. g2 is derived from the match of g7. However, since g6 is also matched and g2 excludes g6 with higher priority, g6's match causes g2 to be unmatched. Therefore, g2 is removed from the set.
-
-6. g4 is derived from the match of g7. However, since g13 is also matched and g4 excludes g13 with higher priority, g13's match causes g4 to be unmatched. Therefore, g4 is removed from the set.
-
-7. Finally, `all matched groups` {g11, g13, g1, g6, g7}, `matched super groups` {g1, g6, g7}.
-
-Again remove the dotted line from g13 to g4, as shown in the diagram below. If the matched subordinate groups: **{g11, g13}**, then activated superiors: **{g1, g4, g6, g7}**.
-
-<img src="./imgs/group-hierarchy3.png" width="750" height="350" >
-
-The analysis process is as follows:
-
-**matched groups {g11, g13}**
-
-**Level 1**: g11 => incl{g6, g7} excl{null}, g13 => incl{g3} excl{null}; new matched groups {g6, g7, g3}, `all matched groups` {g11, g13, g6, g7, g3}
-
-**new matched groups {g6, g7, g3}**
-
-**Level 2**: g6 => incl{g1} excl{g2, g3}, g7 => incl{g2, g4} excl{null}; new matched groups {g1, g2, g4}, `all matched groups` {g11, g13, g6, g1, g7, g2, g4}
-
-**new matched groups {g1, g2, g4}**
-
-**Level 3**: end
-
-Check the validity of `all matched groups` {g11, g13, g6, g1, g7, g2, g4}:
-
-1. g11, g13 are the originally matched nodes, so keep {g11, g13}.
-
-2. g6 is derived from the match of g11, implying the g10 is not matched(if g10 is matched, then g7 is not matched, as the exclude priority is higher), so keep g6.
-
-3. g1 is derived from the match of g6, which in turn is derived from the match of g11, implying the g5 is not matched, so keep g1.
-
-4. g7 is derived from the match of g11, implying the g10 is not matched, so keep g7.
-
-5. g2 is derived from the match of g7. However, since g6 is also matched and g2 excludes g6 with higher priority, g6's match causes g2 to be unmatched. Therefore, g2 is removed from the set.
-
-6. g4 is derived from the match of g13, so keep g4.
-
-7. Finally, `all matched groups` {g11, g13, g6, g1, g7, g4}, `matched super groups` {g1, g4, g6, g7}.
-
-The above example is strictly consistent with the case `GroupExcludeTest.level_3_function` in the [test/group_nesting](../test/group_nesting/) test. Please run it to see the actual execution results. \ No newline at end of file
diff --git a/docs/history.md b/docs/history.md
index 429a429..e9c99d0 100644
--- a/docs/history.md
+++ b/docs/history.md
@@ -8,15 +8,15 @@
| v3.1.20| 2021-4-28 | Add explanation for loading gzip-compressed JSON files | Zheng Chao |
| v3.1.5 | 2021-3-12 | Add matching examples for callback class FQDN table | Zheng Chao |
| v3.1.4 | 2020-11-04| When content foreign key is "null," it represents an empty file | Zheng Chao |
-| v3.1.1 | 2020-9-27 | Add explanation for creating attributes on multiple different types of physical tables | Zheng Chao |
+| v3.1.1 | 2020-9-27 | Add explanation for creating virtual tables on multiple different types of physical tables | Zheng Chao |
| v3.1.0 | 2020-9-18 | Add FQDN callback table | Zheng Chao |
| v3.0.4 | 2020-8-17 | Add extended numerical domain configuration interval_plus | Zheng Chao |
-| v3.0 | 2020-6-29 | Maat 3.0, support conditions, original grouping table split into grouping relationship table and grouping compilation table | Zheng Chao |
+| v3.0 | 2020-6-29 | Maat 3.0, support clauses, original grouping table split into grouping relationship table and grouping compilation table | Zheng Chao |
| v2.8 | 2020-3-13 | Support composite tables | Zheng Chao |
| v2.8 | 2020-2-11 | Support Hit Path | Zheng Chao |
| v2.8 | 2020-2-4 | Support sorting strategies by Evaluation Order | Zheng Chao |
| v2.8 | 2020-1-22 | Maat JSON file encryption support, see 17.3 | Zheng Chao |
-| v2.8 | 2019-7-28 | 1. No longer compatible with no grouping tables 2. Support attributes | Zheng Chao |
+| v2.8 | 2019-7-28 | 1. No longer compatible with no grouping tables 2. Support virtual tables | Zheng Chao |
| v2.7.2 | 2019-7-10 | Expand IP configuration table to support CIDR format | Zheng Chao |
| v2.7.1 | 2019-5-23 | Rename rich IP class configuration table to extended IP configuration table | Zheng Chao |
| v2.7.0 | 2019-5-12 | 1. Add explanation for subgroup relationships 2. Add explanation for rich IP class configuration | Zheng Chao |
diff --git a/docs/imgs/NOT-clause-groups.png b/docs/imgs/NOT-clause-objects.png
index bc42519..bc42519 100644
--- a/docs/imgs/NOT-clause-groups.png
+++ b/docs/imgs/NOT-clause-objects.png
Binary files differ
diff --git a/docs/imgs/group-hierarchy1.png b/docs/imgs/object-hierarchy1.png
index 8bf11ee..8bf11ee 100644
--- a/docs/imgs/group-hierarchy1.png
+++ b/docs/imgs/object-hierarchy1.png
Binary files differ
diff --git a/docs/imgs/group-hierarchy2.png b/docs/imgs/object-hierarchy2.png
index 751605d..751605d 100644
--- a/docs/imgs/group-hierarchy2.png
+++ b/docs/imgs/object-hierarchy2.png
Binary files differ
diff --git a/docs/imgs/group-hierarchy3.png b/docs/imgs/object-hierarchy3.png
index 0a879b3..0a879b3 100644
--- a/docs/imgs/group-hierarchy3.png
+++ b/docs/imgs/object-hierarchy3.png
Binary files differ
diff --git a/docs/logical_combinations.md b/docs/logical_combinations.md
index ffe1041..3c09331 100644
--- a/docs/logical_combinations.md
+++ b/docs/logical_combinations.md
@@ -1,26 +1,26 @@
# Logical combinations
-When you understand the [configuration relationship](./overview.md#12-configuration-relationship) and [group hierarchy](./group_hierarchy.md), you will find multiple layers of logical relationships. Are all these logical relationships necessary? If yes, what are the use cases targeted by each? This document serves as a cheat sheet for you to understand the logical combinations of maat rules.
+When you understand the [configuration relationship](./overview.md#12-configuration-relationship) and [object hierarchy](./object_hierarchy.md), you will find multiple layers of logical relationships. Are all these logical relationships necessary? If yes, what are the use cases targeted by each? This document serves as a cheat sheet for you to understand the logical combinations of maat rules.
Before describing specific rules, we need to define the syntax of logical combinations. A rule is written using infix notation, which consists of operands, operators, and parentheses. The operands are rule IDs, and operators are "!(NOT)", "&(AND)", "|(OR)".
Before showing how to configure the specific rules, we need some raw materials (items). The following is the configuration information for the different types of item tables:
**keywords(table_id=1)**
-| item_id | group_id | keywords |
+| item_id | object_id | keywords |
| ------- | -------- | ------------- |
| 101 | 201 | www.baidu.com |
| 102 | 202 | baidu.com |
**ip address(table_id=2)**
-| item_id | group_id | ip range |
+| item_id | object_id | ip range |
| ------- | -------- | --------------------------- |
| 110 | 210 | 192.168.1.1 ~ 192.168.1.255 |
| 111 | 211 | 192.168.1.11 ~ 192.168.1.20 |
| 112 | 212 | 192.168.1.21 ~ 192.168.1.30 |
**port(table_id=3)**
-| item_id | group_id | interval range |
+| item_id | object_id | interval range |
| ------- | -------- | -------------- |
| 120 | 220 | 100 ~ 200 |
| 121 | 221 | 80 ~ 80 |
@@ -29,7 +29,7 @@ Before showing how to configure the specific rules, we need some raw materials (
* [AND logic](#and-logic)
* [OR logic](#or-logic)
* [NOT logic](#not-logic)
-* [Group exclude](#group-exclude)
+* [Object exclude](#object-exclude)
## AND logic
@@ -37,62 +37,62 @@ Before showing how to configure the specific rules, we need some raw materials (
* 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.
- * 192.168.1.11 ~ 192.168.1.20 => group_id(211)
- * www.baidu.com => group_id(201)
+ * 192.168.1.11 ~ 192.168.1.20 => object_id(211)
+ * www.baidu.com => object_id(201)
```bash
rule(rule) = condition1 & condition2
- = {attribute1, group1, condition_index1} & {attribute2, group2, condition_index2}
+ = {attribute1, object1, condition_index1} & {attribute2, object2, condition_index2}
= {2, 211, 1} & {1, 201, 2}
```
* case2: To block the traffic whose source IP address is 192.168.1.11 to 192.168.1.20 and source port 80.
- * 192.168.1.11 ~ 192.168.1.20 => group_id(211)
- * 端口80 ~ 80 => group_id(221)
+ * 192.168.1.11 ~ 192.168.1.20 => object_id(211)
+ * 端口80 ~ 80 => object_id(221)
```bash
rule(rule) = condition1 & condition2
- = {attribute1, group1, condition_index1} & {attribute2, group2, condition_index2}
+ = {attribute1, object1, condition_index1} & {attribute2, object2, condition_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 rule_id=152.
-group_name: "152_mail_addr" and group_name: "interval_group_refered" are two conditions of this rule, with a logical `AND` relationship between them.
+object_name: "152_mail_addr" and object_name: "interval_object_refered" are two conditions of this rule, with a logical `AND` relationship between them.
## OR logic
-`Note`: Multiple groups under the same condition have a logical 'OR' relationship.
+`Note`: Multiple objects under the same condition have a logical 'OR' relationship.
* case1: Deny hosts with source IP addresses in the range of 192.168.1.11 to 192.168.1.30 from accessing the website www.baidu.com.
- * 192.168.1.11 ~ 192.168.1.20 => group_id(211)
- * 192.168.1.21 ~ 192.168.1.30 => group_id(212)
- * www.baidu.com => group_id(201)
+ * 192.168.1.11 ~ 192.168.1.20 => object_id(211)
+ * 192.168.1.21 ~ 192.168.1.30 => object_id(212)
+ * www.baidu.com => object_id(201)
```bash
rule(rule) = condition1 & condition2
- = {attribute1, (group1 | group2), condition_index1} & {attribute2, group3, condition_index2}
+ = {attribute1, (object1 | object2), condition_index1} & {attribute2, object3, condition_index2}
= {2, (211 | 212), 1} & {1, 201, 2}
```
* case2: To block the traffic whose source ip address is 192.168.1.11 to 192.168.1.20 and source port 80 or 443.
- * 192.168.1.11 ~ 192.168.1.20 => group_id(211)
- * port 80 ~ 80 => group_id(221)
- * port 443 ~ 443 => group_id(222)
+ * 192.168.1.11 ~ 192.168.1.20 => object_id(211)
+ * port 80 ~ 80 => object_id(221)
+ * port 443 ~ 443 => object_id(222)
```bash
rule(rule) = condition1 & condition2
- = {attribute1, group1, condition_index1} & {attribute2, (group2 | group3), condition_index2}
+ = {attribute1, object1, condition_index1} & {attribute2, (object2 | object3), condition_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 rule_id=152.
-group_name: "152_mail_addr" contains two regions(items) with a logical `OR` relationship between them.
+object_name: "152_mail_addr" contains two regions(items) with a logical `OR` relationship between them.
## NOT logic
@@ -101,76 +101,76 @@ group_name: "152_mail_addr" contains two regions(items) with a logical `OR` rela
* case1: Hosts with source ip addresses ranging from 192.168.1.11 to 192.168.1.20 are allowed to access websites other than www.baidu.com.
- * 192.168.1.11 ~ 192.168.1.20 => group_id(211)
- * www.baidu.com => group_id(201)
+ * 192.168.1.11 ~ 192.168.1.20 => object_id(211)
+ * www.baidu.com => object_id(201)
```bash
rule(rule) = condition1 & !condition2
- = {attribute1, group1, condition_index1} & !{attribute2, group2, condition_index2}
+ = {attribute1, object1, condition_index1} & !{attribute2, object2, condition_index2}
= {2, 211, 1} & !{1, 201, 2}
```
* case2: To block the traffic whose source ip address is in 192.168.1.11 to 192.168.1.20 and the source port is not 80 or 443.
- * 192.168.1.11 ~ 192.168.1.20 => group_id(211)
- * port 80 ~ 80 => group_id(221)
- * port 443 ~ 443 => group_id(222)
+ * 192.168.1.11 ~ 192.168.1.20 => object_id(211)
+ * port 80 ~ 80 => object_id(221)
+ * port 443 ~ 443 => object_id(222)
```bash
rule(rule) = condition1 & !condition2
- = {attribute1, group1, condition_index1} & !{attribute2, (group2 | group3), condition_index2}
+ = {attribute1, object1, condition_index1} & !{attribute2, (object2 | object3), condition_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 rule_id=145.
-The group_name: "123_IP_group" is a negate condition of this rule.
+The object_name: "123_IP_object" is a negate condition of this rule.
-## Group exclude
+## Object exclude
-`Note`: The `exclude` relationship only applies between groups of the same type, such as super_group1 = include {group1}, exclude {group2}.
+`Note`: The `exclude` relationship only applies between objects of the same type, such as super_object1 = include {object1}, exclude {object2}.
-Constraint: The super group cannot consist only of exclude groups; it must contain at least one include group.
+Constraint: The super object cannot consist only of exclude objects; it must contain at least one include object.
* case1: Deny hosts with source IP addresses in the range of 192.168.1.1 to 192.168.1.255 but not in the range of 192.168.1.11 to 192.168.1.20 from accessing the website www.baidu.com.
- * 192.168.1.1 ~ 192.168.1.255 => group_id(210)
- * 192.168.1.11 ~ 192.168.20 => group_id(211)
- * www.baidu.com => group_id(201)
+ * 192.168.1.1 ~ 192.168.1.255 => object_id(210)
+ * 192.168.1.11 ~ 192.168.20 => object_id(211)
+ * www.baidu.com => object_id(201)
-In this case, you need to configure super_group1 first.
+In this case, you need to configure super_object1 first.
```bash
-super_group1 = group1 exclude group2
+super_object1 = object1 exclude object2
= 210 exclude 211
```
And then configure the rule.
```bash
rule(rule) = condition1 & condition2
- = {attribute1, super_group1, condition_index1} & {attribute2, group2, condition_index2}
+ = {attribute1, super_object1, condition_index1} & {attribute2, object2, condition_index2}
= {2, (210 exclude 211), 1} & {1, 201, 2}
```
* case2: Deny hosts with source IP addresses in the range of 192.168.1.11 to 192.168.1.20 from accessing subdomains of baidu.com except for www.baidu.com.
- * 192.168.1.11 ~ 192.168.1.20 => group_id(211)
- * www.baidu.com => group_id(201)
- * baidu.com => group_id(202)
+ * 192.168.1.11 ~ 192.168.1.20 => object_id(211)
+ * www.baidu.com => object_id(201)
+ * baidu.com => object_id(202)
-In this case, you need to configure super_group2 first.
+In this case, you need to configure super_object2 first.
```bash
-super_group2 = group2 exclude group3
+super_object2 = object2 exclude object3
= 202 exclude 201
```
And then configure the rule.
```bash
rule(rule) = condition1 & condition2
- = {attribute1, group1, condition_index1} & {attribute2, super_group2, condition_index2}
+ = {attribute1, object1, condition_index1} & {attribute2, super_object2, condition_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 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
+The object_name: "ExcludeLogicObject200" is a super object that includes an include object "ExcludeLogicObject200_1" and an exclude object "ExcludeLogicObject200_2". \ No newline at end of file
diff --git a/docs/maat_table.md b/docs/maat_table.md
index f1bd1a4..aade183 100644
--- a/docs/maat_table.md
+++ b/docs/maat_table.md
@@ -12,8 +12,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)
- [rule table](#12-rule-table)
-- [group2rule table](#13-group2rule-table)
-- [group2group table](#14-group2group-table)
+- [object2rule table](#13-object2rule-table)
+- [object2object table](#14-object2object-table)
- [plugin table](#15-plugin-table)
- [ip_plugin table](#16-ip_plugin-table)
- [fqdn_plugin table](#17-fqdn_plugin-table)
@@ -39,11 +39,11 @@ Each item table must has the following columns:
- item_id: In a maat instance, the item id is globally unique, meaning that the item id of different tables must not be duplicate.
-- group_id: Indicate the group to which the item belongs, an item belongs to only one group.
+- object_id: Indicate the object to which the item belongs, an item belongs to only one object.
- is_valid: In incremental updates, 1(valid means add) 0(invalid means del)
-The range of item_id(group_id, rule_id) is 0~2^63,which is 8 bytes.
+The range of item_id(object_id, rule_id) is 0~2^63,which is 8 bytes.
#### 1.1.1 <a name='exprtable'></a> 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 & group2rule table |
+| **object_id** | LONG LONG | leaf object id, can be referenced by object2object & object2rule 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) |
@@ -68,7 +68,7 @@ The table schema is stored in table_info.conf.
"valid_column":7, //7th column(is_valid field)
"custom": {
"item_id":1, //1st column(item_id field)
- "group_id":2, //2nd column(group_id field)
+ "object_id":2, //2nd column(object_id field)
"keywords":3, //3rd column(keywords field)
"expr_type":4, //4th column(expr_type field)
"match_method":5,//5th column(match_method field)
@@ -86,7 +86,7 @@ The table schema is stored in table_info.conf.
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -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 & group2rule table |
+| **object_id** | LONG LONG | leaf object id, can be referenced by object2object & object2rule 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 & group2rule table |
+| **object_id** | LONG LONG | leaf object id, can be referenced by object2object & object2rule 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 & group2rule table |
+| **object_id** | INT | leaf object id, can be referenced by object2object & object2rule 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 & group2rule table |
+| **object_id** | INT | leaf object id, can be referenced by object2object & object2rule 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 & group2rule table |
+| **object_id** | INT | leaf object id, can be referenced by object2object & object2rule 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,7 +230,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 & group2rule table |
+| **object_id** | INT | leaf object id, can be referenced by object2object & object2rule 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)|
@@ -247,30 +247,30 @@ Describe the specific policy, one maat instance can has multiple rule tables wit
| **is_valid** | INT | 0(invalid),1(valid) |
| **condition_num** | INT | no more than 8 conditions |
-### 1.3 <a name='Group2RuleTable'></a> group2rule table
+### 1.3 <a name='Object2RuleTable'></a> object2rule table
-Describe the relationship between group and rule.
+Describe the relationship between object and rule.
| **FieldName** | **type** | **constraint** |
| ----------------- | ------------- | -------------- |
-| **group_ids** | VARCHAR(256) | group ids are separated by commas(g1,g2,g3) |
+| **object_ids** | VARCHAR(256) | object ids are separated by commas(g1,g2,g3) |
| **rule_id** | LONG LONG | rule id |
| **is_valid** | INT | 0(invalid), 1(valid) |
| **negate_option** | INT | logical 'NOT', identify a negate condition, 0(no) 1(yes) |
| **attribute** | VARCHAR2(256) | attribute name, NOT NULL |
-| **Nth_condition** | INT | the condition seq in (conjunctive normal form)CNF, from 0 to 7. groups with the same condition ID are logical 'OR' |
+| **Nth_condition** | INT | the condition seq in (conjunctive normal form)CNF, from 0 to 7. objects with the same condition ID are logical 'OR' |
-NOTE: If group_id is invalid in xx_item table, it must be marked as invalid in this table.
+NOTE: If object_id is invalid in xx_item table, it must be marked as invalid in this table.
-### 1.4 <a name='Group2GroupTable'></a> group2group table
+### 1.4 <a name='Object2ObjectTable'></a> object2object table
-Describe the relationship between groups.
+Describe the relationship between objects.
| **FieldName** | **type** | **constraint** |
| ---------------------- | ------------ | ---------------|
-| **group_id** | LONG LONG | reference from xx_item table's group_id |
-| **incl_sub_group_ids** | VARCHAR(256) | included sub group ids are separated by commas(g1,g2,g3)|
-| **excl_sub_group_ids** | VARCHAR(256) | excluded sub group ids are separated by commas(g4,g5)|
+| **object_id** | LONG LONG | reference from xx_item table's object_id |
+| **incl_sub_object_ids** | VARCHAR(256) | included sub object ids are separated by commas(g1,g2,g3)|
+| **excl_sub_object_ids** | VARCHAR(256) | excluded sub object ids are separated by commas(g4,g5)|
| **is_valid** | Bool | (invalid), 1(valid) |
@@ -359,7 +359,7 @@ For example: HTTP_REGION is the conjunction of HTTP_URL and HTTP_HOST.
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -396,13 +396,13 @@ Before notifying the callback table, Maat fetches the foreign keys to local file
By matching the tags accepted by Maat with the configuration tags, selective configuration loading is achieved. Configuration tags are a collection of tag arrays, denoted as "tag_sets", while Maat accepts tags are tag arrays denoted as "tags".
-Configuration tags are tags stored on compilation configurations or group configurations, identifying where the configuration is effective in which Maat instances. It consists of multiple tag sets, where multiple tags within a set are ANDed, and multiple values of a tag are ORed.
+Configuration tags are tags stored on compilation configurations or object configurations, identifying where the configuration is effective in which Maat instances. It consists of multiple tag sets, where multiple tags within a set are ANDed, and multiple values of a tag are ORed.
## 2. Table runtime
-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.
+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 object_id.
-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.
+From the [configuration relationship](./overview.md#12-configuration-relationship) diagram, we can see how the hit object is referenced by other objects or rules. If a hit object is referenced by other objects or rules, there will be one or more hit paths that follow the `item_id -> object_id` {-> super object_id} `-> rule_id`. This requires two special runtimes: object2object_runtime and rule_runtime.
Based on this, we can divide the runtime into the following three categories:
@@ -412,8 +412,8 @@ Based on this, we can divide the runtime into the following three categories:
* flag_runtime
* interval_runtime
-2. group & rule table runtime
- * group2group_runtime
+2. object & rule table runtime
+ * object2object_runtime
* rule_runtime
3. xx_plugin table runtime
@@ -431,15 +431,15 @@ 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 & rule table runtime
+### 2.2 object & rule table runtime
-#### 2.2.1 group2group runtime
+#### 2.2.1 object2object 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.
+The `object2object_runtime` is a runtime that is built based on the reference relationships between objects, which are stored in the [object2object table](#14-object2object-table). From the [object hierarchy](./object_hierarchy.md), we can understand that if a hit occurs in a leaf object that is referenced by other objects, there may be certain super objects that are also hit. This is exactly the functionality provided by this runtime.
#### 2.2.2 rule runtime
-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.
+In addition to the rule table, there is also the object2rule 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 object2rule_runtime. Rule_runtime is the most complex among all runtime types because it serves multiple functions.
**Note:** This will involve the terminology of [condition](./terminology.md#condition).
@@ -449,7 +449,7 @@ In addition to the rule table, there is also the group2rule table in the table s
* rule2 = condition1 & condition2 = {attribute1, g2} & {attribute2, g3}
- Given the matched attribute_id and group_id, all matching rule_ids can be provided. For example, if scanning attribute1 matches g2 and attribute2 matches g3, rule_runtime will return the matched rule_id 2.
+ Given the matched attribute_id and object_id, all matching rule_ids can be provided. For example, if scanning attribute1 matches g2 and attribute2 matches g3, rule_runtime will return the matched rule_id 2.
2. For expressions with negate-conditions, returning the matched rule_id:
@@ -459,9 +459,9 @@ In addition to the rule table, there is also the group2rule table in the table s
If scanning attribute1 matches g1 and attribute2 matches g3, rule_runtime will return the matched rule_id 4.
-3. If a rule_id is matched, the full hit path can be obtained: **item_id -> group_id ->** {super_group_id} -> condition{**attribute_id, negate_option, condition_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}.
+3. If a rule_id is matched, the full hit path can be obtained: **item_id -> object_id ->** {super_object_id} -> condition{**attribute_id, negate_option, condition_index} -> rule_id**. If the matched object is not referenced by a rule, a half hit path can be obtained: **item_id -> object_id** -> {super_object_id}.
-4. Getting the matched group_ids and the count of hit groups.
+4. Getting the matched object_ids and the count of hit objects.
The internal structure of rule_runtime is as follows, including the control plane for configuration loading and the data plane for external calls.
@@ -469,33 +469,33 @@ The internal structure of rule_runtime is as follows, including the control plan
* **Control plane**
-Rule runtime loads the rule table and group2rule table configurations into memory, assigning a unique condition_id to all conditions of each rule. The following three parts are constructed based on the condition_id:
+Rule runtime loads the rule table and object2rule table configurations into memory, assigning a unique condition_id to all conditions of each rule. The following three parts are constructed based on the condition_id:
1. All condition_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 negate_option=0 (conditions), a `condition_id hash` is built, key:{group_id, attribute_id, negate_option}, value:condition_id.
+2. For negate_option=0 (conditions), a `condition_id hash` is built, key:{object_id, attribute_id, negate_option}, value:condition_id.
-3. For negate_option=1 (negate-conditions), a `NOT_condition_id hash` is built, key:{group_id, attribute_id, negate_option}, value:condition_id.
+3. For negate_option=1 (negate-conditions), a `NOT_condition_id hash` is built, key:{object_id, attribute_id, negate_option}, value:condition_id.
* **Data Plane**
On the data plane, services are provided externally through the maat API, primarily with the following three types of interfaces:
-1. **maat_scan_xx**: This interface dynamically generates the hit {item_id, group_id}.
+1. **maat_scan_xx**: This interface dynamically generates the hit {item_id, object_id}.
-* The hit item_id and group_id form a half-hit path.
+* The hit item_id and object_id form a half-hit path.
-* The group_id that is hit and the scanned `attribute_id` form the key {group_id, attribute_id, 0}. This key is used to find the `hit condition_ids` in the condition_id hash.
+* The object_id that is hit and the scanned `attribute_id` form the key {object_id, attribute_id, 0}. This key is used to find the `hit condition_ids` in the condition_id hash.
-* Use the key {group_id, attribute_id, 1} to search for NOT_condition_ids in the NOT_condition_id hash and cache them as `exclude condition_ids`. These condition_ids need to be removed from all condition_ids that are eventually hit. This is because the scan hit {group_id, attribute_id, 0} => condition_id, leading to the deduction that {group_id, attribute_id, 1} => NOT_condition_id does not hit.
+* Use the key {object_id, attribute_id, 1} to search for NOT_condition_ids in the NOT_condition_id hash and cache them as `exclude condition_ids`. These condition_ids need to be removed from all condition_ids that are eventually hit. This is because the scan hit {object_id, attribute_id, 0} => condition_id, leading to the deduction that {object_id, attribute_id, 1} => NOT_condition_id does not hit.
-* Identify the group_ids in attribute_id table that appear in the NOT_condition and add them to the `NOT_condition_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_condition_group` for the attribute_id table.
+* Identify the object_ids in attribute_id table that appear in the NOT_condition and add them to the `NOT_condition_object` set. Ensure that this set does not contain any object_id that was hit during scanning. If any such object_id is present, remove it from the set to form the final `NOT_condition_object` for the attribute_id table.
* Use the hit condition_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 negate-condition logic.
-* Traverse the `NOT_condition_group` of `attribute_id`. For each `group_id`, form a key `{group_id, attribute_id, 1}` to obtain the `NOT_condition_id`. If it is in the `exclude condition_ids` set, ignore it; otherwise, add it to the `all hit condition_ids` set as a hit `NOT_condition_id`, and record the half-hit path of the negate-condition.
+* Traverse the `NOT_condition_object` of `attribute_id`. For each `object_id`, form a key `{object_id, attribute_id, 1}` to obtain the `NOT_condition_id`. If it is in the `exclude condition_ids` set, ignore it; otherwise, add it to the `all hit condition_ids` set as a hit `NOT_condition_id`, and record the half-hit path of the negate-condition.
* Use the `all hit condition_ids` to calculate if there are any newly hit rule_ids. If there are, populate the half-hit path of the negate-condition which will become full-hit path.
diff --git a/docs/monitor_tools.md b/docs/monitor_tools.md
index 894f4ed..1b0fd6b 100644
--- a/docs/monitor_tools.md
+++ b/docs/monitor_tools.md
@@ -24,7 +24,7 @@ The statistical information in the above figure is divided into two parts, part1
- NOT_condition_num: total number of negate-conditions
-- excl_grp_num: total number of exclude groups
+- excl_grp_num: total number of exclude objects
- garbage_queue_len: number of elements in the garbage queue
diff --git a/docs/object_hierarchy.md b/docs/object_hierarchy.md
new file mode 100644
index 0000000..8254373
--- /dev/null
+++ b/docs/object_hierarchy.md
@@ -0,0 +1,158 @@
+# Object(Object) hierarchies
+
+A object can reference other objects, and can also be referenced by other objects. For example, object_A references object_B, object_A is the superior object of object_B, and object_B is the subordinate object of object_A. There are two reference relationships between objects: `include` and `exclude`.
+
+## Include
+
+Include is equivalent to the inclusion semantics in set theory. For example, when object_A is included by object_B, if a traffic attribute satisfies object_A, object_B is satisfied.
+
+## Exclude
+
+A object defines a subset of an object type, such as network addresses or port numbers. The definition is made using items, which can be used to add to or exclude from the object definition. Objects can also have subordinate objects whose definitions are included in the superior object.
+
+There are rules of precedence to take into account when defining objects:
+
+- Excluding has precedence over including in the same object.
+
+- Items in a superior object have precedence over items in a subordinate object.
+
+- Items in a superior object are not taken into account in a subordinate object, if the subordinate object is used directly in a rule.
+
+- Peer objects (different subordinate objects of the same superior object) do not affect each other.
+
+In short, to determine the set defined by a object, perform the following calculation:
+
+1. For each subordinate object (remember sibling objects do not affect each other):
+ - Add included items.
+
+ - Subtract excluded items.
+
+2. Add included items in the object itself, overriding any excludes in the subordinate objects.
+
+3. Subtract excluded items in the object itself.
+
+The following figure shows a object with an included set and an excluded subset.
+
+<img src="./imgs/exclude.png" width="350" height="200" >
+
+Now, consider adding a subordinate object. The subordinate object also has an included set and an excluded subset. If the superior object is used, the result is shown in the following figure “A superior and subordinate object”.
+
+<img src="./imgs/hierarchy-and-exclude.png" width="350" height="230" >
+
+As can be seen, the excluded item in the subordinate object is overwritten since it is in the included set of the superior object. Also, the excluded item from the superior object excludes part of the included item in the subordinate.
+
+If only the subordinate object is used in a rule condition, the superior object items are disregarded, leaving the set shown in the next figure, “The subordinate object”.
+
+<img src="./imgs/sub-exclude.png" width="350" height="230" >
+
+Restrictions:
+
+- A object can only include or exclude objects of the same type.
+
+- A object should include at least one subordinate object. (Exclude only is not allowed)
+
+- Traffic attribute using stream scan cannot allow use object(object) with exclude, i.e., keywords object on HTTP Response Body, Email attachment.
+
+Now, let's see a graph of hierarchy example, where the dotted line means exclude. The matched subordinate objects and activated superiors are listed in the following table.
+
+Now, let's see a graph of hierarchy example, where the dotted line means exclude. If the matched subordinate objects: **{g11, g13}**, then activated superiors: **{g2, g7}**.
+
+<img src="./imgs/object-hierarchy1.png" width="750" height="350" >
+
+The analysis process is as follows:
+
+**matched objects {g11, g13}**
+
+**Level 1**: g11 => incl{g6, g7} excl{null}, g13 => incl{g3} excl{g4}; new matched objects {g6, g7, g3}, `all matched objects` {g11, g13, g6, g7, g3}
+
+**new matched objects {g6, g7, g3}**
+
+**Level 2**: g6 => incl{g1} excl{g2, g3}, g7 => incl{g2, g4} excl{g6}; new matched objects {g1, g2, g4}, `all matched objects` {g11, g13, g7, g1, g2, g4}
+
+**new matched objects {g1, g2, g4}**
+
+**Level 3**: end
+
+Check the validity of `all matched objects` {g11, g13, g7, g1, g2, g4}:
+
+1. g11, g13 are the originally matched nodes, so keep {g11, g13}.
+
+2. g7 is derived from the match of g11, implying that g10 is not matched (if g10 is matched, then g7 is not matched, as the exclude priority is higher), so keep g7.
+
+3. g1 is derived from the match of g6, but since g6 is excluded due to both g11 and g7, and g6 excludes g7 with higher priority, g1 is no longer matched. Therefore, remove g1 from the set.
+
+3. g1 is derived from the match of g6, which in turn is derived from the match of g11. However, since g7 is also matched and g6 excludes g7 with higher priority, g7's match causes g6 to be unmatched, and consequently, g1 is no longer matched. Therefore, g1 is removed from the set.
+
+4. g2 is derived from the match of g7, with the implied condition that g6 is not matched, so keep g2.
+
+5. Finally, `all matched objects` {g11, g13, g7, g2}, `matched super objects` {g2, g7}.
+
+Remove the dotted line from g7 to g6, as shown in the diagram below. If the matched subordinate objects: **{g11, g13}**, then activated objects: **{g1, g6, g7}**.
+
+<img src="./imgs/object-hierarchy2.png" width="750" height="350" >
+
+The analysis process is as follows:
+
+**matched objects {g11, g13}**
+
+**Level 1**: g11 => incl{g6, g7} excl{null}, g13 => incl{g3} excl{g4}; new matched objects {g6, g7, g3}, `all matched objects` {g11, g13, g6, g7, g3}
+
+**new matched objects {g6, g7, g3}**
+
+**Level 2**: g6 => incl{g1} excl{g2, g3}, g7 => incl{g2, g4} excl{null}; new matched objects {g1, g2, g4}, `all matched objects` {g11, g13, g6, g1, g7, g2, g4}
+
+**new matched objects {g1, g2, g4}**
+
+**Level 3**: end
+
+Check the validity of `all matched objects` {g11, g13, g6, g1, g7, g2, g4}:
+
+1. g11, g13 are the originally matched nodes, so keep {g11, g13}.
+
+2. g6 is derived from the match of g11, implying the g10 is not matched(if g10 is matched, then g7 is not matched, as the exclude priority is higher), so keep g6.
+
+3. g1 is derived from the match of g6, which in turn is derived from the match of g11, implying the g5 is not matched, so keep g1.
+
+4. g7 is derived from the match of g11, implying the g10 is not matched, so keep g7.
+
+5. g2 is derived from the match of g7. However, since g6 is also matched and g2 excludes g6 with higher priority, g6's match causes g2 to be unmatched. Therefore, g2 is removed from the set.
+
+6. g4 is derived from the match of g7. However, since g13 is also matched and g4 excludes g13 with higher priority, g13's match causes g4 to be unmatched. Therefore, g4 is removed from the set.
+
+7. Finally, `all matched objects` {g11, g13, g1, g6, g7}, `matched super objects` {g1, g6, g7}.
+
+Again remove the dotted line from g13 to g4, as shown in the diagram below. If the matched subordinate objects: **{g11, g13}**, then activated superiors: **{g1, g4, g6, g7}**.
+
+<img src="./imgs/object-hierarchy3.png" width="750" height="350" >
+
+The analysis process is as follows:
+
+**matched objects {g11, g13}**
+
+**Level 1**: g11 => incl{g6, g7} excl{null}, g13 => incl{g3} excl{null}; new matched objects {g6, g7, g3}, `all matched objects` {g11, g13, g6, g7, g3}
+
+**new matched objects {g6, g7, g3}**
+
+**Level 2**: g6 => incl{g1} excl{g2, g3}, g7 => incl{g2, g4} excl{null}; new matched objects {g1, g2, g4}, `all matched objects` {g11, g13, g6, g1, g7, g2, g4}
+
+**new matched objects {g1, g2, g4}**
+
+**Level 3**: end
+
+Check the validity of `all matched objects` {g11, g13, g6, g1, g7, g2, g4}:
+
+1. g11, g13 are the originally matched nodes, so keep {g11, g13}.
+
+2. g6 is derived from the match of g11, implying the g10 is not matched(if g10 is matched, then g7 is not matched, as the exclude priority is higher), so keep g6.
+
+3. g1 is derived from the match of g6, which in turn is derived from the match of g11, implying the g5 is not matched, so keep g1.
+
+4. g7 is derived from the match of g11, implying the g10 is not matched, so keep g7.
+
+5. g2 is derived from the match of g7. However, since g6 is also matched and g2 excludes g6 with higher priority, g6's match causes g2 to be unmatched. Therefore, g2 is removed from the set.
+
+6. g4 is derived from the match of g13, so keep g4.
+
+7. Finally, `all matched objects` {g11, g13, g6, g1, g7, g4}, `matched super objects` {g1, g4, g6, g7}.
+
+The above example is strictly consistent with the case `ObjectExcludeTest.level_3_function` in the [test/object_nesting](../test/object_nesting/) test. Please run it to see the actual execution results. \ No newline at end of file
diff --git a/docs/overview.md b/docs/overview.md
index bb3f795..82b44ba 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, group2rule table, and rule table
+* Update rules in the item table, object2rule 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 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.
+The physical tables are mainly divided into three categories: the item table, object rule relationship table (rule table, object2rule table, object2object 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, condition, 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.
+As shown in the diagram below, maat organizes and abstracts configurations using terms such as item, object, literal, condition, 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).
+In addition, objects support nesting. For more detailed information, please refer to [object hierarchy](./object_hierarchy.md).
-If we define literal_id = {attribute_id, group_id}, then a literal is composed of one or more literal_ids. The multiple literal_ids that form the same condition have a logical “OR” relationship. The multiple conditions that form the same rule have a logical “AND” relationship, and there can be a maximum of 8 conditions within the same rule. In addition, the condition itself supports logical "NOT".
+If we define literal_id = {attribute_id, object_id}, then a literal is composed of one or more literal_ids. The multiple literal_ids that form the same condition have a logical “OR” relationship. The multiple conditions that form the same rule have a logical “AND” relationship, and there can be a maximum of 8 conditions within the same rule. In addition, the condition itself supports logical "NOT".
<img src="./imgs/rule_diagram.png" width="800" height="450" >
@@ -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 `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.
+ 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 object, it further searches for the matching `rule_id` through object2object runtime, object2rule 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.
@@ -102,7 +102,7 @@ maat_framework_perf_gtest: The performance test set is mainly used to test the t
* benchmark: Maat performance benchmark test, testing the scanning time of different scanning interfaces under different scale rule sets.
-* group_nesting: Functionality and performance test set for group nesting.
+* object_nesting: Functionality and performance test set for object nesting.
* ipport_plugin: Functionality and performance test set for the ipport_plugin table.
diff --git a/docs/terminology.md b/docs/terminology.md
index 723b24a..4956b93 100644
--- a/docs/terminology.md
+++ b/docs/terminology.md
@@ -1,7 +1,7 @@
# Terminology
* [Item](#item)
-* [Group(Object)](#groupobject)
+* [Object(Object)](#objectobject)
* [Rule(Policy)](#rulepolicy)
* [Condition(Condition)](#condition)
* [Literal](#literal)
@@ -32,27 +32,27 @@ As a filter for network attributes, the smallest unit of a rule
There are multiple types of items stored in corresponding tables such as string, IP and numerical range, more details can be found in [Item table](./maat_table.md#11-item-table).
-## Group(Object)
+## Object(Object)
-A group defines a set that can contain different types of items and can also reference other groups. The definition is made using items, which can be used to add to or exclude from the group definition. Groups can also have subordinate groups whose definitions are included in or excluded from the superior group.
+A object defines a set that can contain different types of items and can also reference other objects. The definition is made using items, which can be used to add to or exclude from the object definition. Objects can also have subordinate objects whose definitions are included in or excluded from the superior object.
-- An item only belongs to one group, but one group can has multiple items. The multiple items under the same group are logical 'OR' relationships. e.g.(g1 = item1 | item2).
+- An item only belongs to one object, but one object can has multiple items. The multiple items under the same object are logical 'OR' relationships. e.g.(g1 = item1 | item2).
-- A group can be included or excluded by other groups. For example, if group1 and group2 is included by group3, then the group3 is called the superior(super) group, and group1(group2) is called the subordinate(sub) group. There's a logical 'OR' relationship between the included sub groups under the same group, e.g.(g3 = incl-g1 | incl-g2). There's a logical 'AND' relationship between included group and excluded group under the same group, e.g.(g4 = incl-g1 & excl-g2).
+- A object can be included or excluded by other objects. For example, if object1 and object2 is included by object3, then the object3 is called the superior(super) object, and object1(object2) is called the subordinate(sub) object. There's a logical 'OR' relationship between the included sub objects under the same object, e.g.(g3 = incl-g1 | incl-g2). There's a logical 'AND' relationship between included object and excluded object under the same object, e.g.(g4 = incl-g1 & excl-g2).
-- Group supports multi-level nesting, see [group hierarchy](./overview.md#groupobject-nesting-and-hierarchies)
+- Object supports multi-level nesting, see [object hierarchy](./overview.md#objectobject-nesting-and-hierarchies)
-- A Group can be referenced by different rules.
+- A Object can be referenced by different rules.
-The relationship between group and group is stored in the [group2group table](./maat_table.md#14-group2group-table).
+The relationship between object and object is stored in the [object2object table](./maat_table.md#14-object2object-table).
## Rule(Policy)
-A conjunctive normal form(CNF) consisting of multiple groups and attributes.
+A conjunctive normal form(CNF) consisting of multiple objects and attributes.
`Note`: A rule can contain up to 8 conditions and multiple conditions in the same rule can be logical 'AND' and logical 'NOT' relationships.
-The relationship between group and rule is stored in the [group2rule table](./maat_table.md#13-group2rule-table).
+The relationship between object and rule is stored in the [object2rule table](./maat_table.md#13-object2rule-table).
<img src="./imgs/CNF.jpg" alt="exclude" style="zoom:80%" />
@@ -64,11 +64,11 @@ Conditions are divided into two categories based on whether they contain the log
## Literal
-A Literal consists of `attribute_id(attribute id)` and `group_id`. During the rules loading process, a unique condition_id will be generated based on the combination of attribute_id and group_id in the same condition.
+A Literal consists of `attribute_id(attribute id)` and `object_id`. During the rules loading process, a unique condition_id will be generated based on the combination of attribute_id and object_id in the same condition.
## Physical table
-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.
+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), [object2rule table](./maat_table.md#13-object2rule-table), [object2object table](./maat_table.md#14-object2object-table), and [xx_plugin table](./maat_table.md#15-plugin-table), and so on.
## Attribute
@@ -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 group2rule table is merged with the corresponding rule table to generate a rule runtime, meaning there is no separate group2rule runtime.
+The runtime generated by loading the configuration in the table into memory. Different tables have different runtimes. The object2rule table is merged with the corresponding rule table to generate a rule runtime, meaning there is no separate object2rule 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 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.
+From the diagram of [configuration relationship](./overview.md#12-configuration-relationship), it can be seen that if the object 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 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.
+From the relationship of item, object, and rule mentioned above, if a scan hits a certain rule, there must be a logical path composed of item_id -> object_id -> rule_id. Maat names this path the hit path. If a object has nested references, the hit path should be item_id -> sub_object_id -> object_id -> rule_id.
## Redis
diff --git a/include/maat.h b/include/maat.h
index 0d275ac..359e5cb 100644
--- a/include/maat.h
+++ b/include/maat.h
@@ -33,21 +33,21 @@ struct maat_hit_path {
int negate_option; // 1 means negate condition(condition)
int condition_index; // 0 ~ 7
long long item_id;
- long long sub_group_id;
- long long top_group_id;
+ long long sub_object_id;
+ long long top_object_id;
long long rule_id;
};
-struct maat_hit_group {
+struct maat_hit_object {
long long item_id;
- long long group_id;
+ long long object_id;
int attribute_id;
};
enum maat_scan_status {
MAAT_SCAN_ERR = -1, //scan error
- MAAT_SCAN_OK, //scan but not hit(group or rule)
- MAAT_SCAN_HALF_HIT, //half hit: hit group, not hit rule
+ MAAT_SCAN_OK, //scan but not hit(object or rule)
+ MAAT_SCAN_HALF_HIT, //half hit: hit object, not hit rule
MAAT_SCAN_HIT //scan hit rule
};
@@ -158,7 +158,7 @@ int maat_options_set_expr_engine(struct maat_options *opts, enum maat_expr_engin
int maat_options_set_hit_path_enabled(struct maat_options *opts);
-int maat_options_set_hit_group_enabled(struct maat_options *opts);
+int maat_options_set_hit_object_enabled(struct maat_options *opts);
/* maat_instance API */
struct maat *maat_new(struct maat_options *opts, const char *table_info_path);
@@ -287,8 +287,8 @@ int maat_scan_string(struct maat *instance, int table_id,
long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state);
-int maat_scan_group(struct maat *instance, int table_id,
- struct maat_hit_group *groups, size_t n_group,
+int maat_scan_object(struct maat *instance, int table_id,
+ struct maat_hit_object *objects, size_t n_object,
long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state);
@@ -330,34 +330,34 @@ int maat_state_get_rule_table_ids(struct maat_state *state, long long *rule_ids,
size_t maat_state_get_scan_count(struct maat_state *state);
/**
- * @brief direct group means group corresponding to item
+ * @brief direct object means object corresponding to item
*
- * NOTE: hit groups may be duplicated
+ * NOTE: hit objects may be duplicated
*
*/
-int maat_state_get_direct_hit_groups(struct maat_state *state,
- struct maat_hit_group *group_array,
+int maat_state_get_direct_hit_objects(struct maat_state *state,
+ struct maat_hit_object *object_array,
size_t array_size);
-size_t maat_state_get_direct_hit_group_cnt(struct maat_state *state);
+size_t maat_state_get_direct_hit_object_cnt(struct maat_state *state);
/**
- * @brief indirect group means superior group
+ * @brief indirect object means superior object
*
- * NOTE: hit groups may be duplicated
+ * NOTE: hit objects may be duplicated
*/
-int maat_state_get_indirect_hit_groups(struct maat_state *state,
- struct maat_hit_group *group_array,
+int maat_state_get_indirect_hit_objects(struct maat_state *state,
+ struct maat_hit_object *object_array,
size_t array_size);
-size_t maat_state_get_indirect_hit_group_cnt(struct maat_state *state);
+size_t maat_state_get_indirect_hit_object_cnt(struct maat_state *state);
/**
- * @brief get last scan hit groups(including direct/indirect)
+ * @brief get last scan hit objects(including direct/indirect)
*/
-int maat_state_get_last_hit_groups(struct maat_state *state,
- struct maat_hit_group *group_array,
+int maat_state_get_last_hit_objects(struct maat_state *state,
+ struct maat_hit_object *object_array,
size_t array_size);
-size_t maat_state_get_last_hit_group_cnt(struct maat_state *state);
+size_t maat_state_get_last_hit_object_cnt(struct maat_state *state);
#ifdef __cplusplus
}
diff --git a/readme.md b/readme.md
index df6c200..d8253a3 100644
--- a/readme.md
+++ b/readme.md
@@ -28,7 +28,7 @@ Read [getting started](./docs/getting_started.md) for building steps and play wi
* [Configuration management](./docs/configuration_management.md)
-* [Group hierarchy](./docs/group_hierarchy.md)
+* [Object hierarchy](./docs/object_hierarchy.md)
* [Logical combinations](./docs/logical_combinations.md)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c76bda8..7bed0f4 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_rule.c maat_group.c maat_ip.c maat_flag.c maat_interval.c maat_expr.c maat_plugin.c
+ maat_rule.c maat_object.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_attribute.c maat_stat.c)
set(LIB_SOURCE_FILES
diff --git a/src/inc_internal/maat_core.h b/src/inc_internal/maat_core.h
index e4d42ff..c50834c 100644
--- a/src/inc_internal/maat_core.h
+++ b/src/inc_internal/maat_core.h
@@ -44,7 +44,7 @@ extern "C"
#define INVALID_VERSION -1
#define mr_region_id_var "SEQUENCE_REGION"
-#define mr_group_id_var "SEQUENCE_GROUP"
+#define mr_object_id_var "SEQUENCE_OBJECT"
enum tag_match {
TAG_MATCH_ERR = -1,
@@ -54,7 +54,7 @@ enum tag_match {
struct maat_item {
long long item_id;
- long long group_id;
+ long long object_id;
};
struct maat_runtime {
@@ -121,7 +121,7 @@ struct maat_options {
int stat_on;
int perf_on;
int hit_path_on;
- int hit_group_on;
+ int hit_object_on;
int deferred_load_on;
int maat_json_is_gzipped;
diff --git a/src/inc_internal/maat_expr.h b/src/inc_internal/maat_expr.h
index 2e7693a..bdd3512 100644
--- a/src/inc_internal/maat_expr.h
+++ b/src/inc_internal/maat_expr.h
@@ -45,9 +45,9 @@ long long expr_runtime_get_version(void *expr_runtime);
/* expr runtime scan API */
/**
- * @brief scan string to get hit group_ids
+ * @brief scan string to get hit object_ids
*
- * @retval the num of hit group_id
+ * @retval the num of hit object_id
*/
int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id, const char *data,
size_t data_len, int attribute_id, struct maat_state *state);
diff --git a/src/inc_internal/maat_flag.h b/src/inc_internal/maat_flag.h
index c65cbae..63e5d56 100644
--- a/src/inc_internal/maat_flag.h
+++ b/src/inc_internal/maat_flag.h
@@ -43,9 +43,9 @@ long long flag_runtime_rule_count(void *flag_runtime);
/* flag runtime scan API */
/**
- * @brief scan flag to get hit group_ids
+ * @brief scan flag to get hit object_ids
*
- * @retval the num of hit group_id
+ * @retval the num of hit object_id
*/
int flag_runtime_scan(struct flag_runtime *flag_rt, int thread_id, long long flag,
int attribute_id, struct maat_state *state);
diff --git a/src/inc_internal/maat_group.h b/src/inc_internal/maat_group.h
deleted file mode 100644
index f03a23e..0000000
--- a/src/inc_internal/maat_group.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-**********************************************************************************************
-* File: maat_group.h
-* Description:
-* Authors: Liu wentan <[email protected]>
-* Date: 2022-10-31
-* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved.
-***********************************************************************************************
-*/
-
-#ifndef _MAAT_GROUP_H_
-#define _MAAT_GROUP_H_
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <stdint.h>
-
-#include "cJSON/cJSON.h"
-#include "maat_kv.h"
-#include "maat_table.h"
-
-struct maat_group;
-struct group2group_runtime;
-
-/* group2group schema API */
-void *group2group_schema_new(cJSON *json, struct table_manager *tbl_mgr,
- const char *table_name, struct log_handle *logger);
-void group2group_schema_free(void *g2g_schema);
-
-/* group2group runtime API */
-void *group2group_runtime_new(void *g2g_schema, size_t max_thread_num,
- struct maat_garbage_bin *garbage_bin,
- struct log_handle *logger);
-void group2group_runtime_free(void *g2g_runtime);
-
-int group2group_runtime_update(void *g2g_runtime, void *g2g_schema, const char *table_name,
- const char *line, int valid_column);
-
-int group2group_runtime_commit(void *g2g_runtime, const char *table_name, long long maat_rt_version);
-
-size_t group2group_runtime_get_super_groups(void *g2g_runtime, long long *group_ids,
- size_t n_group_ids, long long *super_group_ids,
- size_t super_group_ids_size);
-
-long long group2group_runtime_rule_count(void *g2g_runtime);
-
-long long group2group_runtime_exclude_rule_count(void *g2g_runtime);
-
-long long group2group_runtime_update_err_count(void *g2g_runtime);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/inc_internal/maat_interval.h b/src/inc_internal/maat_interval.h
index 0c82442..86382c3 100644
--- a/src/inc_internal/maat_interval.h
+++ b/src/inc_internal/maat_interval.h
@@ -44,9 +44,9 @@ long long interval_runtime_rule_count(void *interval_runtime);
/* interval runtime scan API */
/**
- * @brief scan interval to get hit group_ids
+ * @brief scan interval to get hit object_ids
*
- * @retval the num of hit group_id
+ * @retval the num of hit object_id
*/
int interval_runtime_scan(struct interval_runtime *interval_rt, int thread_id,
long long integer, int attribute_id, struct maat_state *state);
diff --git a/src/inc_internal/maat_limits.h b/src/inc_internal/maat_limits.h
index 45b9f1a..58542b3 100644
--- a/src/inc_internal/maat_limits.h
+++ b/src/inc_internal/maat_limits.h
@@ -22,8 +22,8 @@ extern "C"
#define MAX_NAME_STR_LEN 128
#define MAX_IP_STR_LEN 64
#define MAX_INSTANCE_NAME_LEN 15
-#define MAX_GROUP_IDS_STR_LEN 256
-#define MAX_GROUP_CNT 128
+#define MAX_OBJECT_IDS_STR_LEN 256
+#define MAX_OBJECT_CNT 128
#define MAX_CONJ_PARENTS_NUM 16
#ifdef __cplusplus
diff --git a/src/inc_internal/maat_object.h b/src/inc_internal/maat_object.h
new file mode 100644
index 0000000..ffc9d19
--- /dev/null
+++ b/src/inc_internal/maat_object.h
@@ -0,0 +1,58 @@
+/*
+**********************************************************************************************
+* File: maat_object.h
+* Description:
+* Authors: Liu wentan <[email protected]>
+* Date: 2022-10-31
+* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved.
+***********************************************************************************************
+*/
+
+#ifndef _MAAT_OBJECT_H_
+#define _MAAT_OBJECT_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <stdint.h>
+
+#include "cJSON/cJSON.h"
+#include "maat_kv.h"
+#include "maat_table.h"
+
+struct maat_object;
+struct object2object_runtime;
+
+/* object2object schema API */
+void *object2object_schema_new(cJSON *json, struct table_manager *tbl_mgr,
+ const char *table_name, struct log_handle *logger);
+void object2object_schema_free(void *g2g_schema);
+
+/* object2object runtime API */
+void *object2object_runtime_new(void *g2g_schema, size_t max_thread_num,
+ struct maat_garbage_bin *garbage_bin,
+ struct log_handle *logger);
+void object2object_runtime_free(void *g2g_runtime);
+
+int object2object_runtime_update(void *g2g_runtime, void *g2g_schema, const char *table_name,
+ const char *line, int valid_column);
+
+int object2object_runtime_commit(void *g2g_runtime, const char *table_name, long long maat_rt_version);
+
+size_t object2object_runtime_get_super_objects(void *g2g_runtime, long long *object_ids,
+ size_t n_object_ids, long long *super_object_ids,
+ size_t super_object_ids_size);
+
+long long object2object_runtime_rule_count(void *g2g_runtime);
+
+long long object2object_runtime_exclude_rule_count(void *g2g_runtime);
+
+long long object2object_runtime_update_err_count(void *g2g_runtime);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/inc_internal/maat_rule.h b/src/inc_internal/maat_rule.h
index da1bb45..6a3dda3 100644
--- a/src/inc_internal/maat_rule.h
+++ b/src/inc_internal/maat_rule.h
@@ -25,17 +25,17 @@ extern "C"
struct rule_schema;
struct rule_runtime;
struct rule_state;
-struct group2group_runtime;
+struct object2object_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,
+void *object2rule_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);
+void object2rule_schema_free(void *g2c_schema);
+int object2rule_associated_rule_table_id(void *g2c_schema);
/* rule runtime API */
void *rule_runtime_new(void *rule_schema, size_t max_thread_num,
@@ -64,24 +64,24 @@ size_t rule_runtime_get_hit_paths(struct rule_runtime *rule_rt, int thread_id,
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,
+/* object2rule runtime API */
+void *object2rule_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 object2rule_runtime_init(void *g2c_runtime, void *rule_runtime);
-void group2rule_runtime_free(void *g2c_runtime);
+void object2rule_runtime_free(void *g2c_runtime);
-int group2rule_runtime_update(void *g2c_runtime, void *g2c_schema,
+int object2rule_runtime_update(void *g2c_runtime, void *g2c_schema,
const char *table_name, const char *line,
int valid_column);
-long long group2rule_runtime_not_condition_count(void *g2c_runtime);
+long long object2rule_runtime_not_condition_count(void *g2c_runtime);
-long long group2rule_runtime_rule_count(void *g2c_runtime);
+long long object2rule_runtime_rule_count(void *g2c_runtime);
-long long group2rule_runtime_update_err_count(void *g2c_runtime);
+long long object2rule_runtime_update_err_count(void *g2c_runtime);
/* maat rule state API */
struct rule_state;
@@ -96,7 +96,7 @@ int rule_state_update(struct rule_state *rule_state, struct maat *maat_inst,
int attribute_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_clear_last_hit_object(struct rule_state *rule_state);
void rule_state_not_logic_update(struct rule_state *rule_state,
struct rule_runtime *rule_rt,
@@ -105,27 +105,27 @@ void rule_state_not_logic_update(struct rule_state *rule_state,
size_t rule_state_get_internal_hit_paths(struct rule_state *rule_state,
struct rule_runtime *rule_rt,
- struct group2group_runtime *g2g_rt,
+ struct object2object_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 rule_state_get_direct_hit_objects(struct rule_state *rule_state,
+ struct maat_hit_object *object_array,
size_t array_size);
-size_t rule_state_get_direct_hit_group_cnt(struct rule_state *rule_state);
+size_t rule_state_get_direct_hit_object_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 rule_state_get_indirect_hit_objects(struct rule_state *rule_state,
+ struct maat_hit_object *object_array,
size_t array_size);
-size_t rule_state_get_indirect_hit_group_cnt(struct rule_state *rule_state);
+size_t rule_state_get_indirect_hit_object_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 rule_state_get_last_hit_objects(struct rule_state *rule_state,
+ struct maat_hit_object *object_arary,
size_t array_size);
-size_t rule_state_get_last_hit_group_cnt(struct rule_state *rule_state);
+size_t rule_state_get_last_hit_object_cnt(struct rule_state *rule_state);
int rule_state_get_rule_table_id(struct rule_state *rule_state,
long long rule_id);
diff --git a/src/inc_internal/maat_table.h b/src/inc_internal/maat_table.h
index d1890c8..5cead74 100644
--- a/src/inc_internal/maat_table.h
+++ b/src/inc_internal/maat_table.h
@@ -40,8 +40,8 @@ enum table_type {
//above are physical table
TABLE_TYPE_ATTRIBUTE,
TABLE_TYPE_RULE,
- TABLE_TYPE_GROUP2GROUP,
- TABLE_TYPE_GROUP2RULE,
+ TABLE_TYPE_OBJECT2OBJECT,
+ TABLE_TYPE_OBJECT2RULE,
TABLE_TYPE_MAX
};
@@ -85,7 +85,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_rule_table_id(struct table_manager *tbl_mgr);
-int table_manager_get_group2group_table_id(struct table_manager *tbl_mgr);
+int table_manager_get_object2object_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 915861f..fca7ef6 100644
--- a/src/inc_internal/maat_utils.h
+++ b/src/inc_internal/maat_utils.h
@@ -56,7 +56,7 @@ extern "C"
#define MAX_HIT_PATH_NUM 4096
#define MAX_HIT_RULE_NUM 4096
-#define MAX_HIT_GROUP_NUM 4096
+#define MAX_HIT_OBJECT_NUM 4096
#define MAX_HIT_ITEM_NUM 4096
#define IPV4 4
diff --git a/src/json2iris.c b/src/json2iris.c
index a0ccded..f9863ad 100644
--- a/src/json2iris.c
+++ b/src/json2iris.c
@@ -28,22 +28,22 @@
#define MAX_COLUMN_NUM 32
#define MAX_PATH_LINE 512
#define MAX_BUFF_LEN 4096
-#define MAX_GROUP_ID_STR 128
+#define MAX_OBJECT_ID_STR 128
const int json_version = 1;
-const char *untitled_group_name = "Untitled";
-long long untitled_group_id = 123456789;
+const char *untitled_object_name = "Untitled";
+long long untitled_object_id = 123456789;
-enum maat_group_relation {
+enum maat_object_relation {
PARENT_TYPE_RULE = 0,
- PARENT_TYPE_GROUP
+ PARENT_TYPE_OBJECT
};
-struct group_info {
- int group_id;
- char group_name[NAME_MAX];
- UT_array *incl_sub_group_ids;
- UT_array *excl_sub_group_ids;
+struct object_info {
+ int object_id;
+ char object_name[NAME_MAX];
+ UT_array *incl_sub_object_ids;
+ UT_array *excl_sub_object_ids;
UT_hash_handle hh;
};
@@ -59,19 +59,19 @@ struct iris_table {
};
struct iris_description {
- int group_cnt;
+ int object_cnt;
int region_cnt;
char tmp_iris_dir[MAX_PATH_LINE];
char tmp_iris_index_dir[MAX_PATH_LINE];
char index_path[PATH_MAX];
- struct iris_table *group_table;
- struct iris_table *group2group_table;
- struct iris_table *group2rule_table;
+ struct iris_table *object_table;
+ struct iris_table *object2object_table;
+ struct iris_table *object2rule_table;
struct iris_table *rule_table;
- struct group_info *group_name_map;
+ struct object_info *object_name_map;
struct iris_table *iris_table_map;
struct maat_kv_store *str2int_map;
@@ -130,8 +130,8 @@ 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 *rule_tn, const char *group2rule_tn,
- const char* group2group_tn, redisContext *redis_write_ctx,
+ const char *rule_tn, const char *object2rule_tn,
+ const char* object2object_tn, redisContext *redis_write_ctx,
struct iris_description *iris_cfg)
{
memset(iris_cfg, 0, sizeof(struct iris_description));
@@ -183,10 +183,10 @@ set_iris_descriptor(const char *json_file, cJSON *json,
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);
+ iris_cfg->object2rule_table = query_table_info(iris_cfg, object2rule_tn,
+ TABLE_TYPE_OBJECT2RULE);
+ iris_cfg->object2object_table = query_table_info(iris_cfg, object2object_tn,
+ TABLE_TYPE_OBJECT2OBJECT);
if (encrypt_key && encrypt_algo) {
iris_cfg->encrypt_key = maat_strdup(encrypt_key);
@@ -198,21 +198,21 @@ set_iris_descriptor(const char *json_file, cJSON *json,
static void clear_iris_descriptor(struct iris_description *iris_cfg)
{
- if (iris_cfg->group_name_map != NULL) {
- struct group_info *node = NULL;
- struct group_info *tmp = NULL;
- HASH_ITER(hh, iris_cfg->group_name_map, node, tmp) {
- if (node->incl_sub_group_ids != NULL) {
- utarray_free(node->incl_sub_group_ids);
- node->incl_sub_group_ids = NULL;
+ if (iris_cfg->object_name_map != NULL) {
+ struct object_info *node = NULL;
+ struct object_info *tmp = NULL;
+ HASH_ITER(hh, iris_cfg->object_name_map, node, tmp) {
+ if (node->incl_sub_object_ids != NULL) {
+ utarray_free(node->incl_sub_object_ids);
+ node->incl_sub_object_ids = NULL;
}
- if (node->excl_sub_group_ids != NULL) {
- utarray_free(node->excl_sub_group_ids);
- node->excl_sub_group_ids = NULL;
+ if (node->excl_sub_object_ids != NULL) {
+ utarray_free(node->excl_sub_object_ids);
+ node->excl_sub_object_ids = NULL;
}
- HASH_DELETE(hh, iris_cfg->group_name_map, node);
+ HASH_DELETE(hh, iris_cfg->object_name_map, node);
FREE(node);
}
}
@@ -301,31 +301,31 @@ write_plugin_line(cJSON *plug_table_json, int sequence,
return 0;
}
-static struct group_info *group_info_read(struct group_info *group_name_map,
- const char *group_name)
+static struct object_info *object_info_read(struct object_info *object_name_map,
+ const char *object_name)
{
- struct group_info *node = NULL;
- HASH_FIND(hh, group_name_map, group_name, strlen(group_name), node);
+ struct object_info *node = NULL;
+ HASH_FIND(hh, object_name_map, object_name, strlen(object_name), node);
return node;
}
-UT_icd ut_json2iris_group_id_icd = {sizeof(int), NULL, NULL, NULL};
-static struct group_info *
-group_info_add_unsafe(struct iris_description *p_iris, const char *group_name,
- long long group_id)
+UT_icd ut_json2iris_object_id_icd = {sizeof(int), NULL, NULL, NULL};
+static struct object_info *
+object_info_add_unsafe(struct iris_description *p_iris, const char *object_name,
+ long long object_id)
{
- struct group_info *group_info = ALLOC(struct group_info, 1);
- utarray_new(group_info->incl_sub_group_ids, &ut_json2iris_group_id_icd);
- utarray_new(group_info->excl_sub_group_ids, &ut_json2iris_group_id_icd);
+ struct object_info *object_info = ALLOC(struct object_info, 1);
+ utarray_new(object_info->incl_sub_object_ids, &ut_json2iris_object_id_icd);
+ utarray_new(object_info->excl_sub_object_ids, &ut_json2iris_object_id_icd);
- group_info->group_id = group_id;
- strncpy(group_info->group_name, group_name, sizeof(group_info->group_name));
+ object_info->object_id = object_id;
+ strncpy(object_info->object_name, object_name, sizeof(object_info->object_name));
- HASH_ADD_KEYPTR(hh, p_iris->group_name_map, group_info->group_name,
- strlen(group_name), group_info);
+ HASH_ADD_KEYPTR(hh, p_iris->object_name_map, object_info->object_name,
+ strlen(object_name), object_info);
- return group_info;
+ return object_info;
}
static int get_region_seq(struct iris_description *iris_cfg)
@@ -435,7 +435,7 @@ write_flag_line(cJSON *region_json, struct iris_description *p_iris,
json_cmd[cmd_cnt].json_type=cJSON_Number;
cmd_cnt++;
- json_cmd[cmd_cnt].json_string = "group_id";
+ json_cmd[cmd_cnt].json_string = "object_id";
json_cmd[cmd_cnt].json_type = cJSON_Number;
cmd_cnt++;
@@ -473,7 +473,7 @@ write_expr_line(cJSON *region_json, struct iris_description *p_iris,
json_cmd[cmd_cnt].json_type = cJSON_Number;
cmd_cnt++;
- json_cmd[cmd_cnt].json_string = "group_id";
+ json_cmd[cmd_cnt].json_string = "object_id";
json_cmd[cmd_cnt].json_type = cJSON_Number;
cmd_cnt++;
@@ -512,7 +512,7 @@ write_ip_line(cJSON *region_json, struct iris_description *p_iris,
json_cmd[cmd_cnt].json_type = cJSON_Number;
cmd_cnt++;
- json_cmd[cmd_cnt].json_string = "group_id";
+ json_cmd[cmd_cnt].json_string = "object_id";
json_cmd[cmd_cnt].json_type = cJSON_Number;
cmd_cnt++;
@@ -548,7 +548,7 @@ write_interval_line(cJSON *region_json, struct iris_description *p_iris,
json_cmd[cmd_cnt].json_type = cJSON_Number;
cmd_cnt++;
- json_cmd[cmd_cnt].json_string = "group_id";
+ json_cmd[cmd_cnt].json_string = "object_id";
json_cmd[cmd_cnt].json_type = cJSON_Number;
cmd_cnt++;
@@ -571,7 +571,7 @@ write_interval_line(cJSON *region_json, struct iris_description *p_iris,
}
static int
-write_region_rule(cJSON *region_json, int rule_id, int group_id,
+write_region_rule(cJSON *region_json, int rule_id, int object_id,
struct iris_description *p_iris, struct log_handle *logger)
{
cJSON *item = cJSON_GetObjectItem(region_json, "table_name");
@@ -613,7 +613,7 @@ write_region_rule(cJSON *region_json, int rule_id, int group_id,
int region_id = get_region_seq(p_iris);
cJSON_AddNumberToObject(table_content, "region_id", region_id);
- cJSON_AddNumberToObject(table_content, "group_id", group_id);
+ cJSON_AddNumberToObject(table_content, "object_id", object_id);
cJSON_AddNumberToObject(table_content, "is_valid", 1);
struct iris_table *table_info = query_table_info(p_iris, table_name,
@@ -642,8 +642,8 @@ write_region_rule(cJSON *region_json, int rule_id, int group_id,
}
static int
-write_group2rule_line(int *group_ids, size_t n_group_id,
- int rule_id, int group_negate_option,
+write_object2rule_line(int *object_ids, size_t n_object_id,
+ int rule_id, int object_negate_option,
int condition_index, const char *attribute,
struct iris_description *p_iris,
struct iris_table *g2c_table)
@@ -654,26 +654,26 @@ write_group2rule_line(int *group_ids, size_t n_group_id,
if (g2c_table != NULL) {
table = g2c_table;
} else {
- if (NULL == p_iris->group2rule_table) {
+ if (NULL == p_iris->object2rule_table) {
return -1;
}
- table = p_iris->group2rule_table;
+ table = p_iris->object2rule_table;
}
- if (n_group_id > 1) {
+ if (n_object_id > 1) {
char tmp_str[64] = {0};
- char group_id_str[2048] = {0};
+ char object_id_str[2048] = {0};
- for (size_t i = 0; i < n_group_id; i++) {
- snprintf(tmp_str, sizeof(tmp_str), "%d,", group_ids[i]);
- strcat(group_id_str, tmp_str);
+ for (size_t i = 0; i < n_object_id; i++) {
+ snprintf(tmp_str, sizeof(tmp_str), "%d,", object_ids[i]);
+ strcat(object_id_str, tmp_str);
}
- 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,
- rule_id, group_negate_option, attribute, condition_index);
+ object_id_str[strlen(object_id_str) - 1] = '\0';
+ snprintf(buff, sizeof(buff), "%s\t%d\t%d\t%s\t%d\t1\n", object_id_str,
+ rule_id, object_negate_option, attribute, condition_index);
} else {
- snprintf(buff, sizeof(buff), "%d\t%d\t%d\t%s\t%d\t1\n", group_ids[0],
- rule_id, group_negate_option, attribute, condition_index);
+ snprintf(buff, sizeof(buff), "%d\t%d\t%d\t%s\t%d\t1\n", object_ids[0],
+ rule_id, object_negate_option, attribute, condition_index);
}
table->write_pos += memcat(&(table->buff), table->write_pos,
@@ -684,60 +684,60 @@ write_group2rule_line(int *group_ids, size_t n_group_id,
}
static int
-write_group2group_line(int group_id, UT_array *incl_sub_group_ids,
- UT_array *excl_sub_group_ids,
+write_object2object_line(int object_id, UT_array *incl_sub_object_ids,
+ UT_array *excl_sub_object_ids,
struct iris_description *p_iris)
{
char buff[MAX_BUFF_LEN*4] = {0};
- struct iris_table *table = p_iris->group2group_table;
+ struct iris_table *table = p_iris->object2object_table;
if (NULL == table) {
return -1;
}
size_t i = 0, pos = 0;
- char incl_sub_group_id_str[MAX_BUFF_LEN] = {0};
- char excl_sub_group_id_str[MAX_BUFF_LEN] = {0};
+ char incl_sub_object_id_str[MAX_BUFF_LEN] = {0};
+ char excl_sub_object_id_str[MAX_BUFF_LEN] = {0};
- if (0 == utarray_len(incl_sub_group_ids) &&
- 0 == utarray_len(excl_sub_group_ids)) {
+ if (0 == utarray_len(incl_sub_object_ids) &&
+ 0 == utarray_len(excl_sub_object_ids)) {
return 0;
}
int *tmp_id = NULL;
- char tmp_str[MAX_GROUP_ID_STR] = {0};
- for (i = 0; i < utarray_len(incl_sub_group_ids); i++) {
- tmp_id = (int *)utarray_eltptr(incl_sub_group_ids, i);
+ char tmp_str[MAX_OBJECT_ID_STR] = {0};
+ for (i = 0; i < utarray_len(incl_sub_object_ids); i++) {
+ tmp_id = (int *)utarray_eltptr(incl_sub_object_ids, i);
sprintf(tmp_str, "%d,", *tmp_id);
- sprintf(incl_sub_group_id_str + pos, "%s", tmp_str);
+ sprintf(incl_sub_object_id_str + pos, "%s", tmp_str);
pos += strlen(tmp_str);
}
const char *null_str = "null";
- size_t str_len = strlen(incl_sub_group_id_str);
+ size_t str_len = strlen(incl_sub_object_id_str);
if (str_len > 0) {
- incl_sub_group_id_str[str_len - 1] = '\0';
+ incl_sub_object_id_str[str_len - 1] = '\0';
} else {
- memcpy(incl_sub_group_id_str, null_str, strlen(null_str));
+ memcpy(incl_sub_object_id_str, null_str, strlen(null_str));
}
pos = 0;
memset(tmp_str, 0, sizeof(tmp_str));
- for (i = 0; i < utarray_len(excl_sub_group_ids); i++) {
- tmp_id = (int *)utarray_eltptr(excl_sub_group_ids, i);
+ for (i = 0; i < utarray_len(excl_sub_object_ids); i++) {
+ tmp_id = (int *)utarray_eltptr(excl_sub_object_ids, i);
sprintf(tmp_str, "%d,", *tmp_id);
- sprintf(excl_sub_group_id_str + pos, "%s", tmp_str);
+ sprintf(excl_sub_object_id_str + pos, "%s", tmp_str);
pos += strlen(tmp_str);
}
- str_len = strlen(excl_sub_group_id_str);
+ str_len = strlen(excl_sub_object_id_str);
if (str_len > 0) {
- excl_sub_group_id_str[str_len - 1] = '\0';
+ excl_sub_object_id_str[str_len - 1] = '\0';
} else {
- memcpy(excl_sub_group_id_str, null_str, strlen(null_str));
+ memcpy(excl_sub_object_id_str, null_str, strlen(null_str));
}
- snprintf(buff, sizeof(buff), "%d\t%s\t%s\t1\n", group_id,
- incl_sub_group_id_str, excl_sub_group_id_str);
+ snprintf(buff, sizeof(buff), "%d\t%s\t%s\t1\n", object_id,
+ incl_sub_object_id_str, excl_sub_object_id_str);
table->write_pos += memcat(&(table->buff), table->write_pos,
&(table->buff_sz), buff, strlen(buff));
@@ -747,119 +747,119 @@ write_group2group_line(int group_id, UT_array *incl_sub_group_ids,
}
static int
-write_group_rule(cJSON *group_json, int parent_id,
+write_object_rule(cJSON *object_json, int parent_id,
int parent_type, int tracking_rule_id,
- int Nth_group, struct iris_description *p_iris,
+ int Nth_object, struct iris_description *p_iris,
struct log_handle *logger)
{
int ret = 0;
- int group_negate_option = 0;
+ int object_negate_option = 0;
int condition_index = 0;
- const char *group_name = NULL;
- char group_name_array[32][MAX_NAME_STR_LEN];
- size_t group_name_cnt = 0;
- long long group_id = -1;
+ const char *object_name = NULL;
+ char object_name_array[32][MAX_NAME_STR_LEN];
+ size_t object_name_cnt = 0;
+ long long object_id = -1;
const char *attribute = NULL;
struct iris_table *g2c_table = NULL;
- cJSON *item = cJSON_GetObjectItem(group_json, "group_name");
+ cJSON *item = cJSON_GetObjectItem(object_json, "object_name");
if (NULL == item) {
- group_name = untitled_group_name;
+ object_name = untitled_object_name;
} else if (item->type == cJSON_String) {
- group_name = item->valuestring;
+ object_name = item->valuestring;
} else if (item->type == cJSON_Array) {
- group_name_cnt = cJSON_GetArraySize(item);
- assert(group_name_cnt <= 32);
- for (size_t i = 0; i < group_name_cnt; i++) {
+ object_name_cnt = cJSON_GetArraySize(item);
+ assert(object_name_cnt <= 32);
+ for (size_t i = 0; i < object_name_cnt; i++) {
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 rule:%d format error",
+ "[%s:%d] object_name of rule:%d format error",
__FUNCTION__, __LINE__, parent_id);
return -1;
}
- memset(group_name_array[i], 0, sizeof(group_name_array[i]));
- memcpy(group_name_array[i], tmp_json->valuestring,
+ memset(object_name_array[i], 0, sizeof(object_name_array[i]));
+ memcpy(object_name_array[i], tmp_json->valuestring,
strlen(tmp_json->valuestring));
}
}
- item = cJSON_GetObjectItem(group_json, "group_id");
+ item = cJSON_GetObjectItem(object_json, "object_id");
if (item != NULL && item->type == cJSON_Number) {
- group_id = item->valueint;
+ object_id = item->valueint;
}
if (parent_type == PARENT_TYPE_RULE) {
- item = cJSON_GetObjectItem(group_json, "attribute");
+ item = cJSON_GetObjectItem(object_json, "attribute");
if (NULL == item || item->type != cJSON_String) {
attribute = "null";
} else {
attribute = item->valuestring;
}
- item = cJSON_GetObjectItem(group_json, "negate_option");
+ item = cJSON_GetObjectItem(object_json, "negate_option");
if (NULL == item || item->type != cJSON_Number) {
- group_negate_option = 0;
+ object_negate_option = 0;
} else {
- group_negate_option = item->valueint;
+ object_negate_option = item->valueint;
}
- item = cJSON_GetObjectItem(group_json, "condition_index");
+ item = cJSON_GetObjectItem(object_json, "condition_index");
if (NULL == item || item->type != cJSON_Number) {
- condition_index = Nth_group;
+ condition_index = Nth_object;
} else {
condition_index = item->valueint;
}
- item = cJSON_GetObjectItem(group_json, "g2c_table_name");
+ item = cJSON_GetObjectItem(object_json, "g2c_table_name");
if (item != NULL && item->type == cJSON_String) {
g2c_table = query_table_info(p_iris, item->valuestring,
- TABLE_TYPE_GROUP2RULE);
+ TABLE_TYPE_OBJECT2RULE);
}
}
- if (group_name_cnt > 0) {
- int group_ids[group_name_cnt];
- for (size_t i = 0; i < group_name_cnt; i++) {
- struct group_info *group_info =
- group_info_read(p_iris->group_name_map, group_name_array[i]);
- if (NULL == group_info) {
- log_fatal(logger, MODULE_JSON2IRIS, "[%s:%d] group_name:%s"
- " has no group_id", __FUNCTION__, __LINE__,
- group_name_array[i]);
+ if (object_name_cnt > 0) {
+ int object_ids[object_name_cnt];
+ for (size_t i = 0; i < object_name_cnt; i++) {
+ struct object_info *object_info =
+ object_info_read(p_iris->object_name_map, object_name_array[i]);
+ if (NULL == object_info) {
+ log_fatal(logger, MODULE_JSON2IRIS, "[%s:%d] object_name:%s"
+ " has no object_id", __FUNCTION__, __LINE__,
+ object_name_array[i]);
return -1;
}
- group_ids[i] = group_info->group_id;
+ object_ids[i] = object_info->object_id;
}
assert(parent_type == PARENT_TYPE_RULE);
- ret = write_group2rule_line(group_ids, group_name_cnt, parent_id,
- group_negate_option, condition_index,
+ ret = write_object2rule_line(object_ids, object_name_cnt, parent_id,
+ object_negate_option, condition_index,
attribute, p_iris, g2c_table);
} else {
- struct group_info *group_info =
- group_info_read(p_iris->group_name_map, group_name);
- // exist group name, regions and sub groups will be ommit.
- if (NULL == group_info) {
- if (0 == strncasecmp(group_name, untitled_group_name,
- strlen(untitled_group_name))) {
- group_id = untitled_group_id;
+ struct object_info *object_info =
+ object_info_read(p_iris->object_name_map, object_name);
+ // exist object name, regions and sub objects will be ommit.
+ if (NULL == object_info) {
+ if (0 == strncasecmp(object_name, untitled_object_name,
+ strlen(untitled_object_name))) {
+ object_id = untitled_object_id;
}
- if (-1 == group_id) {
+ if (-1 == object_id) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] group_name:<%s> has no group_id",
- __FUNCTION__, __LINE__, group_name);
+ "[%s:%d] object_name:<%s> has no object_id",
+ __FUNCTION__, __LINE__, object_name);
return -1;
}
- group_info = group_info_add_unsafe(p_iris, group_name, group_id);
- cJSON *region_json = cJSON_GetObjectItem(group_json, "regions");
+ object_info = object_info_add_unsafe(p_iris, object_name, object_id);
+ cJSON *region_json = cJSON_GetObjectItem(object_json, "regions");
if (region_json != NULL) {
cJSON *region_rule = NULL;
cJSON_ArrayForEach(region_rule, region_json) {
ret = write_region_rule(region_rule, tracking_rule_id,
- group_info->group_id, p_iris, logger);
+ object_info->object_id, p_iris, logger);
if (ret < 0) {
log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] rule rule %d write region error",
@@ -869,14 +869,14 @@ write_group_rule(cJSON *group_json, int parent_id,
}
}
- cJSON *sub_groups = cJSON_GetObjectItem(group_json, "sub_groups");
- if (sub_groups != NULL) {
+ cJSON *sub_objects = cJSON_GetObjectItem(object_json, "sub_objects");
+ if (sub_objects != NULL) {
// recursively
int i = 0;
- cJSON_ArrayForEach(item, sub_groups) {
+ cJSON_ArrayForEach(item, sub_objects) {
i++;
- ret = write_group_rule(item, group_info->group_id,
- PARENT_TYPE_GROUP, tracking_rule_id,
+ ret = write_object_rule(item, object_info->object_id,
+ PARENT_TYPE_OBJECT, tracking_rule_id,
i, p_iris, logger);
if (ret < 0) {
return -1;
@@ -884,21 +884,21 @@ write_group_rule(cJSON *group_json, int parent_id,
}
}
- if (NULL == region_json && NULL == sub_groups) {
+ if (NULL == region_json && NULL == sub_objects) {
log_info(logger, MODULE_JSON2IRIS,
- "[%s:%d] A group of rule rule %d has neither regions, "
- "sub groups, nor refered another existed group",
+ "[%s:%d] A object of rule rule %d has neither regions, "
+ "sub objects, nor refered another existed object",
__FUNCTION__, __LINE__, tracking_rule_id);
}
}
if (parent_type == PARENT_TYPE_RULE) {
- ret = write_group2rule_line(&(group_info->group_id), 1, parent_id,
- group_negate_option, condition_index,
+ ret = write_object2rule_line(&(object_info->object_id), 1, parent_id,
+ object_negate_option, condition_index,
attribute, p_iris, g2c_table);
if (ret < 0) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] rule:%d write group error",
+ "[%s:%d] rule:%d write object error",
__FUNCTION__, __LINE__, parent_id);
return -1;
}
@@ -921,14 +921,14 @@ write_rule_line(cJSON *rule, struct iris_description *p_iris,
}
int rule_id = item->valueint;
- cJSON *group_array = cJSON_GetObjectItem(rule, "groups");
- int group_num = cJSON_GetArraySize(group_array);
- int *condition_ids = ALLOC(int, group_num);
+ cJSON *object_array = cJSON_GetObjectItem(rule, "objects");
+ int object_num = cJSON_GetArraySize(object_array);
+ int *condition_ids = ALLOC(int, object_num);
int condition_num = 0;
- cJSON *group_obj = NULL;
+ cJSON *object_obj = NULL;
- cJSON_ArrayForEach(group_obj, group_array) {
- item = cJSON_GetObjectItem(group_obj, "condition_index");
+ cJSON_ArrayForEach(object_obj, object_array) {
+ item = cJSON_GetObjectItem(object_obj, "condition_index");
if (item) {
int i = 0;
int condition_index = item->valueint;
@@ -947,7 +947,7 @@ write_rule_line(cJSON *rule, struct iris_description *p_iris,
FREE(condition_ids);
if (condition_num == 0) {
- condition_num = group_num;
+ condition_num = object_num;
}
cJSON_AddNumberToObject(rule, "condition_num", condition_num);
@@ -1086,67 +1086,67 @@ static int write_index_file(struct iris_description *p_iris,
return 0;
}
-int recursive_traverse_sub_groups(cJSON *group_obj, struct iris_description *p_iris,
+int recursive_traverse_sub_objects(cJSON *object_obj, struct iris_description *p_iris,
struct log_handle *logger)
{
- cJSON *sub_group_array = cJSON_GetObjectItem(group_obj, "sub_groups");
- if (NULL == sub_group_array) {
+ cJSON *sub_object_array = cJSON_GetObjectItem(object_obj, "sub_objects");
+ if (NULL == sub_object_array) {
return 0;
}
- cJSON *item = cJSON_GetObjectItem(group_obj, "group_name");
+ cJSON *item = cJSON_GetObjectItem(object_obj, "object_name");
if (NULL == item || item->type != cJSON_String) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] has no group_name before sub_groups.");
+ "[%s:%d] has no object_name before sub_objects.");
return -1;
}
- const char *parent_group_name = item->valuestring;
- struct group_info *parent_group = group_info_read(p_iris->group_name_map,
+ const char *parent_object_name = item->valuestring;
+ struct object_info *parent_object = object_info_read(p_iris->object_name_map,
item->valuestring);
- if (NULL == parent_group) {
- item = cJSON_GetObjectItem(group_obj, "group_id");
+ if (NULL == parent_object) {
+ item = cJSON_GetObjectItem(object_obj, "object_id");
if (NULL == item || item->type != cJSON_Number) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] group_name:%s has no group_id.", parent_group_name);
+ "[%s:%d] object_name:%s has no object_id.", parent_object_name);
return -1;
}
- parent_group = group_info_add_unsafe(p_iris, parent_group_name, item->valueint);
+ parent_object = object_info_add_unsafe(p_iris, parent_object_name, item->valueint);
}
- cJSON *sub_group_obj = NULL;
- cJSON_ArrayForEach(sub_group_obj, sub_group_array) {
- cJSON *tmp_item1 = cJSON_GetObjectItem(sub_group_obj, "group_name");
+ cJSON *sub_object_obj = NULL;
+ cJSON_ArrayForEach(sub_object_obj, sub_object_array) {
+ cJSON *tmp_item1 = cJSON_GetObjectItem(sub_object_obj, "object_name");
if (NULL == tmp_item1 || tmp_item1->type != cJSON_String) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d]group:%s's sub_groups has no group_name",
- __FUNCTION__, __LINE__, parent_group_name);
+ "[%s:%d]object:%s's sub_objects has no object_name",
+ __FUNCTION__, __LINE__, parent_object_name);
return -1;
}
- int group_id = -1;
+ int object_id = -1;
int is_exclude = 0;
- cJSON *tmp_item2 = cJSON_GetObjectItem(sub_group_obj, "group_id");
+ cJSON *tmp_item2 = cJSON_GetObjectItem(sub_object_obj, "object_id");
if (NULL == tmp_item2) {
- struct group_info *group = group_info_read(p_iris->group_name_map,
+ struct object_info *object = object_info_read(p_iris->object_name_map,
tmp_item1->valuestring);
- assert(group != NULL);
- group_id = group->group_id;
+ assert(object != NULL);
+ object_id = object->object_id;
} else {
- group_id = tmp_item2->valueint;
+ object_id = tmp_item2->valueint;
}
- cJSON *tmp_item3 = cJSON_GetObjectItem(sub_group_obj, "is_exclude");
+ cJSON *tmp_item3 = cJSON_GetObjectItem(sub_object_obj, "is_exclude");
if (tmp_item3 != NULL && tmp_item3->type == cJSON_Number) {
is_exclude = tmp_item3->valueint;
}
if (0 == is_exclude) {
- utarray_push_back(parent_group->incl_sub_group_ids, &group_id);
+ utarray_push_back(parent_object->incl_sub_object_ids, &object_id);
} else {
- utarray_push_back(parent_group->excl_sub_group_ids, &group_id);
+ utarray_push_back(parent_object->excl_sub_object_ids, &object_id);
}
- int ret = recursive_traverse_sub_groups(sub_group_obj, p_iris, logger);
+ int ret = recursive_traverse_sub_objects(sub_object_obj, p_iris, logger);
if (ret < 0) {
return -1;
}
@@ -1155,21 +1155,21 @@ int recursive_traverse_sub_groups(cJSON *group_obj, struct iris_description *p_i
return 0;
}
-static int write_group2group_rule(struct iris_description *p_iris,
+static int write_object2object_rule(struct iris_description *p_iris,
struct log_handle *logger)
{
int ret = 0;
- struct group_info *group_info = NULL, *tmp_group_info = NULL;
+ struct object_info *object_info = NULL, *tmp_object_info = NULL;
- HASH_ITER(hh, p_iris->group_name_map, group_info, tmp_group_info) {
- ret = write_group2group_line(group_info->group_id,
- group_info->incl_sub_group_ids,
- group_info->excl_sub_group_ids,
+ HASH_ITER(hh, p_iris->object_name_map, object_info, tmp_object_info) {
+ ret = write_object2object_line(object_info->object_id,
+ object_info->incl_sub_object_ids,
+ object_info->excl_sub_object_ids,
p_iris);
if (ret < 0) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] write group2group line failed for super_group:%d",
- __FUNCTION__, __LINE__, group_info->group_id);
+ "[%s:%d] write object2object line failed for super_object:%d",
+ __FUNCTION__, __LINE__, object_info->object_id);
return -1;
}
}
@@ -1182,7 +1182,7 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
{
int i = 0;
int ret = 0;
- static struct group_info *parent_group = NULL; // TODO
+ static struct object_info *parent_object = NULL; // TODO
cJSON *plug_tables = cJSON_GetObjectItem(json, "plugin_table");
if (plug_tables != NULL) {
@@ -1193,35 +1193,35 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
}
}
- cJSON *group_array = cJSON_GetObjectItem(json, "groups"); // sub-group to group
- if (group_array != NULL) {
- cJSON *group_obj = NULL;
- cJSON_ArrayForEach(group_obj, group_array) {
- const char *parent_group_name = NULL;
- cJSON *item = cJSON_GetObjectItem(group_obj, "parent_group");
+ cJSON *object_array = cJSON_GetObjectItem(json, "objects"); // sub-object to object
+ if (object_array != NULL) {
+ cJSON *object_obj = NULL;
+ cJSON_ArrayForEach(object_obj, object_array) {
+ const char *parent_object_name = NULL;
+ cJSON *item = cJSON_GetObjectItem(object_obj, "parent_object");
if (NULL == item || item->type != cJSON_String) {
- parent_group_name = untitled_group_name;
+ parent_object_name = untitled_object_name;
} else {
- parent_group_name = item->string;
+ parent_object_name = item->string;
}
- parent_group = group_info_read(p_iris->group_name_map, parent_group_name);
- if (NULL == parent_group) {
- parent_group = group_info_add_unsafe(p_iris, parent_group_name,
- untitled_group_id);
+ parent_object = object_info_read(p_iris->object_name_map, parent_object_name);
+ if (NULL == parent_object) {
+ parent_object = object_info_add_unsafe(p_iris, parent_object_name,
+ untitled_object_id);
}
- item = cJSON_GetObjectItem(group_obj, "group_id");
+ item = cJSON_GetObjectItem(object_obj, "object_id");
if (NULL == item || item->type != cJSON_Number) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d]Global groups has group with no group_id.",
+ "[%s:%d]Global objects has object with no object_id.",
__FUNCTION__, __LINE__);
return -1;
}
- utarray_push_back(parent_group->incl_sub_group_ids, &item->valueint);
- ret = write_group_rule(group_obj, parent_group->group_id,
- PARENT_TYPE_GROUP, 0, 0, p_iris, logger);
+ utarray_push_back(parent_object->incl_sub_object_ids, &item->valueint);
+ ret = write_object_rule(object_obj, parent_object->object_id,
+ PARENT_TYPE_OBJECT, 0, 0, p_iris, logger);
if (ret < 0) {
return -1;
}
@@ -1245,26 +1245,26 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
return -1;
}
- group_array = cJSON_GetObjectItem(rule_obj, "groups");
- if (NULL == group_array) {
+ object_array = cJSON_GetObjectItem(rule_obj, "objects");
+ if (NULL == object_array) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] rule rule %d have no group",
+ "[%s:%d] rule rule %d have no object",
__FUNCTION__, __LINE__, rule_id);
return -1;
}
- int group_cnt = cJSON_GetArraySize(group_array);
- if (group_cnt <= 0) {
+ int object_cnt = cJSON_GetArraySize(object_array);
+ if (object_cnt <= 0) {
log_fatal(logger, MODULE_JSON2IRIS,
- "[%s:%d] rule rule %d have no groups",
+ "[%s:%d] rule rule %d have no objects",
__FUNCTION__, __LINE__, rule_id);
return -1;
}
i = 0;
- cJSON *group_obj = NULL;
- cJSON_ArrayForEach(group_obj, group_array) {
- ret = write_group_rule(group_obj, rule_id, PARENT_TYPE_RULE,
+ cJSON *object_obj = NULL;
+ cJSON_ArrayForEach(object_obj, object_array) {
+ ret = write_object_rule(object_obj, rule_id, PARENT_TYPE_RULE,
rule_id, i, p_iris, logger);
if (ret < 0) {
return -1;
@@ -1274,11 +1274,11 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
}
cJSON_ArrayForEach(rule_obj, rule_array) {
- cJSON *group_array = cJSON_GetObjectItem(rule_obj, "groups");
+ cJSON *object_array = cJSON_GetObjectItem(rule_obj, "objects");
- cJSON *group_obj = NULL;
- cJSON_ArrayForEach(group_obj, group_array) {
- ret = recursive_traverse_sub_groups(group_obj, p_iris, logger);
+ cJSON *object_obj = NULL;
+ cJSON_ArrayForEach(object_obj, object_array) {
+ ret = recursive_traverse_sub_objects(object_obj, p_iris, logger);
if (ret < 0) {
return -1;
}
@@ -1286,7 +1286,7 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
}
}
- ret = write_group2group_rule(p_iris, logger);
+ ret = write_object2object_rule(p_iris, logger);
if (ret < 0) {
return -1;
}
@@ -1307,8 +1307,8 @@ int json2iris(const char *json_buff, const char *json_filename,
int ret = -1;
cJSON *tmp_obj = NULL;
const char *rule_tbl_name = NULL;
- const char *group2rule_tbl_name = NULL;
- const char *group2group_tbl_name = NULL;
+ const char *object2rule_tbl_name = NULL;
+ const char *object2object_tbl_name = NULL;
struct iris_description iris_cfg;
memset(&iris_cfg, 0, sizeof(iris_cfg));
@@ -1326,19 +1326,19 @@ int json2iris(const char *json_buff, const char *json_filename,
rule_tbl_name = tmp_obj->valuestring;
}
- tmp_obj = cJSON_GetObjectItem(json, "group2rule_table");
+ tmp_obj = cJSON_GetObjectItem(json, "object2rule_table");
if (tmp_obj) {
- group2rule_tbl_name = tmp_obj->valuestring;
+ object2rule_tbl_name = tmp_obj->valuestring;
}
- tmp_obj = cJSON_GetObjectItem(json, "group2group_table");
+ tmp_obj = cJSON_GetObjectItem(json, "object2object_table");
if (tmp_obj) {
- group2group_tbl_name = tmp_obj->valuestring;
+ object2object_tbl_name = tmp_obj->valuestring;
}
ret = set_iris_descriptor(json_filename, json, encrypt_key, encrypt_algo,
- rule_tbl_name, group2rule_tbl_name,
- group2group_tbl_name, redis_write_ctx, &iris_cfg);
+ rule_tbl_name, object2rule_tbl_name,
+ object2object_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 0cf4ffa..660d094 100644
--- a/src/maat_api.c
+++ b/src/maat_api.c
@@ -29,7 +29,7 @@
#include "ip_matcher.h"
#include "adapter_hs.h"
#include "maat_garbage_collection.h"
-#include "maat_group.h"
+#include "maat_object.h"
#include "maat_expr.h"
#include "maat_flag.h"
#include "maat_interval.h"
@@ -288,13 +288,13 @@ int maat_options_set_hit_path_enabled(struct maat_options *opts)
return 0;
}
-int maat_options_set_hit_group_enabled(struct maat_options *opts)
+int maat_options_set_hit_object_enabled(struct maat_options *opts)
{
if (NULL == opts) {
return -1;
}
- opts->hit_group_on = 1;
+ opts->hit_object_on = 1;
return 0;
}
@@ -1081,22 +1081,22 @@ flag_scan(struct table_manager *tbl_mgr, int thread_id, long long flag,
}
}
- int group_hit_cnt = flag_runtime_scan((struct flag_runtime *)flag_rt,
+ int object_hit_cnt = flag_runtime_scan((struct flag_runtime *)flag_rt,
thread_id, flag, attribute_id, state);
- if (group_hit_cnt <= 0) {
- return group_hit_cnt;
+ if (object_hit_cnt <= 0) {
+ return object_hit_cnt;
}
if (virt_rt != NULL) {
- //Note: group_hit_cnt is equivalent to item_hit_cnt
+ //Note: object_hit_cnt is equivalent to item_hit_cnt
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
- thread_id, group_hit_cnt);
+ thread_id, object_hit_cnt);
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, thread_id);
}
flag_runtime_hit_times_inc((struct flag_runtime *)flag_rt, thread_id);
- return group_hit_cnt;
+ return object_hit_cnt;
}
static int
@@ -1133,22 +1133,22 @@ interval_scan(struct table_manager *tbl_mgr, int thread_id, long long integer,
}
}
- int group_hit_cnt = interval_runtime_scan((struct interval_runtime *)interval_rt,
+ int object_hit_cnt = interval_runtime_scan((struct interval_runtime *)interval_rt,
thread_id, integer, attribute_id, state);
- if (group_hit_cnt <= 0) {
- return group_hit_cnt;
+ if (object_hit_cnt <= 0) {
+ return object_hit_cnt;
}
if (virt_rt != NULL) {
- //Note: group_hit_cnt is equivalent to item_hit_cnt
+ //Note: object_hit_cnt is equivalent to item_hit_cnt
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
- thread_id, group_hit_cnt);
+ thread_id, object_hit_cnt);
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, thread_id);
}
interval_runtime_hit_times_inc((struct interval_runtime *)interval_rt, thread_id);
- return group_hit_cnt;
+ return object_hit_cnt;
}
static int
@@ -1179,22 +1179,22 @@ ipv4_scan(struct table_manager *tbl_mgr, int thread_id, uint32_t ip_addr,
}
}
- int group_hit_cnt = ip_runtime_scan((struct ip_runtime *)ip_rt, thread_id, IPv4,
+ int object_hit_cnt = ip_runtime_scan((struct ip_runtime *)ip_rt, thread_id, IPv4,
(uint8_t *)&ip_addr, port, attribute_id, state);
- if (group_hit_cnt <= 0) {
- return group_hit_cnt;
+ if (object_hit_cnt <= 0) {
+ return object_hit_cnt;
}
if (virt_rt != NULL) {
- //Note: group_hit_cnt is equivalent to item_hit_cnt
+ //Note: object_hit_cnt is equivalent to item_hit_cnt
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
- thread_id, group_hit_cnt);
+ thread_id, object_hit_cnt);
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, thread_id);
}
ip_runtime_hit_times_inc((struct ip_runtime *)ip_rt, thread_id);
- return group_hit_cnt;
+ return object_hit_cnt;
}
static int
@@ -1225,22 +1225,22 @@ ipv6_scan(struct table_manager *tbl_mgr, int thread_id, uint8_t *ip_addr,
}
}
- int group_hit_cnt = ip_runtime_scan((struct ip_runtime *)ip_rt, thread_id, IPv6,
+ int object_hit_cnt = ip_runtime_scan((struct ip_runtime *)ip_rt, thread_id, IPv6,
ip_addr, port, attribute_id, state);
- if (group_hit_cnt <= 0) {
- return group_hit_cnt;
+ if (object_hit_cnt <= 0) {
+ return object_hit_cnt;
}
if (virt_rt != NULL) {
- //Note: group_hit_cnt is equivalent to item_hit_cnt
+ //Note: object_hit_cnt is equivalent to item_hit_cnt
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
- thread_id, group_hit_cnt);
+ thread_id, object_hit_cnt);
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, thread_id);
}
ip_runtime_hit_times_inc((struct ip_runtime *)ip_rt, thread_id);
- return group_hit_cnt;
+ return object_hit_cnt;
}
static int
@@ -1280,27 +1280,27 @@ string_scan(struct table_manager *tbl_mgr, int thread_id,
}
}
- int group_hit_cnt = expr_runtime_scan((struct expr_runtime *)expr_rt,
+ int object_hit_cnt = expr_runtime_scan((struct expr_runtime *)expr_rt,
thread_id, data, data_len,
attribute_id, state);
- if (group_hit_cnt <= 0) {
- return group_hit_cnt;
+ if (object_hit_cnt <= 0) {
+ return object_hit_cnt;
}
if (virt_rt != NULL) {
- //Note: group_hit_cnt is equivalent to item_hit_cnt
+ //Note: object_hit_cnt is equivalent to item_hit_cnt
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
- thread_id, group_hit_cnt);
+ thread_id, object_hit_cnt);
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, thread_id);
}
expr_runtime_hit_times_inc((struct expr_runtime *)expr_rt, thread_id);
- return group_hit_cnt;
+ return object_hit_cnt;
}
static size_t
-group_to_rule(struct maat *maat_inst, long long *results, size_t n_result,
+object_to_rule(struct maat *maat_inst, long long *results, size_t n_result,
struct maat_state *state)
{
int rule_table_id =
@@ -1363,9 +1363,9 @@ int maat_scan_flag(struct maat *maat_inst, int table_id,
}
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
- int hit_group_cnt = flag_scan(maat_inst->tbl_mgr, state->thread_id, flag,
+ int hit_object_cnt = flag_scan(maat_inst->tbl_mgr, state->thread_id, flag,
phy_table_id, attribute_id, state);
- if (hit_group_cnt < 0) {
+ if (hit_object_cnt < 0) {
maat_inst->stat->scan_err_cnt++;
return MAAT_SCAN_ERR;
}
@@ -1373,8 +1373,8 @@ int maat_scan_flag(struct maat *maat_inst, int table_id,
maat_runtime_ref_inc(maat_rt, state->thread_id);
size_t sum_hit_rule_cnt = 0;
- if (hit_group_cnt > 0) {
- sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ if (hit_object_cnt > 0) {
+ sum_hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
*n_hit_result = sum_hit_rule_cnt;
}
@@ -1397,7 +1397,7 @@ int maat_scan_flag(struct maat *maat_inst, int table_id,
if (sum_hit_rule_cnt > 0) {
return MAAT_SCAN_HIT;
- } else if (hit_group_cnt > 0) {
+ } else if (hit_object_cnt > 0) {
return MAAT_SCAN_HALF_HIT;
} else {
return MAAT_SCAN_OK;
@@ -1448,9 +1448,9 @@ int maat_scan_integer(struct maat *maat_inst, int table_id,
}
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
- int hit_group_cnt = interval_scan(maat_inst->tbl_mgr, state->thread_id, integer,
+ int hit_object_cnt = interval_scan(maat_inst->tbl_mgr, state->thread_id, integer,
phy_table_id, attribute_id, state);
- if (hit_group_cnt < 0) {
+ if (hit_object_cnt < 0) {
maat_inst->stat->scan_err_cnt++;
return MAAT_SCAN_ERR;
}
@@ -1458,8 +1458,8 @@ int maat_scan_integer(struct maat *maat_inst, int table_id,
maat_runtime_ref_inc(maat_rt, state->thread_id);
size_t sum_hit_rule_cnt = 0;
- if (hit_group_cnt > 0) {
- sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ if (hit_object_cnt > 0) {
+ sum_hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
*n_hit_result = sum_hit_rule_cnt;
}
@@ -1482,7 +1482,7 @@ int maat_scan_integer(struct maat *maat_inst, int table_id,
if (sum_hit_rule_cnt > 0) {
return MAAT_SCAN_HIT;
- } else if (hit_group_cnt > 0) {
+ } else if (hit_object_cnt > 0) {
return MAAT_SCAN_HALF_HIT;
} else {
return MAAT_SCAN_OK;
@@ -1532,9 +1532,9 @@ int maat_scan_ipv4_port(struct maat *maat_inst, int table_id, uint32_t ip_addr,
}
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
- int hit_group_cnt = ipv4_scan(maat_inst->tbl_mgr, state->thread_id, ip_addr, port,
+ int hit_object_cnt = ipv4_scan(maat_inst->tbl_mgr, state->thread_id, ip_addr, port,
phy_table_id, attribute_id, state);
- if (hit_group_cnt < 0) {
+ if (hit_object_cnt < 0) {
maat_inst->stat->scan_err_cnt++;
return MAAT_SCAN_ERR;
}
@@ -1542,8 +1542,8 @@ 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_rule_cnt = 0;
- if (hit_group_cnt > 0) {
- sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ if (hit_object_cnt > 0) {
+ sum_hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
*n_hit_result = sum_hit_rule_cnt;
}
@@ -1566,7 +1566,7 @@ int maat_scan_ipv4_port(struct maat *maat_inst, int table_id, uint32_t ip_addr,
if (sum_hit_rule_cnt > 0) {
return MAAT_SCAN_HIT;
- } else if (hit_group_cnt > 0) {
+ } else if (hit_object_cnt > 0) {
return MAAT_SCAN_HALF_HIT;
} else {
return MAAT_SCAN_OK;
@@ -1616,9 +1616,9 @@ int maat_scan_ipv6_port(struct maat *maat_inst, int table_id, uint8_t *ip_addr,
}
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
- int hit_group_cnt = ipv6_scan(maat_inst->tbl_mgr, state->thread_id, ip_addr, port,
+ int hit_object_cnt = ipv6_scan(maat_inst->tbl_mgr, state->thread_id, ip_addr, port,
phy_table_id, attribute_id, state);
- if (hit_group_cnt < 0) {
+ if (hit_object_cnt < 0) {
maat_inst->stat->scan_err_cnt++;
return MAAT_SCAN_ERR;
}
@@ -1626,8 +1626,8 @@ 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_rule_cnt = 0;
- if (hit_group_cnt > 0) {
- sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ if (hit_object_cnt > 0) {
+ sum_hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
*n_hit_result = sum_hit_rule_cnt;
}
@@ -1650,7 +1650,7 @@ int maat_scan_ipv6_port(struct maat *maat_inst, int table_id, uint8_t *ip_addr,
if (sum_hit_rule_cnt > 0) {
return MAAT_SCAN_HIT;
- } else if (hit_group_cnt > 0) {
+ } else if (hit_object_cnt > 0) {
return MAAT_SCAN_HALF_HIT;
} else {
return MAAT_SCAN_OK;
@@ -1719,9 +1719,9 @@ int maat_scan_string(struct maat *maat_inst, int table_id,
}
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
- int hit_group_cnt = string_scan(maat_inst->tbl_mgr, state->thread_id, data,
+ int hit_object_cnt = string_scan(maat_inst->tbl_mgr, state->thread_id, data,
data_len, phy_table_id, attribute_id, state);
- if (hit_group_cnt < 0) {
+ if (hit_object_cnt < 0) {
maat_inst->stat->scan_err_cnt++;
return MAAT_SCAN_ERR;
}
@@ -1729,8 +1729,8 @@ int maat_scan_string(struct maat *maat_inst, int table_id,
maat_runtime_ref_inc(maat_rt, state->thread_id);
size_t sum_hit_rule_cnt = 0;
- if (hit_group_cnt > 0) {
- sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ if (hit_object_cnt > 0) {
+ sum_hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
*n_hit_result = sum_hit_rule_cnt;
}
@@ -1753,21 +1753,21 @@ int maat_scan_string(struct maat *maat_inst, int table_id,
if (sum_hit_rule_cnt > 0) {
return MAAT_SCAN_HIT;
- } else if (hit_group_cnt > 0) {
+ } else if (hit_object_cnt > 0) {
return MAAT_SCAN_HALF_HIT;
} else {
return MAAT_SCAN_OK;
}
}
-static void maat_state_add_hit_group(struct maat_state *state, int table_id,
- struct maat_hit_group *groups, size_t n_group)
+static void maat_state_add_hit_object(struct maat_state *state, int table_id,
+ struct maat_hit_object *objects, size_t n_object)
{
struct maat *maat_inst = state->maat_inst;
- //clear rule_state->last_hit_group
+ //clear rule_state->last_hit_object
if (state != NULL && state->rule_state != NULL) {
- rule_state_clear_last_hit_group(state->rule_state);
+ rule_state_clear_last_hit_object(state->rule_state);
}
if (NULL == state->rule_state) {
@@ -1776,15 +1776,15 @@ static void maat_state_add_hit_group(struct maat_state *state, int table_id,
state->thread_id, 1);
}
- size_t n_hit_item = n_group;
- if (n_group >= MAX_HIT_GROUP_NUM) {
- n_hit_item = MAX_HIT_GROUP_NUM;
+ size_t n_hit_item = n_object;
+ if (n_object >= MAX_HIT_OBJECT_NUM) {
+ n_hit_item = MAX_HIT_OBJECT_NUM;
}
struct maat_item hit_items[n_hit_item];
for (size_t i = 0; i < n_hit_item; i++) {
- hit_items[i].item_id = groups[i].item_id;
- hit_items[i].group_id = groups[i].group_id;
+ hit_items[i].item_id = objects[i].item_id;
+ hit_items[i].object_id = objects[i].object_id;
}
rule_state_update(state->rule_state, maat_inst, table_id,
@@ -1793,7 +1793,7 @@ static void maat_state_add_hit_group(struct maat_state *state, int table_id,
}
static void
-maat_state_activate_hit_not_group(struct maat_state *state, int table_id)
+maat_state_activate_hit_not_object(struct maat_state *state, int table_id)
{
if (NULL == state) {
return;
@@ -1812,22 +1812,22 @@ maat_state_activate_hit_not_group(struct maat_state *state, int table_id)
return;
}
- //clear rule_state->last_hit_group
+ //clear rule_state->last_hit_object
if (state != NULL && state->rule_state != NULL) {
- rule_state_clear_last_hit_group(state->rule_state);
+ rule_state_clear_last_hit_object(state->rule_state);
}
rule_state_not_logic_update(state->rule_state, rule_rt, maat_inst,
table_id, state->Nth_scan);
}
-int maat_scan_group(struct maat *maat_inst, int table_id,
- struct maat_hit_group *groups, size_t n_group,
+int maat_scan_object(struct maat *maat_inst, int table_id,
+ struct maat_hit_object *objects, size_t n_object,
long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state)
{
if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
- (NULL == groups) || (0 == n_group) || (NULL == results) ||
+ (NULL == objects) || (0 == n_object) || (NULL == results) ||
(0 == n_result) || (NULL == n_hit_result) || (NULL == state) ||
(state->thread_id < 0)) {
return -1;
@@ -1852,15 +1852,15 @@ int maat_scan_group(struct maat *maat_inst, int table_id,
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt,
state->thread_id);
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
- state->thread_id, n_group);
+ state->thread_id, n_object);
}
}
maat_runtime_ref_inc(maat_rt, state->thread_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_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ maat_state_add_hit_object(state, table_id, objects, n_object);
+ size_t hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
*n_hit_result = hit_rule_cnt;
maat_runtime_ref_dec(maat_rt, state->thread_id);
@@ -1895,8 +1895,8 @@ int maat_scan_not_logic(struct maat *maat_inst, int table_id,
maat_runtime_ref_inc(maat_rt, state->thread_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_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ maat_state_activate_hit_not_object(state, table_id);
+ size_t hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
*n_hit_result = hit_rule_cnt;
maat_runtime_ref_dec(maat_rt, state->thread_id);
@@ -2004,22 +2004,22 @@ static int expr_stream_scan(struct maat_stream *stream, const char *data,
}
}
- int group_hit_cnt = expr_runtime_stream_scan(stream->expr_rt_stream, data,
+ int object_hit_cnt = expr_runtime_stream_scan(stream->expr_rt_stream, data,
data_len, stream->attribute_id, state);
- if (group_hit_cnt <= 0) {
- return group_hit_cnt;
+ if (object_hit_cnt <= 0) {
+ return object_hit_cnt;
}
if (virt_rt != NULL) {
- //Note: group_hit_cnt is equivalent to item_hit_cnt
+ //Note: object_hit_cnt is equivalent to item_hit_cnt
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
- stream->thread_id, group_hit_cnt);
+ stream->thread_id, object_hit_cnt);
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, stream->thread_id);
}
expr_runtime_stream_hit_times_inc(stream->expr_rt_stream, stream->thread_id);
- return group_hit_cnt;
+ return object_hit_cnt;
}
int maat_stream_scan(struct maat_stream *maat_stream, const char *data, int data_len,
@@ -2055,15 +2055,15 @@ int maat_stream_scan(struct maat_stream *maat_stream, const char *data, int data
alignment_int64_array_add(maat_inst->stat->thread_call_cnt,
maat_stream->thread_id, 1);
- int hit_group_cnt = expr_stream_scan(maat_stream, data, data_len, state);
- if (hit_group_cnt < 0) {
+ int hit_object_cnt = expr_stream_scan(maat_stream, data, data_len, state);
+ if (hit_object_cnt < 0) {
maat_inst->stat->scan_err_cnt++;
return MAAT_SCAN_ERR;
}
size_t sum_hit_rule_cnt = 0;
- if (hit_group_cnt > 0) {
- sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
+ if (hit_object_cnt > 0) {
+ sum_hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
*n_hit_result = sum_hit_rule_cnt;
}
@@ -2081,7 +2081,7 @@ int maat_stream_scan(struct maat_stream *maat_stream, const char *data, int data
if (sum_hit_rule_cnt > 0) {
return MAAT_SCAN_HIT;
- } else if (hit_group_cnt > 0) {
+ } else if (hit_object_cnt > 0) {
return MAAT_SCAN_HALF_HIT;
} else {
return MAAT_SCAN_OK;
@@ -2309,13 +2309,13 @@ int maat_state_get_hit_paths(struct maat_state *state, struct maat_hit_path *pat
return -1;
}
- int g2g_table_id = table_manager_get_group2group_table_id(maat_inst->tbl_mgr);
+ int g2g_table_id = table_manager_get_object2object_table_id(maat_inst->tbl_mgr);
void *g2g_runtime = table_manager_get_runtime(maat_inst->tbl_mgr, g2g_table_id);
size_t hit_path_cnt =
rule_state_get_internal_hit_paths(state->rule_state,
(struct rule_runtime *)rule_rt,
- (struct group2group_runtime *)g2g_runtime,
+ (struct object2object_runtime *)g2g_runtime,
path_array, array_size);
return rule_runtime_get_hit_paths((struct rule_runtime *)rule_rt,
@@ -2332,11 +2332,11 @@ size_t maat_state_get_scan_count(struct maat_state *state)
return state->Nth_scan;
}
-int maat_state_get_direct_hit_groups(struct maat_state *state,
- struct maat_hit_group *group_array,
+int maat_state_get_direct_hit_objects(struct maat_state *state,
+ struct maat_hit_object *object_array,
size_t array_size)
{
- if (NULL == state || NULL == group_array || 0 == array_size) {
+ if (NULL == state || NULL == object_array || 0 == array_size) {
return -1;
}
@@ -2344,24 +2344,24 @@ int maat_state_get_direct_hit_groups(struct maat_state *state,
return 0;
}
- return rule_state_get_direct_hit_groups(state->rule_state,
- group_array, array_size);
+ return rule_state_get_direct_hit_objects(state->rule_state,
+ object_array, array_size);
}
-size_t maat_state_get_direct_hit_group_cnt(struct maat_state *state)
+size_t maat_state_get_direct_hit_object_cnt(struct maat_state *state)
{
if (NULL == state || NULL == state->rule_state) {
return 0;
}
- return rule_state_get_direct_hit_group_cnt(state->rule_state);
+ return rule_state_get_direct_hit_object_cnt(state->rule_state);
}
-int maat_state_get_indirect_hit_groups(struct maat_state *state,
- struct maat_hit_group *group_array,
+int maat_state_get_indirect_hit_objects(struct maat_state *state,
+ struct maat_hit_object *object_array,
size_t array_size)
{
- if (NULL == state || NULL == group_array || 0 == array_size) {
+ if (NULL == state || NULL == object_array || 0 == array_size) {
return -1;
}
@@ -2369,36 +2369,36 @@ int maat_state_get_indirect_hit_groups(struct maat_state *state,
return 0;
}
- return rule_state_get_indirect_hit_groups(state->rule_state,
- group_array, array_size);
+ return rule_state_get_indirect_hit_objects(state->rule_state,
+ object_array, array_size);
}
-size_t maat_state_get_indirect_hit_group_cnt(struct maat_state *state)
+size_t maat_state_get_indirect_hit_object_cnt(struct maat_state *state)
{
if (NULL == state || NULL == state->rule_state) {
return 0;
}
- return rule_state_get_indirect_hit_group_cnt(state->rule_state);
+ return rule_state_get_indirect_hit_object_cnt(state->rule_state);
}
-int maat_state_get_last_hit_groups(struct maat_state *state,
- struct maat_hit_group *group_array,
+int maat_state_get_last_hit_objects(struct maat_state *state,
+ struct maat_hit_object *object_array,
size_t array_size)
{
if (NULL == state || NULL == state->rule_state) {
return 0;
}
- return rule_state_get_last_hit_groups(state->rule_state,
- group_array, array_size);
+ return rule_state_get_last_hit_objects(state->rule_state,
+ object_array, array_size);
}
-size_t maat_state_get_last_hit_group_cnt(struct maat_state *state)
+size_t maat_state_get_last_hit_object_cnt(struct maat_state *state)
{
if (NULL == state || NULL == state->rule_state) {
return 0;
}
- return rule_state_get_last_hit_group_cnt(state->rule_state);
+ return rule_state_get_last_hit_object_cnt(state->rule_state);
} \ No newline at end of file
diff --git a/src/maat_command.c b/src/maat_command.c
index ec6a588..8a76b49 100644
--- a/src/maat_command.c
+++ b/src/maat_command.c
@@ -158,7 +158,7 @@ redis_flushDB(redisContext *ctx, int db_index, struct log_handle *logger)
append_cmd_cnt++;
redisAppendCommand(ctx, "SET %s 1", mr_region_id_var);
append_cmd_cnt++;
- redisAppendCommand(ctx, "SET %s 1", mr_group_id_var);
+ redisAppendCommand(ctx, "SET %s 1", mr_object_id_var);
append_cmd_cnt++;
redisAppendCommand(ctx, "EXEC");
append_cmd_cnt++;
diff --git a/src/maat_expr.c b/src/maat_expr.c
index 0ad3a2c..a4d9076 100644
--- a/src/maat_expr.c
+++ b/src/maat_expr.c
@@ -21,7 +21,7 @@
#include "maat.h"
#include "maat_core.h"
#include "maat_rule.h"
-#include "maat_group.h"
+#include "maat_object.h"
#include "alignment.h"
#include "maat_garbage_collection.h"
@@ -35,7 +35,7 @@
struct expr_schema {
int item_id_column;
- int group_id_column;
+ int object_id_column;
int district_column;
int keywords_column;
int expr_type_column;
@@ -63,7 +63,7 @@ enum match_method {
struct expr_item {
long long item_id;
- long long group_id;
+ long long object_id;
char keywords[MAX_KEYWORDS_STR_LEN + 1];
enum expr_type expr_type;
void *user_data;
@@ -175,15 +175,15 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
}
expr_item->item_id = atoll(line + column_offset);
- ret = get_column_pos(line, expr_schema->group_id_column, &column_offset,
+ ret = get_column_pos(line, expr_schema->object_id_column, &column_offset,
&column_len);
if (ret < 0) {
log_fatal(expr_rt->logger, MODULE_EXPR,
- "[%s:%d] expr table:<%s> has no group_id in line:%s",
+ "[%s:%d] expr table:<%s> has no object_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
}
- expr_item->group_id = atoll(line + column_offset);
+ expr_item->object_id = atoll(line + column_offset);
ret = get_column_pos(line, expr_schema->keywords_column, &column_offset, &column_len);
if (ret < 0) {
@@ -311,12 +311,12 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
goto error;
}
- custom_item = cJSON_GetObjectItem(item, "group_id");
+ custom_item = cJSON_GetObjectItem(item, "object_id");
if (custom_item != NULL && custom_item->type == cJSON_Number) {
- expr_schema->group_id_column = custom_item->valueint;
+ expr_schema->object_id_column = custom_item->valueint;
} else {
log_fatal(logger, MODULE_EXPR,
- "[%s:%d] expr table:<%s> schema has no group_id column",
+ "[%s:%d] expr table:<%s> schema has no object_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
}
@@ -953,9 +953,9 @@ int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id,
const char *data, size_t data_len,
int attribute_id, struct maat_state *state)
{
- //clear rule_state->last_hit_group
+ //clear rule_state->last_hit_object
if (state != NULL && state->rule_state != NULL) {
- rule_state_clear_last_hit_group(state->rule_state);
+ rule_state_clear_last_hit_object(state->rule_state);
}
if (0 == expr_rt->rule_num) {
@@ -1002,7 +1002,7 @@ int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id,
}
hit_maat_items[real_hit_item_num].item_id = item_id;
- hit_maat_items[real_hit_item_num].group_id = expr_item->group_id;
+ hit_maat_items[real_hit_item_num].object_id = expr_item->object_id;
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 rule_state->last_hit_group
+ //clear rule_state->last_hit_object
if (state != NULL && state->rule_state != NULL) {
- rule_state_clear_last_hit_group(state->rule_state);
+ rule_state_clear_last_hit_object(state->rule_state);
}
if (0 == expr_rt->rule_num) {
@@ -1097,7 +1097,7 @@ int expr_runtime_stream_scan(struct expr_runtime_stream *expr_rt_stream,
}
hit_maat_items[real_hit_item_cnt].item_id = item_id;
- hit_maat_items[real_hit_item_cnt].group_id = expr_item->group_id;
+ hit_maat_items[real_hit_item_cnt].object_id = expr_item->object_id;
real_hit_item_cnt++;
}
diff --git a/src/maat_flag.c b/src/maat_flag.c
index 75ef69d..ed73dab 100644
--- a/src/maat_flag.c
+++ b/src/maat_flag.c
@@ -26,7 +26,7 @@
struct flag_schema {
int item_id_column;
- int group_id_column;
+ int object_id_column;
int district_column;
int flag_column;
int flag_mask_column;
@@ -36,7 +36,7 @@ struct flag_schema {
struct flag_item {
long long item_id;
- long long group_id;
+ long long object_id;
long long flag;
long long flag_mask;
void *user_data;
@@ -104,12 +104,12 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
goto error;
}
- custom_item = cJSON_GetObjectItem(item, "group_id");
+ custom_item = cJSON_GetObjectItem(item, "object_id");
if (custom_item != NULL && custom_item->type == cJSON_Number) {
- schema->group_id_column = custom_item->valueint;
+ schema->object_id_column = custom_item->valueint;
} else {
log_fatal(logger, MODULE_FLAG,
- "[%s:%d] flag table:<%s> schema has no group_id column",
+ "[%s:%d] flag table:<%s> schema has no object_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
}
@@ -326,15 +326,15 @@ flag_item_new(struct flag_schema *schema, const char *table_name,
}
item->item_id = atoll(line + column_offset);
- ret = get_column_pos(line, schema->group_id_column, &column_offset,
+ ret = get_column_pos(line, schema->object_id_column, &column_offset,
&column_len);
if (ret < 0) {
log_fatal(flag_rt->logger, MODULE_FLAG,
- "[%s:%d] flag table:<%s> has no group_id in line:%s",
+ "[%s:%d] flag table:<%s> has no object_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
}
- item->group_id = atoll(line + column_offset);
+ item->object_id = atoll(line + column_offset);
table_type = table_manager_get_table_type(schema->ref_tbl_mgr, schema->table_id);
if (table_type == TABLE_TYPE_INTERVAL_PLUS) {
@@ -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 attribute_id, struct maat_state *state)
{
- //clear rule_state->last_hit_group
+ //clear rule_state->last_hit_object
if (state != NULL && state->rule_state != NULL) {
- rule_state_clear_last_hit_group(state->rule_state);
+ rule_state_clear_last_hit_object(state->rule_state);
}
if (0 == flag_rt->rule_num) {
@@ -598,7 +598,7 @@ int flag_runtime_scan(struct flag_runtime *flag_rt, int thread_id,
}
hit_maat_items[real_hit_item_cnt].item_id = item_id;
- hit_maat_items[real_hit_item_cnt].group_id = flag_item->group_id;
+ hit_maat_items[real_hit_item_cnt].object_id = flag_item->object_id;
real_hit_item_cnt++;
}
}
diff --git a/src/maat_group.c b/src/maat_group.c
deleted file mode 100644
index 10b02c8..0000000
--- a/src/maat_group.c
+++ /dev/null
@@ -1,1252 +0,0 @@
-/*
-**********************************************************************************************
-* File: maat_group.c
-* Description:
-* Authors: Liu wentan <[email protected]>
-* Date: 2022-10-31
-* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved.
-***********************************************************************************************
-*/
-
-#include <assert.h>
-#include <pthread.h>
-
-#include "log/log.h"
-#include "maat_group.h"
-#include "maat_utils.h"
-#include "maat_limits.h"
-#include "uthash/uthash.h"
-#include "uthash/utarray.h"
-#include "igraph/igraph.h"
-#include "maat_kv.h"
-
-#define MODULE_GROUP module_name_str("maat.group")
-
-struct group2group_item {
- long long group_id;
- UT_array *incl_sub_group_ids;
- UT_array *excl_sub_group_ids;
-};
-
-struct group2group_schema {
- int group_id_column;
- int incl_sub_group_ids_column;
- int excl_sub_group_ids_column;
- int table_id;
- struct table_manager *ref_tbl_mgr;
-};
-
-struct maat_group {
- igraph_integer_t vertex_id;
- long long group_id;
-
- int ref_by_super_group_cnt;
- int ref_by_sub_group_cnt;
-
- UT_array *incl_super_group_ids;
- UT_array *excl_super_group_ids;
- UT_array *incl_sub_group_ids;
- UT_array *excl_sub_group_ids;
-
- UT_hash_handle hh_group_id;
- UT_hash_handle hh_vertex_id;
-};
-
-struct maat_group_topology {
- struct maat_group *hash_by_group_id; //key: group_id, value: struct maat_group *.
- struct maat_group *hash_by_vertex_id; //key: vetex_id, value: struct maat_group *.
- igraph_t group_graph;
- igraph_integer_t grp_vertex_id_generator;
- struct log_handle *logger;
-};
-
-struct group2group_runtime {
- struct maat_group_topology *group_topo;
- struct maat_group_topology *updating_group_topo;
- long long rule_num;
- long long excl_rule_num; //exclude g2g rule num
- long long update_err_cnt;
- int updating_flag;
-
- struct maat_garbage_bin *ref_garbage_bin;
- struct log_handle *logger;
-};
-
-UT_icd ut_group_id_icd = {sizeof(long long), NULL, NULL, NULL};
-
-static inline int compare_group_id(const void *a, const void *b)
-{
- long long ret = *(const long long *)a - *(const long long *)b;
-
- if (0 == ret) {
- return 0;
- } else if(ret < 0) {
- return -1;
- } else {
- return 1;
- }
-}
-
-void *group2group_schema_new(cJSON *json, struct table_manager *tbl_mgr,
- const char *table_name, struct log_handle *logger)
-{
- struct group2group_schema *g2g_schema = ALLOC(struct group2group_schema, 1);
-
- cJSON *custom_item = NULL;
- cJSON *item = cJSON_GetObjectItem(json, "table_id");
- if (item != NULL && item->type == cJSON_Number) {
- g2g_schema->table_id = item->valueint;
- } else {
- log_fatal(logger, MODULE_GROUP,
- "[%s:%d] g2g table:<%s> schema has no 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_GROUP,
- "[%s:%d] g2g table:<%s> schema has no custom column",
- __FUNCTION__, __LINE__, table_name);
- goto error;
- }
-
- custom_item = cJSON_GetObjectItem(item, "group_id");
- if (custom_item != NULL && custom_item->type == cJSON_Number) {
- g2g_schema->group_id_column = custom_item->valueint;
- } else {
- log_fatal(logger, MODULE_GROUP,
- "[%s:%d] g2g table:<%s> schema has no group_id column",
- __FUNCTION__, __LINE__, table_name);
- goto error;
- }
-
- custom_item = cJSON_GetObjectItem(item, "included_sub_group_ids");
- if (custom_item != NULL && custom_item->type == cJSON_Number) {
- g2g_schema->incl_sub_group_ids_column = custom_item->valueint;
- } else {
- log_fatal(logger, MODULE_GROUP,
- "[%s:%d] g2g table:<%s> schema has no included_sub_group_ids column",
- __FUNCTION__, __LINE__, table_name);
- goto error;
- }
-
- custom_item = cJSON_GetObjectItem(item, "excluded_sub_group_ids");
- if (custom_item != NULL && custom_item->type == cJSON_Number) {
- g2g_schema->excl_sub_group_ids_column = custom_item->valueint;
- } else {
- log_fatal(logger, MODULE_GROUP,
- "[%s:%d] g2g table:<%s> schema has no excluded_sub_group_ids column",
- __FUNCTION__, __LINE__, table_name);
- goto error;
- }
-
- g2g_schema->ref_tbl_mgr = tbl_mgr;
- return g2g_schema;
-error:
- FREE(g2g_schema);
- return NULL;
-}
-
-void group2group_schema_free(void *g2g_schema)
-{
- FREE(g2g_schema);
-}
-
-static void group_vertex_free(struct maat_group *group)
-{
- if (NULL == group) {
- return;
- }
-
- if (group->incl_super_group_ids != NULL) {
- utarray_free(group->incl_super_group_ids);
- group->incl_super_group_ids = NULL;
- }
-
- if (group->excl_super_group_ids != NULL) {
- utarray_free(group->excl_super_group_ids);
- group->excl_super_group_ids = NULL;
- }
-
- if (group->incl_sub_group_ids != NULL) {
- utarray_free(group->incl_sub_group_ids);
- group->incl_sub_group_ids = NULL;
- }
-
- if (group->excl_sub_group_ids != NULL) {
- utarray_free(group->excl_sub_group_ids);
- group->excl_sub_group_ids = NULL;
- }
-
- FREE(group);
-}
-
-static struct maat_group_topology *
-maat_group_topology_new(struct log_handle *logger)
-{
- struct maat_group_topology *group_topo = ALLOC(struct maat_group_topology, 1);
- UNUSED int ret = 0;
-
- group_topo->hash_by_group_id = NULL;
- group_topo->hash_by_vertex_id = NULL;
-
- ret = igraph_empty(&(group_topo->group_graph), 0, IGRAPH_DIRECTED);
- assert(ret == IGRAPH_SUCCESS);
-
- group_topo->logger = logger;
-
- return group_topo;
-}
-
-static void maat_group_topology_free(struct maat_group_topology *group_topo)
-{
- if (NULL == group_topo) {
- return;
- }
-
- struct maat_group *group = NULL, *tmp_group = NULL;
-
- HASH_CLEAR(hh_vertex_id, group_topo->hash_by_vertex_id);//No need group memory clean up.
- HASH_ITER(hh_group_id, group_topo->hash_by_group_id, group, tmp_group) {
- HASH_DELETE(hh_group_id, group_topo->hash_by_group_id, group);
- group_vertex_free(group);
- }
- assert(group_topo->hash_by_group_id == NULL);
-
- igraph_destroy(&group_topo->group_graph);
- FREE(group_topo);
-}
-
-static struct maat_group *maat_group_clone(struct maat_group *group)
-{
- struct maat_group *group_copy = ALLOC(struct maat_group, 1);
-
- group_copy->group_id = group->group_id;
- group_copy->vertex_id = group->vertex_id;
- group_copy->ref_by_sub_group_cnt = group->ref_by_sub_group_cnt;
- group_copy->ref_by_super_group_cnt = group->ref_by_super_group_cnt;
- utarray_new(group_copy->incl_super_group_ids, &ut_group_id_icd);
- utarray_new(group_copy->excl_super_group_ids, &ut_group_id_icd);
- utarray_new(group_copy->incl_sub_group_ids, &ut_group_id_icd);
- utarray_new(group_copy->excl_sub_group_ids, &ut_group_id_icd);
-
- long long *p = NULL;
- for (p = (long long *)utarray_front(group->incl_super_group_ids); p != NULL;
- p = (long long *)utarray_next(group->incl_super_group_ids, p)) {
- utarray_push_back(group_copy->incl_super_group_ids, p);
- }
-
- for (p = (long long *)utarray_front(group->excl_super_group_ids); p != NULL;
- p = (long long *)utarray_next(group->excl_super_group_ids, p)) {
- utarray_push_back(group_copy->excl_super_group_ids, p);
- }
-
- for (p = (long long *)utarray_front(group->incl_sub_group_ids); p != NULL;
- p = (long long *)utarray_next(group->incl_sub_group_ids, p)) {
- utarray_push_back(group_copy->incl_sub_group_ids, p);
- }
-
- for (p = (long long *)utarray_front(group->excl_sub_group_ids); p != NULL;
- p = (long long *)utarray_next(group->excl_sub_group_ids, p)) {
- utarray_push_back(group_copy->excl_sub_group_ids, p);
- }
-
- return group_copy;
-}
-
-static struct maat_group_topology *
-maat_group_topology_clone(struct maat_group_topology *group_topo)
-{
- if (NULL == group_topo) {
- return NULL;
- }
-
- struct maat_group_topology *group_topo_copy = ALLOC(struct maat_group_topology, 1);
-
- struct maat_group *group = NULL, *tmp_group = NULL;
- HASH_ITER(hh_group_id, group_topo->hash_by_group_id, group, tmp_group) {
- struct maat_group *group_copy = maat_group_clone(group);
-
- HASH_ADD(hh_group_id, group_topo_copy->hash_by_group_id, group_id,
- sizeof(group_copy->group_id), group_copy);
- HASH_ADD(hh_vertex_id, group_topo_copy->hash_by_vertex_id, vertex_id,
- sizeof(group_copy->vertex_id), group_copy);
- }
-
- igraph_copy(&(group_topo_copy->group_graph), &(group_topo->group_graph));
- group_topo_copy->grp_vertex_id_generator = group_topo->grp_vertex_id_generator;
- group_topo_copy->logger = group_topo->logger;
-
- return group_topo_copy;
-}
-
-void *group2group_runtime_new(void *g2g_schema, size_t max_thread_num,
- struct maat_garbage_bin *garbage_bin,
- struct log_handle *logger)
-{
- if (NULL == g2g_schema) {
- return NULL;
- }
-
- struct group2group_runtime *g2g_rt = ALLOC(struct group2group_runtime, 1);
-
- g2g_rt->group_topo = maat_group_topology_new(logger);
- g2g_rt->ref_garbage_bin = garbage_bin;
- g2g_rt->logger = logger;
-
- return g2g_rt;
-}
-
-void group2group_runtime_free(void *g2g_runtime)
-{
- if (NULL == g2g_runtime) {
- return;
- }
-
- struct group2group_runtime *g2g_rt = (struct group2group_runtime *)g2g_runtime;
-
- if (g2g_rt->group_topo != NULL) {
- maat_group_topology_free(g2g_rt->group_topo);
- g2g_rt->group_topo = NULL;
- }
-
- if (g2g_rt->updating_group_topo != NULL) {
- maat_group_topology_free(g2g_rt->updating_group_topo);
- g2g_rt->updating_group_topo = NULL;
- }
-
- FREE(g2g_rt);
-}
-
-static struct group2group_item *
-group2group_item_new(const char *line, struct group2group_schema *g2g_schema,
- const char *table_name, struct log_handle *logger)
-{
- size_t column_offset = 0;
- size_t column_len = 0;
- struct group2group_item *g2g_item = ALLOC(struct group2group_item, 1);
- utarray_new(g2g_item->incl_sub_group_ids, &ut_group_id_icd);
- utarray_new(g2g_item->excl_sub_group_ids, &ut_group_id_icd);
-
- int ret = get_column_pos(line, g2g_schema->group_id_column,
- &column_offset, &column_len);
- if (ret < 0) {
- log_fatal(logger, MODULE_GROUP,
- "[%s:%d] g2 table:<%s> has no group_id in line:%s",
- __FUNCTION__, __LINE__, table_name, line);
- goto error;
- }
- g2g_item->group_id = atoll(line + column_offset);
-
- ret = get_column_pos(line, g2g_schema->incl_sub_group_ids_column,
- &column_offset, &column_len);
- if (ret < 0) {
- log_fatal(logger, MODULE_GROUP,
- "[%s:%d] g2g table:<%s> has no included_sub_group_ids in line:%s",
- __FUNCTION__, __LINE__, table_name, line);
- goto error;
- }
-
- char group_ids_str[MAX_GROUP_IDS_STR_LEN] = {0};
- memcpy(group_ids_str, line + column_offset, MIN(MAX_GROUP_IDS_STR_LEN, column_len));
-
- ret = ids_str2longlong_array(group_ids_str, g2g_item->incl_sub_group_ids);
- if (ret < 0) {
- log_fatal(logger, MODULE_GROUP,
- "[%s:%d] g2c table:<%s> included_sub_group_ids str2longlong failed in line:%s",
- __FUNCTION__, __LINE__, table_name, line);
- goto error;
- }
-
- if (utarray_len(g2g_item->incl_sub_group_ids) > MAX_GROUP_CNT) {
- log_fatal(logger, MODULE_GROUP,
- "[%s:%d] g2c table:<%s> included_sub_group_ids exceed maximum:%d in line:%s",
- __FUNCTION__, __LINE__, table_name, MAX_GROUP_CNT, line);
- goto error;
- }
-
- ret = get_column_pos(line, g2g_schema->excl_sub_group_ids_column,
- &column_offset, &column_len);
- if (ret < 0) {
- log_fatal(logger, MODULE_GROUP,
- "[%s:%d] g2g table:<%s> has no excluded_sub_group_ids in line:%s",
- __FUNCTION__, __LINE__, table_name, line);
- goto error;
- }
-
- memset(group_ids_str, 0, sizeof(group_ids_str));
- memcpy(group_ids_str, line + column_offset, MIN(MAX_GROUP_IDS_STR_LEN, column_len));
-
- ret = ids_str2longlong_array(group_ids_str, g2g_item->excl_sub_group_ids);
- if (ret < 0) {
- log_fatal(logger, MODULE_GROUP,
- "[%s:%d] g2c table:<%s> excluded_sub_group_ids str2longlong failed in line:%s",
- __FUNCTION__, __LINE__, table_name, line);
- goto error;
- }
-
- if (utarray_len(g2g_item->excl_sub_group_ids) > MAX_GROUP_CNT) {
- log_fatal(logger, MODULE_GROUP,
- "[%s:%d] g2c table:<%s> excluded_sub_group_ids exceed maximum:%d in line:%s",
- __FUNCTION__, __LINE__, table_name, MAX_GROUP_CNT, line);
- goto error;
- }
-
- return g2g_item;
-error:
- FREE(g2g_item);
- return NULL;
-}
-
-static void group2group_item_free(struct group2group_item *g2g_item)
-{
- if (NULL == g2g_item) {
- return;
- }
-
- if (g2g_item->incl_sub_group_ids != NULL) {
- utarray_free(g2g_item->incl_sub_group_ids);
- g2g_item->incl_sub_group_ids = NULL;
- }
-
- if (g2g_item->excl_sub_group_ids != NULL) {
- utarray_free(g2g_item->excl_sub_group_ids);
- g2g_item->excl_sub_group_ids = NULL;
- }
-
- FREE(g2g_item);
-}
-
-static size_t print_igraph_vector(igraph_vector_t *v, char *buff, size_t sz) {
- long int i;
- int printed = 0;
-
- for (i = 0; i < igraph_vector_size(v); i++) {
- printed += snprintf(buff + printed, sz - printed, " %li",
- (long int) VECTOR(*v)[i]);
- }
-
- return printed;
-}
-
-static struct maat_group *
-group_topology_add_group(struct maat_group_topology *group_topo, long long group_id)
-{
- assert(group_topo != NULL);
-
- struct maat_group *group = ALLOC(struct maat_group, 1);
- group->group_id = group_id;
- group->vertex_id = group_topo->grp_vertex_id_generator++;
- utarray_new(group->incl_super_group_ids, &ut_group_id_icd);
- utarray_new(group->excl_super_group_ids, &ut_group_id_icd);
- utarray_new(group->incl_sub_group_ids, &ut_group_id_icd);
- utarray_new(group->excl_sub_group_ids, &ut_group_id_icd);
-
- assert(igraph_vcount(&group_topo->group_graph)==group->vertex_id);
- igraph_add_vertices(&group_topo->group_graph, 1, NULL); //Add 1 vertice.
-
- HASH_ADD(hh_group_id, group_topo->hash_by_group_id, group_id,
- sizeof(group->group_id), group);
- HASH_ADD(hh_vertex_id, group_topo->hash_by_vertex_id, vertex_id,
- sizeof(group->vertex_id), group);
-
- return group;
-}
-
-static void group_topology_del_group(struct maat_group_topology *group_topo,
- struct maat_group *group)
-{
- if (NULL == group_topo || NULL == group) {
- return;
- }
-
- igraph_vector_t v;
- char buff[4096] = {0};
-
- assert(group->ref_by_super_group_cnt == 0);
-
- igraph_vector_init(&v, 8);
- igraph_neighbors(&group_topo->group_graph, &v, group->vertex_id, IGRAPH_ALL);
- if (igraph_vector_size(&v) > 0) {
- print_igraph_vector(&v, buff, sizeof(buff));
- log_fatal(group_topo->logger, MODULE_GROUP,
- "[%s:%d] Del group %d exception, still reached by %s.",
- __FUNCTION__, __LINE__, group->vertex_id, buff);
- assert(0);
- }
- igraph_vector_destroy(&v);
-
- //We should not call igraph_delete_vertices, because this is function changes the ids of the vertices.
-
- HASH_DELETE(hh_group_id, group_topo->hash_by_group_id, group);
- HASH_DELETE(hh_vertex_id, group_topo->hash_by_vertex_id, group);
- group_vertex_free(group);
-}
-
-static struct maat_group *
-group_topology_find_group(struct maat_group_topology *group_topo, long long group_id)
-{
- if (NULL == group_topo || group_id < 0) {
- return NULL;
- }
-
- struct maat_group *group = NULL;
- HASH_FIND(hh_group_id, group_topo->hash_by_group_id, &group_id, sizeof(group_id), group);
-
- return group;
-}
-
-static void maat_group_reference_super_group(struct maat_group *group,
- long long super_group_id,
- int is_exclude)
-{
- if (NULL == group || super_group_id < 0) {
- return;
- }
-
- if (0 == is_exclude) {
- //include superior group
- if (!utarray_find(group->incl_super_group_ids, &super_group_id,
- compare_group_id)) {
- utarray_push_back(group->incl_super_group_ids, &super_group_id);
- utarray_sort(group->incl_super_group_ids, compare_group_id);
- }
- } else {
- //exclude superior group
- if (!utarray_find(group->excl_super_group_ids, &super_group_id,
- compare_group_id)) {
- utarray_push_back(group->excl_super_group_ids, &super_group_id);
- utarray_sort(group->excl_super_group_ids, compare_group_id);
- }
- }
-}
-
-static void maat_group_reference_sub_group(struct maat_group *group,
- long long sub_group_id,
- int is_exclude)
-{
- if (NULL == group || sub_group_id < 0) {
- return;
- }
-
- if (0 == is_exclude) {
- //include sub group
- if (!utarray_find(group->incl_sub_group_ids, &sub_group_id,
- compare_group_id)) {
- utarray_push_back(group->incl_sub_group_ids, &sub_group_id);
- utarray_sort(group->incl_sub_group_ids, compare_group_id);
- }
- } else {
- //exclude sub group
- if (!utarray_find(group->excl_sub_group_ids, &sub_group_id,
- compare_group_id)) {
- utarray_push_back(group->excl_sub_group_ids, &sub_group_id);
- utarray_sort(group->excl_sub_group_ids, compare_group_id);
- }
- }
-}
-
-static void maat_group_dereference_super_group(struct maat_group *group,
- long long super_group_id,
- int is_exclude)
-{
- if (NULL == group || super_group_id < 0) {
- return;
- }
-
- size_t remove_idx = 0;
- long long *tmp_id = NULL;
- if (0 == is_exclude) {
- //include superior group
- tmp_id = utarray_find(group->incl_super_group_ids, &super_group_id,
- compare_group_id);
- if (tmp_id != NULL) {
- remove_idx = utarray_eltidx(group->incl_super_group_ids, tmp_id);
- utarray_erase(group->incl_super_group_ids, remove_idx, 1);
- }
- } else {
- //exclude superior group
- tmp_id = utarray_find(group->excl_super_group_ids, &super_group_id,
- compare_group_id);
- if (tmp_id != NULL) {
- remove_idx = utarray_eltidx(group->excl_super_group_ids, tmp_id);
- utarray_erase(group->excl_super_group_ids, remove_idx, 1);
- }
- }
-}
-
-static void maat_group_dereference_sub_group(struct maat_group *group,
- long long sub_group_id,
- int is_exclude)
-{
- if (NULL == group || sub_group_id < 0) {
- return;
- }
-
- size_t remove_idx = 0;
- long long *tmp_id = NULL;
- if (0 == is_exclude) {
- //include superior group
- tmp_id = utarray_find(group->incl_sub_group_ids, &sub_group_id,
- compare_group_id);
- if (tmp_id != NULL) {
- remove_idx = utarray_eltidx(group->incl_sub_group_ids, tmp_id);
- utarray_erase(group->incl_sub_group_ids, remove_idx, 1);
- }
- } else {
- //exclude superior group
- tmp_id = utarray_find(group->excl_sub_group_ids, &sub_group_id,
- compare_group_id);
- if (tmp_id != NULL) {
- remove_idx = utarray_eltidx(group->excl_sub_group_ids, tmp_id);
- utarray_erase(group->excl_sub_group_ids, remove_idx, 1);
- }
- }
-}
-
-static int group_topology_add_group_to_group(struct maat_group_topology *group_topo,
- long long group_id, long long sub_group_id,
- int is_exclude)
-{
- if (NULL == group_topo) {
- return -1;
- }
-
- struct maat_group *sub_group = group_topology_find_group(group_topo, sub_group_id);
- if (NULL == sub_group) {
- sub_group = group_topology_add_group(group_topo, sub_group_id);
- }
-
- struct maat_group *group = group_topology_find_group(group_topo, group_id);
- if (NULL == group) {
- group = group_topology_add_group(group_topo, group_id);
- }
-
- maat_group_reference_super_group(sub_group, group_id, is_exclude);
- maat_group_reference_sub_group(group, sub_group_id, is_exclude);
-
- igraph_integer_t edge_id;
- int ret = igraph_get_eid(&group_topo->group_graph, &edge_id, sub_group->vertex_id,
- group->vertex_id, IGRAPH_DIRECTED, /*error*/ 0);
-
- //No duplicated edges between two groups.
- if (edge_id > 0) {
- log_fatal(group_topo->logger, MODULE_GROUP,
- "[%s:%d] Add group %d to group %d failed, relation already existed.",
- __FUNCTION__, __LINE__, sub_group->group_id, group->group_id);
- ret = -1;
- } else {
- igraph_add_edge(&group_topo->group_graph, sub_group->vertex_id,
- group->vertex_id);
- sub_group->ref_by_super_group_cnt++;
- group->ref_by_sub_group_cnt++;
- ret = 0;
- }
-
- igraph_bool_t is_dag;
- igraph_is_dag(&(group_topo->group_graph), &is_dag);
- if (!is_dag) {
- log_fatal(group_topo->logger, MODULE_GROUP,
- "[%s:%d] Sub group cycle detected, sub_group_id:%lld, group_id:%lld!",
- __FUNCTION__, __LINE__, sub_group_id, group_id);
- return -1;
- }
-
- return ret;
-}
-
-static int group_topology_del_group_from_group(struct maat_group_topology *group_topo,
- long long group_id, long long sub_group_id,
- int is_exclude)
-{
- if (NULL == group_topo) {
- return -1;
- }
-
- //No hash write operation, LOCK protection is unnecessary.
- struct maat_group *sub_group = group_topology_find_group(group_topo, sub_group_id);
- if (NULL == sub_group) {
- log_fatal(group_topo->logger, MODULE_GROUP,
- "[%s:%d] Del group %d from group %d failed, group %d not existed.",
- __FUNCTION__, __LINE__, sub_group_id, group_id, sub_group_id);
- return -1;
- }
-
- struct maat_group *group = group_topology_find_group(group_topo, group_id);
- if (NULL == group) {
- log_fatal(group_topo->logger, MODULE_GROUP,
- "[%s:%d] Del group %d from group %d failed, group %d not existed.",
- __FUNCTION__, __LINE__, sub_group_id, group_id, group_id);
- return -1;
- }
-
- maat_group_dereference_super_group(sub_group, group_id, is_exclude);
- maat_group_dereference_sub_group(group, sub_group_id, is_exclude);
-
- igraph_es_t es;
- igraph_integer_t edge_num_before = 0, edge_num_after = 0;
-
- edge_num_before = igraph_ecount(&group_topo->group_graph);
- // The edges between the given pairs of vertices will be included in the edge selection.
- //The vertex pairs must be given as the arguments of the function call, the third argument
- //is the first vertex of the first edge, the fourth argument is the second vertex of the
- //first edge, the fifth is the first vertex of the second edge and so on. The last element
- //of the argument list must be -1 to denote the end of the argument list.
- //https://igraph.org/c/doc/igraph-Iterators.html#igraph_es_pairs_small
- int ret = igraph_es_pairs_small(&es, IGRAPH_DIRECTED, sub_group->vertex_id,
- group->vertex_id, -1);
- assert(ret==IGRAPH_SUCCESS);
- // ignore no such edge to abort().
- igraph_set_error_handler(igraph_error_handler_ignore);
- ret = igraph_delete_edges(&group_topo->group_graph, es);
- edge_num_after = igraph_ecount(&group_topo->group_graph);
- igraph_es_destroy(&es);
-
- if (ret != IGRAPH_SUCCESS || edge_num_before - edge_num_after != 1) {
- assert(0);
- return -1;
- }
-
- sub_group->ref_by_super_group_cnt--;
- group->ref_by_sub_group_cnt--;
-
- return 0;
-}
-
-static int group_topology_build_super_groups(struct maat_group_topology *group_topo)
-{
- if (NULL == group_topo) {
- return -1;
- }
-
- igraph_bool_t is_dag;
- igraph_is_dag(&(group_topo->group_graph), &is_dag);
- if (!is_dag) {
- log_fatal(group_topo->logger, MODULE_GROUP,
- "[%s:%d] Sub group cycle detected!", __FUNCTION__, __LINE__);
- return -1;
- }
-
- struct maat_group *group = NULL, *tmp_group = NULL;
- HASH_ITER (hh_group_id, group_topo->hash_by_group_id, group, tmp_group) {
- //Orphan, Not reference by any one, free it.
- if (0 == group->ref_by_super_group_cnt
- && 0 == group->ref_by_sub_group_cnt) {
- group_topology_del_group(group_topo, group);
- continue;
- }
- }
-
- return 0;
-}
-
-int group2group_runtime_update(void *g2g_runtime, void *g2g_schema,
- const char *table_name, const char *line,
- int valid_column)
-{
- if (NULL == g2g_runtime || NULL == g2g_schema ||
- NULL == line) {
- return -1;
- }
-
- struct group2group_schema *schema = (struct group2group_schema *)g2g_schema;
- struct group2group_runtime *g2g_rt = (struct group2group_runtime *)g2g_runtime;
- int is_valid = get_column_value(line, valid_column);
- if (is_valid < 0) {
- log_fatal(g2g_rt->logger, MODULE_GROUP,
- "[%s:%d] g2g table:<%s> has no is_valid(column seq:%d)"
- " in table_line:%s", __FUNCTION__, __LINE__, table_name,
- valid_column, line);
- g2g_rt->update_err_cnt++;
- return -1;
- }
-
- struct group2group_item *g2g_item = group2group_item_new(line, schema, table_name,
- g2g_rt->logger);
- if (NULL == g2g_item) {
- g2g_rt->update_err_cnt++;
- return -1;
- }
-
- if (0 == g2g_rt->updating_flag) {
- assert(g2g_rt->updating_group_topo == NULL);
- g2g_rt->updating_group_topo = maat_group_topology_clone(g2g_rt->group_topo);
- g2g_rt->updating_flag = 1;
- }
-
- int ret = 0;
- size_t i = 0;
- int err_flag = 0;
- long long *sub_group_id = NULL;
- if (0 == is_valid) {
- //delete
- for (i = 0; i < utarray_len(g2g_item->incl_sub_group_ids); i++) {
- sub_group_id = (long long *)utarray_eltptr(g2g_item->incl_sub_group_ids, i);
- ret = group_topology_del_group_from_group(g2g_rt->updating_group_topo,
- g2g_item->group_id, *sub_group_id, 0);
- if (ret != 0) {
- err_flag = 1;
- }
- }
-
- for (i = 0; i < utarray_len(g2g_item->excl_sub_group_ids); i++) {
- sub_group_id = (long long *)utarray_eltptr(g2g_item->excl_sub_group_ids, i);
- ret = group_topology_del_group_from_group(g2g_rt->updating_group_topo,
- g2g_item->group_id, *sub_group_id, 1);
- if (ret != 0) {
- err_flag = 1;
- }
- }
-
- if (1 == err_flag) {
- g2g_rt->update_err_cnt++;
- } else {
- if (utarray_len(g2g_item->excl_sub_group_ids) > 0) {
- g2g_rt->excl_rule_num--;
- }
- g2g_rt->rule_num--;
- }
- } else {
- //add
- for (i = 0; i < utarray_len(g2g_item->incl_sub_group_ids); i++) {
- sub_group_id = (long long *)utarray_eltptr(g2g_item->incl_sub_group_ids, i);
- ret = group_topology_add_group_to_group(g2g_rt->updating_group_topo,
- g2g_item->group_id, *sub_group_id, 0);
- if (ret != 0) {
- err_flag = 1;
- }
- }
-
- for (i = 0; i < utarray_len(g2g_item->excl_sub_group_ids); i++) {
- sub_group_id = (long long *)utarray_eltptr(g2g_item->excl_sub_group_ids, i);
- ret = group_topology_add_group_to_group(g2g_rt->updating_group_topo,
- g2g_item->group_id, *sub_group_id, 1);
- if (ret != 0) {
- err_flag = 1;
- }
- }
-
- if (1 == err_flag) {
- g2g_rt->update_err_cnt++;
- } else {
- if (utarray_len(g2g_item->excl_sub_group_ids) > 0) {
- g2g_rt->excl_rule_num++;
- }
- g2g_rt->rule_num++;
- }
- }
- group2group_item_free(g2g_item);
-
- return ret;
-}
-
-static void garbage_maat_group_topology_free(void *data, void *arg)
-{
- struct maat_group_topology *group_topo = (struct maat_group_topology *)data;
- maat_group_topology_free(group_topo);
-}
-
-int group2group_runtime_commit(void *g2g_runtime, const char *table_name,
- long long maat_rt_version)
-{
- if (NULL == g2g_runtime) {
- return -1;
- }
-
- struct group2group_runtime *g2g_rt = (struct group2group_runtime *)g2g_runtime;
- if (0 == g2g_rt->updating_flag) {
- return 0;
- }
-
- struct timespec start, end;
- clock_gettime(CLOCK_MONOTONIC, &start);
- int ret = group_topology_build_super_groups(g2g_rt->updating_group_topo);
- 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 (ret < 0) {
- log_fatal(g2g_rt->logger, MODULE_GROUP,
- "[%s:%d] table[%s] group2group runtime commit failed",
- __FUNCTION__, __LINE__, table_name);
- return -1;
- }
-
- struct maat_group_topology *old_group_topo = g2g_rt->group_topo;
- g2g_rt->group_topo = g2g_rt->updating_group_topo;
- g2g_rt->updating_group_topo = NULL;
- g2g_rt->updating_flag = 0;
-
- maat_garbage_bagging(g2g_rt->ref_garbage_bin, old_group_topo, NULL,
- garbage_maat_group_topology_free);
-
- log_info(g2g_rt->logger, MODULE_GROUP,
- "table[%s] commit %zu g2g rules and rebuild super_groups completed,"
- " version:%lld, consume:%lldms", table_name, g2g_rt->rule_num,
- maat_rt_version, time_elapse_ms);
-
- return 0;
-}
-
-#define MAX_RECURSION_DEPTH 5
-static void get_candidate_super_group_ids(struct maat_group_topology *group_topo,
- UT_array *hit_group_ids,
- UT_array *super_group_ids)
-{
- long long *p = NULL;
-
- //Find super candidates
- for (p = (long long *)utarray_front(hit_group_ids); p != NULL;
- p = (long long *)utarray_next(hit_group_ids, p)) {
- struct maat_group *group = group_topology_find_group(group_topo, *p);
- if (NULL == group) {
- //group_id not in group2group table
- continue;
- }
-
- for (int i = 0; i < utarray_len(group->incl_super_group_ids); i++) {
- long long *tmp = (long long *)utarray_eltptr(group->incl_super_group_ids, i);
- utarray_push_back(super_group_ids, tmp);
- }
- }
-}
-
-static void verify_group_by_sub_include_groups(struct maat_group *group,
- UT_array *candidate_group_ids,
- UT_array *kept_super_group_ids,
- UT_array *all_hit_group_ids)
-{
- size_t remove_idx = 0;
- long long *tmp_id = NULL;
-
- // delete groups whose all incl sub not in all_hit_group_ids
- if (utarray_len(group->incl_sub_group_ids) != 0) {
- int sub_incl_flag = 0;
-
- for (tmp_id = (long long *)utarray_front(group->incl_sub_group_ids); tmp_id != NULL;
- tmp_id = (long long *)utarray_next(group->incl_sub_group_ids, tmp_id)) {
- if (utarray_find(candidate_group_ids, tmp_id, compare_group_id)) {
- sub_incl_flag = 1;
- break;
- }
- }
-
- if (0 == sub_incl_flag) {
- tmp_id = utarray_find(all_hit_group_ids, &(group->group_id), compare_group_id);
- if (tmp_id != NULL) {
- remove_idx = utarray_eltidx(all_hit_group_ids, tmp_id);
- utarray_erase(all_hit_group_ids, remove_idx, 1);
- }
-
- tmp_id = utarray_find(kept_super_group_ids, &(group->group_id), compare_group_id);
- if (tmp_id != NULL) {
- remove_idx = utarray_eltidx(kept_super_group_ids, tmp_id);
- utarray_erase(kept_super_group_ids, remove_idx, 1);
- }
- }
- }
-}
-
-static void verify_group_by_sub_exclude_groups(struct maat_group *group,
- UT_array *candidate_group_ids,
- UT_array *kept_super_group_ids,
- UT_array *all_hit_group_ids)
-{
- if (0 == utarray_len(group->excl_sub_group_ids)) {
- return;
- }
-
- // delete groups whose excl sub in all_hit_group_ids
- int sub_excl_flag = 0;
- long long *tmp_id = NULL;
- for (tmp_id = (long long *)utarray_front(group->excl_sub_group_ids); tmp_id != NULL;
- tmp_id = (long long *)utarray_next(group->excl_sub_group_ids, tmp_id)) {
- if (utarray_find(candidate_group_ids, tmp_id, compare_group_id)) {
- sub_excl_flag = 1;
- break;
- }
- }
-
- if (1 == sub_excl_flag) {
- size_t remove_idx = 0;
- tmp_id = utarray_find(all_hit_group_ids, &(group->group_id), compare_group_id);
- if (tmp_id != NULL) {
- remove_idx = utarray_eltidx(all_hit_group_ids, tmp_id);
- utarray_erase(all_hit_group_ids, remove_idx, 1);
- }
-
- tmp_id = utarray_find(kept_super_group_ids, &(group->group_id), compare_group_id);
- if (tmp_id != NULL) {
- remove_idx = utarray_eltidx(kept_super_group_ids, tmp_id);
- utarray_erase(kept_super_group_ids, remove_idx, 1);
- }
- }
-}
-
-static void verify_candidate_super_group_ids(struct maat_group_topology *group_topo,
- UT_array *candidate_super_group_ids,
- UT_array *all_hit_group_ids,
- UT_array *kept_super_group_ids)
-{
- long long *p = NULL;
- UT_array *candidate_group_ids;
-
- utarray_new(candidate_group_ids, &ut_group_id_icd);
-
- /* merge this round of candidate super groups with hit groups from the previous round */
- for (p = (long long *)utarray_front(candidate_super_group_ids); p != NULL;
- p = (long long *)utarray_next(candidate_super_group_ids, p)) {
- utarray_push_back(candidate_group_ids, p);
- }
-
- for (p = (long long *)utarray_front(all_hit_group_ids); p != NULL;
- p = (long long *)utarray_next(all_hit_group_ids, p)) {
- utarray_push_back(candidate_group_ids, p);
- }
-
- utarray_sort(candidate_group_ids, compare_group_id);
-
- /**
- * verify sub exclude for candidate_super_group_ids
- */
- long long prev_group_id = -1;
- for (p = (long long *)utarray_front(candidate_super_group_ids); p != NULL;
- p = (long long *)utarray_next(candidate_super_group_ids, p)) {
- //filter duplicated group id
- if (*p == prev_group_id) {
- continue;
- }
- prev_group_id = *p;
-
- struct maat_group *group = group_topology_find_group(group_topo, *p);
- if (NULL == group) {
- continue;
- }
-
- //if group's sub excl in candidate_group_ids
- int sub_excl_flag = 0;
- long long *tmp_id = NULL;
- for (tmp_id = (long long *)utarray_front(group->excl_sub_group_ids); tmp_id != NULL;
- tmp_id = (long long *)utarray_next(group->excl_sub_group_ids, tmp_id)) {
- if (utarray_find(candidate_group_ids, tmp_id, compare_group_id)) {
- sub_excl_flag = 1;
- break;
- }
- }
-
- //kept super groups should not store this group
- if (1 == sub_excl_flag) {
- continue;
- }
-
- utarray_push_back(kept_super_group_ids, p);
- utarray_push_back(all_hit_group_ids, p);
- }
-
- utarray_sort(all_hit_group_ids, compare_group_id);
- utarray_sort(kept_super_group_ids, compare_group_id);
-
- /**
- * candidate_group_ids clone all_hit_group_ids
- */
- utarray_clear(candidate_group_ids);
- for (p = (long long *)utarray_front(all_hit_group_ids); p != NULL;
- p = (long long *)utarray_next(all_hit_group_ids, p)) {
- utarray_push_back(candidate_group_ids, p);
- }
-
- /**
- * 1. delete groups whose excl sub in all_hit_group_ids
- * 2. delete groups whose all incl sub is non-exist in all_hit_group_ids
- */
- for (p = (long long *)utarray_front(candidate_group_ids); p != NULL;
- p = (long long *)utarray_next(candidate_group_ids, p)) {
- struct maat_group *group = group_topology_find_group(group_topo, *p);
- if (NULL == group) {
- continue;
- }
-
- verify_group_by_sub_exclude_groups(group, candidate_group_ids,
- kept_super_group_ids, all_hit_group_ids);
- verify_group_by_sub_include_groups(group, candidate_group_ids,
- kept_super_group_ids, all_hit_group_ids);
- }
-
- utarray_free(candidate_group_ids);
-}
-
-static void get_super_group_ids(struct maat_group_topology *group_topo,
- UT_array *hit_group_ids, UT_array *all_hit_group_ids,
- size_t depth)
-{
- UT_array *candidate_super_group_ids;
- UT_array *kept_super_group_ids;
-
- if (depth >= MAX_RECURSION_DEPTH) {
- log_error(group_topo->logger, MODULE_GROUP,
- "[%s:%d]exceed max recursion depth(5)",
- __FUNCTION__, __LINE__);
- for (int i = 0; i < utarray_len(hit_group_ids); i++) {
- long long *p = (long long *)utarray_eltptr(hit_group_ids, i);
- log_error(group_topo->logger, MODULE_GROUP,
- "[%s:%d]group_id:%lld can't recursively get super group_id",
- __FUNCTION__, __LINE__, *p);
- }
- return;
- }
-
- utarray_new(kept_super_group_ids, &ut_group_id_icd);
- utarray_new(candidate_super_group_ids, &ut_group_id_icd);
-
- /**
- candidate super groups means all hit groups' super include group,
- don't consider super exclude groups
- for example:
- hit_groups = {g4, g11}
- g4's super include groups = {g7, g8}
- g11's super include groups = {g12}
-
- candidate super groups = {g7, g8, g12}
- */
- get_candidate_super_group_ids(group_topo, hit_group_ids, candidate_super_group_ids);
-
- if (0 == utarray_len(candidate_super_group_ids)) {
- goto next;
- }
-
- /**
- verify if candidates should be kept for hit super groups, must consider exclude groups
- for example:
- hit_groups = {g4, g11}
- \:include x:exclude
- g12
- x \
- x \
- x \
- x \
- g7 g8 \
- x \ /\ \
- x \ / \ \
- x \ / \ \
- x \/ \ \
- g3 g4 g5 g11
- candidate super groups = {g7, g8, g12}
- verify logic:
- 1. g12's sub_exclude g8 in candidates, so g12 should be dropped
- 2. g7 & g8, their sub_include in hit groups, so kept them
- if their all sub_include not exist in hit groups, they should be dropped
- after verify candidates, kept super groups = {g7, g8},
- all hit groups = {g4, g11, g7, g8}
- */
- verify_candidate_super_group_ids(group_topo, candidate_super_group_ids, all_hit_group_ids,
- kept_super_group_ids);
-
- depth++;
- get_super_group_ids(group_topo, kept_super_group_ids, all_hit_group_ids, depth);
-next:
- utarray_free(candidate_super_group_ids);
- utarray_free(kept_super_group_ids);
-}
-
-static size_t group_topology_get_super_groups(struct maat_group_topology *group_topo,
- long long *group_ids, size_t n_group_ids,
- long long *super_group_ids,
- size_t super_group_ids_size)
-{
- size_t i = 0, idx = 0;
- UT_array *all_hit_group_ids;
- UT_array *candidate_group_ids;
-
- utarray_new(all_hit_group_ids, &ut_group_id_icd);
- utarray_new(candidate_group_ids, &ut_group_id_icd);
-
- for (i = 0; i < n_group_ids; i++) {
- utarray_push_back(all_hit_group_ids, &(group_ids[i]));
- utarray_push_back(candidate_group_ids, &(group_ids[i]));
- }
-
- get_super_group_ids(group_topo, candidate_group_ids, all_hit_group_ids, 0);
-
- for (i = 0; i < n_group_ids; i++) {
- long long *tmp_id = utarray_find(all_hit_group_ids, &(group_ids[i]),
- compare_group_id);
- if (tmp_id != NULL) {
- size_t remove_idx = utarray_eltidx(all_hit_group_ids, tmp_id);
- utarray_erase(all_hit_group_ids, remove_idx, 1);
- }
- }
-
- long long *p = NULL;
- for (p = (long long *)utarray_front(all_hit_group_ids); p != NULL;
- p = (long long *)utarray_next(all_hit_group_ids, p)) {
- if (idx >= super_group_ids_size) {
- break;
- }
- super_group_ids[idx++] = *p;
- }
-
- utarray_free(all_hit_group_ids);
- utarray_free(candidate_group_ids);
-
- return idx;
-}
-
-size_t group2group_runtime_get_super_groups(void *g2g_runtime, long long *group_ids,
- size_t n_group_ids, long long *super_group_ids,
- size_t super_group_ids_size)
-{
- if (NULL == g2g_runtime || NULL == group_ids || 0 == n_group_ids) {
- return 0;
- }
-
- struct group2group_runtime *g2g_rt = (struct group2group_runtime *)g2g_runtime;
- long long g2g_group_ids[n_group_ids];
- size_t g2g_group_ids_cnt = 0;
-
- for (size_t i = 0; i < n_group_ids; i++) {
- struct maat_group *group = group_topology_find_group(g2g_rt->group_topo, group_ids[i]);
- if (NULL == group) {
- continue;
- }
-
- g2g_group_ids[g2g_group_ids_cnt++] = group_ids[i];
- }
-
- if (0 == g2g_group_ids_cnt) {
- return 0;
- }
-
- return group_topology_get_super_groups(g2g_rt->group_topo, g2g_group_ids, g2g_group_ids_cnt,
- super_group_ids, super_group_ids_size);
-}
-
-long long group2group_runtime_rule_count(void *g2g_runtime)
-{
- if (NULL == g2g_runtime) {
- return 0;
- }
-
- struct group2group_runtime *g2g_rt = (struct group2group_runtime *)g2g_runtime;
- return g2g_rt->rule_num;
-}
-
-long long group2group_runtime_exclude_rule_count(void *g2g_runtime)
-{
- if (NULL == g2g_runtime) {
- return 0;
- }
-
- struct group2group_runtime *g2g_rt = (struct group2group_runtime *)g2g_runtime;
- return g2g_rt->excl_rule_num;
-}
-
-long long group2group_runtime_update_err_count(void *g2g_runtime)
-{
- if (NULL == g2g_runtime) {
- return 0;
- }
-
- struct group2group_runtime *g2g_rt = (struct group2group_runtime *)g2g_runtime;
- return g2g_rt->update_err_cnt;
-} \ No newline at end of file
diff --git a/src/maat_interval.c b/src/maat_interval.c
index 828271c..81a8b05 100644
--- a/src/maat_interval.c
+++ b/src/maat_interval.c
@@ -23,7 +23,7 @@
struct interval_schema {
int item_id_column;
- int group_id_column;
+ int object_id_column;
int district_column;
int interval_column;
int table_id;
@@ -32,7 +32,7 @@ struct interval_schema {
struct interval_item {
long long item_id;
- long long group_id;
+ long long object_id;
int low_boundary;
int up_boundary;
void *user_data;
@@ -100,12 +100,12 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
goto error;
}
- custom_item = cJSON_GetObjectItem(item, "group_id");
+ custom_item = cJSON_GetObjectItem(item, "object_id");
if (custom_item != NULL && custom_item->type == cJSON_Number) {
- schema->group_id_column = custom_item->valueint;
+ schema->object_id_column = custom_item->valueint;
} else {
log_fatal(logger, MODULE_INTERVAL,
- "[%s:%d] interval table:<%s> schema has no group_id column",
+ "[%s:%d] interval table:<%s> schema has no object_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
}
@@ -289,15 +289,15 @@ interval_item_new(struct interval_schema *schema, const char *table_name,
}
item->item_id = atoll(line + column_offset);
- ret = get_column_pos(line, schema->group_id_column, &column_offset,
+ ret = get_column_pos(line, schema->object_id_column, &column_offset,
&column_len);
if (ret < 0) {
log_fatal(interval_rt->logger, MODULE_INTERVAL,
- "[%s:%d] interval table:<%s> has no group_id in line:%s",
+ "[%s:%d] interval table:<%s> has no object_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
}
- item->group_id = atoll(line + column_offset);
+ item->object_id = atoll(line + column_offset);
table_type = table_manager_get_table_type(schema->ref_tbl_mgr, schema->table_id);
if (table_type == TABLE_TYPE_INTERVAL_PLUS) {
@@ -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 attribute_id, struct maat_state *state)
{
- //clear rule_state->last_hit_group
+ //clear rule_state->last_hit_object
if (state != NULL && state->rule_state != NULL) {
- rule_state_clear_last_hit_group(state->rule_state);
+ rule_state_clear_last_hit_object(state->rule_state);
}
if (0 == interval_rt->rule_num) {
@@ -587,7 +587,7 @@ int interval_runtime_scan(struct interval_runtime *interval_rt, int thread_id,
}
hit_maat_items[real_hit_item_cnt].item_id = item_id;
- hit_maat_items[real_hit_item_cnt].group_id = int_item->group_id;
+ hit_maat_items[real_hit_item_cnt].object_id = int_item->object_id;
real_hit_item_cnt++;
}
}
diff --git a/src/maat_ip.c b/src/maat_ip.c
index 21cfdc3..86c3d78 100644
--- a/src/maat_ip.c
+++ b/src/maat_ip.c
@@ -25,7 +25,7 @@
struct ip_schema {
int item_id_column;
- int group_id_column;
+ int object_id_column;
int ip_column;
int table_id;
int port_column;
@@ -44,7 +44,7 @@ struct ipv6_item_rule {
struct ip_item {
long long item_id;
- long long group_id;
+ long long object_id;
int addr_type;
union {
struct ipv4_item_rule ipv4;
@@ -107,12 +107,12 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
goto error;
}
- custom_item = cJSON_GetObjectItem(item, "group_id");
+ custom_item = cJSON_GetObjectItem(item, "object_id");
if (custom_item != NULL && custom_item->type == cJSON_Number) {
- ip_schema->group_id_column = custom_item->valueint;
+ ip_schema->object_id_column = custom_item->valueint;
} else {
log_fatal(logger, MODULE_IP,
- "[%s:%d] ip table:<%s> schema has no group_id column",
+ "[%s:%d] ip table:<%s> schema has no object_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
}
@@ -164,15 +164,15 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
}
ip_item->item_id = atoll(line + column_offset);
- ret = get_column_pos(line, ip_schema->group_id_column, &column_offset,
+ ret = get_column_pos(line, ip_schema->object_id_column, &column_offset,
&column_len);
if (ret < 0) {
log_fatal(logger, MODULE_IP,
- "[%s:%d] ip table:<%s> has no group_id in line:%s",
+ "[%s:%d] ip table:<%s> has no object_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
}
- ip_item->group_id = atoll(line + column_offset);
+ ip_item->object_id = atoll(line + column_offset);
ret = get_column_pos(line, ip_schema->ip_column, &column_offset,
&column_len);
@@ -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 attribute_id, struct maat_state *state)
{
- //clear rule_state->last_hit_group
+ //clear rule_state->last_hit_object
if (state != NULL && state->rule_state != NULL) {
- rule_state_clear_last_hit_group(state->rule_state);
+ rule_state_clear_last_hit_object(state->rule_state);
}
if (0 == ip_rt->rule_num) {
@@ -584,7 +584,7 @@ int ip_runtime_scan(struct ip_runtime *ip_rt, int thread_id, int ip_type,
}
hit_maat_items[real_hit_item_cnt].item_id = ip_results[i].rule_id;
- hit_maat_items[real_hit_item_cnt].group_id = ip_item->group_id;
+ hit_maat_items[real_hit_item_cnt].object_id = ip_item->object_id;
real_hit_item_cnt++;
}
diff --git a/src/maat_object.c b/src/maat_object.c
new file mode 100644
index 0000000..c0e9eee
--- /dev/null
+++ b/src/maat_object.c
@@ -0,0 +1,1252 @@
+/*
+**********************************************************************************************
+* File: maat_object.c
+* Description:
+* Authors: Liu wentan <[email protected]>
+* Date: 2022-10-31
+* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved.
+***********************************************************************************************
+*/
+
+#include <assert.h>
+#include <pthread.h>
+
+#include "log/log.h"
+#include "maat_object.h"
+#include "maat_utils.h"
+#include "maat_limits.h"
+#include "uthash/uthash.h"
+#include "uthash/utarray.h"
+#include "igraph/igraph.h"
+#include "maat_kv.h"
+
+#define MODULE_OBJECT module_name_str("maat.object")
+
+struct object2object_item {
+ long long object_id;
+ UT_array *incl_sub_object_ids;
+ UT_array *excl_sub_object_ids;
+};
+
+struct object2object_schema {
+ int object_id_column;
+ int incl_sub_object_ids_column;
+ int excl_sub_object_ids_column;
+ int table_id;
+ struct table_manager *ref_tbl_mgr;
+};
+
+struct maat_object {
+ igraph_integer_t vertex_id;
+ long long object_id;
+
+ int ref_by_super_object_cnt;
+ int ref_by_sub_object_cnt;
+
+ UT_array *incl_super_object_ids;
+ UT_array *excl_super_object_ids;
+ UT_array *incl_sub_object_ids;
+ UT_array *excl_sub_object_ids;
+
+ UT_hash_handle hh_object_id;
+ UT_hash_handle hh_vertex_id;
+};
+
+struct maat_object_topology {
+ struct maat_object *hash_by_object_id; //key: object_id, value: struct maat_object *.
+ struct maat_object *hash_by_vertex_id; //key: vetex_id, value: struct maat_object *.
+ igraph_t object_graph;
+ igraph_integer_t grp_vertex_id_generator;
+ struct log_handle *logger;
+};
+
+struct object2object_runtime {
+ struct maat_object_topology *object_topo;
+ struct maat_object_topology *updating_object_topo;
+ long long rule_num;
+ long long excl_rule_num; //exclude g2g rule num
+ long long update_err_cnt;
+ int updating_flag;
+
+ struct maat_garbage_bin *ref_garbage_bin;
+ struct log_handle *logger;
+};
+
+UT_icd ut_object_id_icd = {sizeof(long long), NULL, NULL, NULL};
+
+static inline int compare_object_id(const void *a, const void *b)
+{
+ long long ret = *(const long long *)a - *(const long long *)b;
+
+ if (0 == ret) {
+ return 0;
+ } else if(ret < 0) {
+ return -1;
+ } else {
+ return 1;
+ }
+}
+
+void *object2object_schema_new(cJSON *json, struct table_manager *tbl_mgr,
+ const char *table_name, struct log_handle *logger)
+{
+ struct object2object_schema *g2g_schema = ALLOC(struct object2object_schema, 1);
+
+ cJSON *custom_item = NULL;
+ cJSON *item = cJSON_GetObjectItem(json, "table_id");
+ if (item != NULL && item->type == cJSON_Number) {
+ g2g_schema->table_id = item->valueint;
+ } else {
+ log_fatal(logger, MODULE_OBJECT,
+ "[%s:%d] g2g table:<%s> schema has no 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_OBJECT,
+ "[%s:%d] g2g table:<%s> schema has no custom column",
+ __FUNCTION__, __LINE__, table_name);
+ goto error;
+ }
+
+ custom_item = cJSON_GetObjectItem(item, "object_id");
+ if (custom_item != NULL && custom_item->type == cJSON_Number) {
+ g2g_schema->object_id_column = custom_item->valueint;
+ } else {
+ log_fatal(logger, MODULE_OBJECT,
+ "[%s:%d] g2g table:<%s> schema has no object_id column",
+ __FUNCTION__, __LINE__, table_name);
+ goto error;
+ }
+
+ custom_item = cJSON_GetObjectItem(item, "included_sub_object_ids");
+ if (custom_item != NULL && custom_item->type == cJSON_Number) {
+ g2g_schema->incl_sub_object_ids_column = custom_item->valueint;
+ } else {
+ log_fatal(logger, MODULE_OBJECT,
+ "[%s:%d] g2g table:<%s> schema has no included_sub_object_ids column",
+ __FUNCTION__, __LINE__, table_name);
+ goto error;
+ }
+
+ custom_item = cJSON_GetObjectItem(item, "excluded_sub_object_ids");
+ if (custom_item != NULL && custom_item->type == cJSON_Number) {
+ g2g_schema->excl_sub_object_ids_column = custom_item->valueint;
+ } else {
+ log_fatal(logger, MODULE_OBJECT,
+ "[%s:%d] g2g table:<%s> schema has no excluded_sub_object_ids column",
+ __FUNCTION__, __LINE__, table_name);
+ goto error;
+ }
+
+ g2g_schema->ref_tbl_mgr = tbl_mgr;
+ return g2g_schema;
+error:
+ FREE(g2g_schema);
+ return NULL;
+}
+
+void object2object_schema_free(void *g2g_schema)
+{
+ FREE(g2g_schema);
+}
+
+static void object_vertex_free(struct maat_object *object)
+{
+ if (NULL == object) {
+ return;
+ }
+
+ if (object->incl_super_object_ids != NULL) {
+ utarray_free(object->incl_super_object_ids);
+ object->incl_super_object_ids = NULL;
+ }
+
+ if (object->excl_super_object_ids != NULL) {
+ utarray_free(object->excl_super_object_ids);
+ object->excl_super_object_ids = NULL;
+ }
+
+ if (object->incl_sub_object_ids != NULL) {
+ utarray_free(object->incl_sub_object_ids);
+ object->incl_sub_object_ids = NULL;
+ }
+
+ if (object->excl_sub_object_ids != NULL) {
+ utarray_free(object->excl_sub_object_ids);
+ object->excl_sub_object_ids = NULL;
+ }
+
+ FREE(object);
+}
+
+static struct maat_object_topology *
+maat_object_topology_new(struct log_handle *logger)
+{
+ struct maat_object_topology *object_topo = ALLOC(struct maat_object_topology, 1);
+ UNUSED int ret = 0;
+
+ object_topo->hash_by_object_id = NULL;
+ object_topo->hash_by_vertex_id = NULL;
+
+ ret = igraph_empty(&(object_topo->object_graph), 0, IGRAPH_DIRECTED);
+ assert(ret == IGRAPH_SUCCESS);
+
+ object_topo->logger = logger;
+
+ return object_topo;
+}
+
+static void maat_object_topology_free(struct maat_object_topology *object_topo)
+{
+ if (NULL == object_topo) {
+ return;
+ }
+
+ struct maat_object *object = NULL, *tmp_object = NULL;
+
+ HASH_CLEAR(hh_vertex_id, object_topo->hash_by_vertex_id);//No need object memory clean up.
+ HASH_ITER(hh_object_id, object_topo->hash_by_object_id, object, tmp_object) {
+ HASH_DELETE(hh_object_id, object_topo->hash_by_object_id, object);
+ object_vertex_free(object);
+ }
+ assert(object_topo->hash_by_object_id == NULL);
+
+ igraph_destroy(&object_topo->object_graph);
+ FREE(object_topo);
+}
+
+static struct maat_object *maat_object_clone(struct maat_object *object)
+{
+ struct maat_object *object_copy = ALLOC(struct maat_object, 1);
+
+ object_copy->object_id = object->object_id;
+ object_copy->vertex_id = object->vertex_id;
+ object_copy->ref_by_sub_object_cnt = object->ref_by_sub_object_cnt;
+ object_copy->ref_by_super_object_cnt = object->ref_by_super_object_cnt;
+ utarray_new(object_copy->incl_super_object_ids, &ut_object_id_icd);
+ utarray_new(object_copy->excl_super_object_ids, &ut_object_id_icd);
+ utarray_new(object_copy->incl_sub_object_ids, &ut_object_id_icd);
+ utarray_new(object_copy->excl_sub_object_ids, &ut_object_id_icd);
+
+ long long *p = NULL;
+ for (p = (long long *)utarray_front(object->incl_super_object_ids); p != NULL;
+ p = (long long *)utarray_next(object->incl_super_object_ids, p)) {
+ utarray_push_back(object_copy->incl_super_object_ids, p);
+ }
+
+ for (p = (long long *)utarray_front(object->excl_super_object_ids); p != NULL;
+ p = (long long *)utarray_next(object->excl_super_object_ids, p)) {
+ utarray_push_back(object_copy->excl_super_object_ids, p);
+ }
+
+ for (p = (long long *)utarray_front(object->incl_sub_object_ids); p != NULL;
+ p = (long long *)utarray_next(object->incl_sub_object_ids, p)) {
+ utarray_push_back(object_copy->incl_sub_object_ids, p);
+ }
+
+ for (p = (long long *)utarray_front(object->excl_sub_object_ids); p != NULL;
+ p = (long long *)utarray_next(object->excl_sub_object_ids, p)) {
+ utarray_push_back(object_copy->excl_sub_object_ids, p);
+ }
+
+ return object_copy;
+}
+
+static struct maat_object_topology *
+maat_object_topology_clone(struct maat_object_topology *object_topo)
+{
+ if (NULL == object_topo) {
+ return NULL;
+ }
+
+ struct maat_object_topology *object_topo_copy = ALLOC(struct maat_object_topology, 1);
+
+ struct maat_object *object = NULL, *tmp_object = NULL;
+ HASH_ITER(hh_object_id, object_topo->hash_by_object_id, object, tmp_object) {
+ struct maat_object *object_copy = maat_object_clone(object);
+
+ HASH_ADD(hh_object_id, object_topo_copy->hash_by_object_id, object_id,
+ sizeof(object_copy->object_id), object_copy);
+ HASH_ADD(hh_vertex_id, object_topo_copy->hash_by_vertex_id, vertex_id,
+ sizeof(object_copy->vertex_id), object_copy);
+ }
+
+ igraph_copy(&(object_topo_copy->object_graph), &(object_topo->object_graph));
+ object_topo_copy->grp_vertex_id_generator = object_topo->grp_vertex_id_generator;
+ object_topo_copy->logger = object_topo->logger;
+
+ return object_topo_copy;
+}
+
+void *object2object_runtime_new(void *g2g_schema, size_t max_thread_num,
+ struct maat_garbage_bin *garbage_bin,
+ struct log_handle *logger)
+{
+ if (NULL == g2g_schema) {
+ return NULL;
+ }
+
+ struct object2object_runtime *g2g_rt = ALLOC(struct object2object_runtime, 1);
+
+ g2g_rt->object_topo = maat_object_topology_new(logger);
+ g2g_rt->ref_garbage_bin = garbage_bin;
+ g2g_rt->logger = logger;
+
+ return g2g_rt;
+}
+
+void object2object_runtime_free(void *g2g_runtime)
+{
+ if (NULL == g2g_runtime) {
+ return;
+ }
+
+ struct object2object_runtime *g2g_rt = (struct object2object_runtime *)g2g_runtime;
+
+ if (g2g_rt->object_topo != NULL) {
+ maat_object_topology_free(g2g_rt->object_topo);
+ g2g_rt->object_topo = NULL;
+ }
+
+ if (g2g_rt->updating_object_topo != NULL) {
+ maat_object_topology_free(g2g_rt->updating_object_topo);
+ g2g_rt->updating_object_topo = NULL;
+ }
+
+ FREE(g2g_rt);
+}
+
+static struct object2object_item *
+object2object_item_new(const char *line, struct object2object_schema *g2g_schema,
+ const char *table_name, struct log_handle *logger)
+{
+ size_t column_offset = 0;
+ size_t column_len = 0;
+ struct object2object_item *g2g_item = ALLOC(struct object2object_item, 1);
+ utarray_new(g2g_item->incl_sub_object_ids, &ut_object_id_icd);
+ utarray_new(g2g_item->excl_sub_object_ids, &ut_object_id_icd);
+
+ int ret = get_column_pos(line, g2g_schema->object_id_column,
+ &column_offset, &column_len);
+ if (ret < 0) {
+ log_fatal(logger, MODULE_OBJECT,
+ "[%s:%d] g2 table:<%s> has no object_id in line:%s",
+ __FUNCTION__, __LINE__, table_name, line);
+ goto error;
+ }
+ g2g_item->object_id = atoll(line + column_offset);
+
+ ret = get_column_pos(line, g2g_schema->incl_sub_object_ids_column,
+ &column_offset, &column_len);
+ if (ret < 0) {
+ log_fatal(logger, MODULE_OBJECT,
+ "[%s:%d] g2g table:<%s> has no included_sub_object_ids in line:%s",
+ __FUNCTION__, __LINE__, table_name, line);
+ goto error;
+ }
+
+ char object_ids_str[MAX_OBJECT_IDS_STR_LEN] = {0};
+ memcpy(object_ids_str, line + column_offset, MIN(MAX_OBJECT_IDS_STR_LEN, column_len));
+
+ ret = ids_str2longlong_array(object_ids_str, g2g_item->incl_sub_object_ids);
+ if (ret < 0) {
+ log_fatal(logger, MODULE_OBJECT,
+ "[%s:%d] g2c table:<%s> included_sub_object_ids str2longlong failed in line:%s",
+ __FUNCTION__, __LINE__, table_name, line);
+ goto error;
+ }
+
+ if (utarray_len(g2g_item->incl_sub_object_ids) > MAX_OBJECT_CNT) {
+ log_fatal(logger, MODULE_OBJECT,
+ "[%s:%d] g2c table:<%s> included_sub_object_ids exceed maximum:%d in line:%s",
+ __FUNCTION__, __LINE__, table_name, MAX_OBJECT_CNT, line);
+ goto error;
+ }
+
+ ret = get_column_pos(line, g2g_schema->excl_sub_object_ids_column,
+ &column_offset, &column_len);
+ if (ret < 0) {
+ log_fatal(logger, MODULE_OBJECT,
+ "[%s:%d] g2g table:<%s> has no excluded_sub_object_ids in line:%s",
+ __FUNCTION__, __LINE__, table_name, line);
+ goto error;
+ }
+
+ memset(object_ids_str, 0, sizeof(object_ids_str));
+ memcpy(object_ids_str, line + column_offset, MIN(MAX_OBJECT_IDS_STR_LEN, column_len));
+
+ ret = ids_str2longlong_array(object_ids_str, g2g_item->excl_sub_object_ids);
+ if (ret < 0) {
+ log_fatal(logger, MODULE_OBJECT,
+ "[%s:%d] g2c table:<%s> excluded_sub_object_ids str2longlong failed in line:%s",
+ __FUNCTION__, __LINE__, table_name, line);
+ goto error;
+ }
+
+ if (utarray_len(g2g_item->excl_sub_object_ids) > MAX_OBJECT_CNT) {
+ log_fatal(logger, MODULE_OBJECT,
+ "[%s:%d] g2c table:<%s> excluded_sub_object_ids exceed maximum:%d in line:%s",
+ __FUNCTION__, __LINE__, table_name, MAX_OBJECT_CNT, line);
+ goto error;
+ }
+
+ return g2g_item;
+error:
+ FREE(g2g_item);
+ return NULL;
+}
+
+static void object2object_item_free(struct object2object_item *g2g_item)
+{
+ if (NULL == g2g_item) {
+ return;
+ }
+
+ if (g2g_item->incl_sub_object_ids != NULL) {
+ utarray_free(g2g_item->incl_sub_object_ids);
+ g2g_item->incl_sub_object_ids = NULL;
+ }
+
+ if (g2g_item->excl_sub_object_ids != NULL) {
+ utarray_free(g2g_item->excl_sub_object_ids);
+ g2g_item->excl_sub_object_ids = NULL;
+ }
+
+ FREE(g2g_item);
+}
+
+static size_t print_igraph_vector(igraph_vector_t *v, char *buff, size_t sz) {
+ long int i;
+ int printed = 0;
+
+ for (i = 0; i < igraph_vector_size(v); i++) {
+ printed += snprintf(buff + printed, sz - printed, " %li",
+ (long int) VECTOR(*v)[i]);
+ }
+
+ return printed;
+}
+
+static struct maat_object *
+object_topology_add_object(struct maat_object_topology *object_topo, long long object_id)
+{
+ assert(object_topo != NULL);
+
+ struct maat_object *object = ALLOC(struct maat_object, 1);
+ object->object_id = object_id;
+ object->vertex_id = object_topo->grp_vertex_id_generator++;
+ utarray_new(object->incl_super_object_ids, &ut_object_id_icd);
+ utarray_new(object->excl_super_object_ids, &ut_object_id_icd);
+ utarray_new(object->incl_sub_object_ids, &ut_object_id_icd);
+ utarray_new(object->excl_sub_object_ids, &ut_object_id_icd);
+
+ assert(igraph_vcount(&object_topo->object_graph)==object->vertex_id);
+ igraph_add_vertices(&object_topo->object_graph, 1, NULL); //Add 1 vertice.
+
+ HASH_ADD(hh_object_id, object_topo->hash_by_object_id, object_id,
+ sizeof(object->object_id), object);
+ HASH_ADD(hh_vertex_id, object_topo->hash_by_vertex_id, vertex_id,
+ sizeof(object->vertex_id), object);
+
+ return object;
+}
+
+static void object_topology_del_object(struct maat_object_topology *object_topo,
+ struct maat_object *object)
+{
+ if (NULL == object_topo || NULL == object) {
+ return;
+ }
+
+ igraph_vector_t v;
+ char buff[4096] = {0};
+
+ assert(object->ref_by_super_object_cnt == 0);
+
+ igraph_vector_init(&v, 8);
+ igraph_neighbors(&object_topo->object_graph, &v, object->vertex_id, IGRAPH_ALL);
+ if (igraph_vector_size(&v) > 0) {
+ print_igraph_vector(&v, buff, sizeof(buff));
+ log_fatal(object_topo->logger, MODULE_OBJECT,
+ "[%s:%d] Del object %d exception, still reached by %s.",
+ __FUNCTION__, __LINE__, object->vertex_id, buff);
+ assert(0);
+ }
+ igraph_vector_destroy(&v);
+
+ //We should not call igraph_delete_vertices, because this is function changes the ids of the vertices.
+
+ HASH_DELETE(hh_object_id, object_topo->hash_by_object_id, object);
+ HASH_DELETE(hh_vertex_id, object_topo->hash_by_vertex_id, object);
+ object_vertex_free(object);
+}
+
+static struct maat_object *
+object_topology_find_object(struct maat_object_topology *object_topo, long long object_id)
+{
+ if (NULL == object_topo || object_id < 0) {
+ return NULL;
+ }
+
+ struct maat_object *object = NULL;
+ HASH_FIND(hh_object_id, object_topo->hash_by_object_id, &object_id, sizeof(object_id), object);
+
+ return object;
+}
+
+static void maat_object_reference_super_object(struct maat_object *object,
+ long long super_object_id,
+ int is_exclude)
+{
+ if (NULL == object || super_object_id < 0) {
+ return;
+ }
+
+ if (0 == is_exclude) {
+ //include superior object
+ if (!utarray_find(object->incl_super_object_ids, &super_object_id,
+ compare_object_id)) {
+ utarray_push_back(object->incl_super_object_ids, &super_object_id);
+ utarray_sort(object->incl_super_object_ids, compare_object_id);
+ }
+ } else {
+ //exclude superior object
+ if (!utarray_find(object->excl_super_object_ids, &super_object_id,
+ compare_object_id)) {
+ utarray_push_back(object->excl_super_object_ids, &super_object_id);
+ utarray_sort(object->excl_super_object_ids, compare_object_id);
+ }
+ }
+}
+
+static void maat_object_reference_sub_object(struct maat_object *object,
+ long long sub_object_id,
+ int is_exclude)
+{
+ if (NULL == object || sub_object_id < 0) {
+ return;
+ }
+
+ if (0 == is_exclude) {
+ //include sub object
+ if (!utarray_find(object->incl_sub_object_ids, &sub_object_id,
+ compare_object_id)) {
+ utarray_push_back(object->incl_sub_object_ids, &sub_object_id);
+ utarray_sort(object->incl_sub_object_ids, compare_object_id);
+ }
+ } else {
+ //exclude sub object
+ if (!utarray_find(object->excl_sub_object_ids, &sub_object_id,
+ compare_object_id)) {
+ utarray_push_back(object->excl_sub_object_ids, &sub_object_id);
+ utarray_sort(object->excl_sub_object_ids, compare_object_id);
+ }
+ }
+}
+
+static void maat_object_dereference_super_object(struct maat_object *object,
+ long long super_object_id,
+ int is_exclude)
+{
+ if (NULL == object || super_object_id < 0) {
+ return;
+ }
+
+ size_t remove_idx = 0;
+ long long *tmp_id = NULL;
+ if (0 == is_exclude) {
+ //include superior object
+ tmp_id = utarray_find(object->incl_super_object_ids, &super_object_id,
+ compare_object_id);
+ if (tmp_id != NULL) {
+ remove_idx = utarray_eltidx(object->incl_super_object_ids, tmp_id);
+ utarray_erase(object->incl_super_object_ids, remove_idx, 1);
+ }
+ } else {
+ //exclude superior object
+ tmp_id = utarray_find(object->excl_super_object_ids, &super_object_id,
+ compare_object_id);
+ if (tmp_id != NULL) {
+ remove_idx = utarray_eltidx(object->excl_super_object_ids, tmp_id);
+ utarray_erase(object->excl_super_object_ids, remove_idx, 1);
+ }
+ }
+}
+
+static void maat_object_dereference_sub_object(struct maat_object *object,
+ long long sub_object_id,
+ int is_exclude)
+{
+ if (NULL == object || sub_object_id < 0) {
+ return;
+ }
+
+ size_t remove_idx = 0;
+ long long *tmp_id = NULL;
+ if (0 == is_exclude) {
+ //include superior object
+ tmp_id = utarray_find(object->incl_sub_object_ids, &sub_object_id,
+ compare_object_id);
+ if (tmp_id != NULL) {
+ remove_idx = utarray_eltidx(object->incl_sub_object_ids, tmp_id);
+ utarray_erase(object->incl_sub_object_ids, remove_idx, 1);
+ }
+ } else {
+ //exclude superior object
+ tmp_id = utarray_find(object->excl_sub_object_ids, &sub_object_id,
+ compare_object_id);
+ if (tmp_id != NULL) {
+ remove_idx = utarray_eltidx(object->excl_sub_object_ids, tmp_id);
+ utarray_erase(object->excl_sub_object_ids, remove_idx, 1);
+ }
+ }
+}
+
+static int object_topology_add_object_to_object(struct maat_object_topology *object_topo,
+ long long object_id, long long sub_object_id,
+ int is_exclude)
+{
+ if (NULL == object_topo) {
+ return -1;
+ }
+
+ struct maat_object *sub_object = object_topology_find_object(object_topo, sub_object_id);
+ if (NULL == sub_object) {
+ sub_object = object_topology_add_object(object_topo, sub_object_id);
+ }
+
+ struct maat_object *object = object_topology_find_object(object_topo, object_id);
+ if (NULL == object) {
+ object = object_topology_add_object(object_topo, object_id);
+ }
+
+ maat_object_reference_super_object(sub_object, object_id, is_exclude);
+ maat_object_reference_sub_object(object, sub_object_id, is_exclude);
+
+ igraph_integer_t edge_id;
+ int ret = igraph_get_eid(&object_topo->object_graph, &edge_id, sub_object->vertex_id,
+ object->vertex_id, IGRAPH_DIRECTED, /*error*/ 0);
+
+ //No duplicated edges between two objects.
+ if (edge_id > 0) {
+ log_fatal(object_topo->logger, MODULE_OBJECT,
+ "[%s:%d] Add object %d to object %d failed, relation already existed.",
+ __FUNCTION__, __LINE__, sub_object->object_id, object->object_id);
+ ret = -1;
+ } else {
+ igraph_add_edge(&object_topo->object_graph, sub_object->vertex_id,
+ object->vertex_id);
+ sub_object->ref_by_super_object_cnt++;
+ object->ref_by_sub_object_cnt++;
+ ret = 0;
+ }
+
+ igraph_bool_t is_dag;
+ igraph_is_dag(&(object_topo->object_graph), &is_dag);
+ if (!is_dag) {
+ log_fatal(object_topo->logger, MODULE_OBJECT,
+ "[%s:%d] Sub object cycle detected, sub_object_id:%lld, object_id:%lld!",
+ __FUNCTION__, __LINE__, sub_object_id, object_id);
+ return -1;
+ }
+
+ return ret;
+}
+
+static int object_topology_del_object_from_object(struct maat_object_topology *object_topo,
+ long long object_id, long long sub_object_id,
+ int is_exclude)
+{
+ if (NULL == object_topo) {
+ return -1;
+ }
+
+ //No hash write operation, LOCK protection is unnecessary.
+ struct maat_object *sub_object = object_topology_find_object(object_topo, sub_object_id);
+ if (NULL == sub_object) {
+ log_fatal(object_topo->logger, MODULE_OBJECT,
+ "[%s:%d] Del object %d from object %d failed, object %d not existed.",
+ __FUNCTION__, __LINE__, sub_object_id, object_id, sub_object_id);
+ return -1;
+ }
+
+ struct maat_object *object = object_topology_find_object(object_topo, object_id);
+ if (NULL == object) {
+ log_fatal(object_topo->logger, MODULE_OBJECT,
+ "[%s:%d] Del object %d from object %d failed, object %d not existed.",
+ __FUNCTION__, __LINE__, sub_object_id, object_id, object_id);
+ return -1;
+ }
+
+ maat_object_dereference_super_object(sub_object, object_id, is_exclude);
+ maat_object_dereference_sub_object(object, sub_object_id, is_exclude);
+
+ igraph_es_t es;
+ igraph_integer_t edge_num_before = 0, edge_num_after = 0;
+
+ edge_num_before = igraph_ecount(&object_topo->object_graph);
+ // The edges between the given pairs of vertices will be included in the edge selection.
+ //The vertex pairs must be given as the arguments of the function call, the third argument
+ //is the first vertex of the first edge, the fourth argument is the second vertex of the
+ //first edge, the fifth is the first vertex of the second edge and so on. The last element
+ //of the argument list must be -1 to denote the end of the argument list.
+ //https://igraph.org/c/doc/igraph-Iterators.html#igraph_es_pairs_small
+ int ret = igraph_es_pairs_small(&es, IGRAPH_DIRECTED, sub_object->vertex_id,
+ object->vertex_id, -1);
+ assert(ret==IGRAPH_SUCCESS);
+ // ignore no such edge to abort().
+ igraph_set_error_handler(igraph_error_handler_ignore);
+ ret = igraph_delete_edges(&object_topo->object_graph, es);
+ edge_num_after = igraph_ecount(&object_topo->object_graph);
+ igraph_es_destroy(&es);
+
+ if (ret != IGRAPH_SUCCESS || edge_num_before - edge_num_after != 1) {
+ assert(0);
+ return -1;
+ }
+
+ sub_object->ref_by_super_object_cnt--;
+ object->ref_by_sub_object_cnt--;
+
+ return 0;
+}
+
+static int object_topology_build_super_objects(struct maat_object_topology *object_topo)
+{
+ if (NULL == object_topo) {
+ return -1;
+ }
+
+ igraph_bool_t is_dag;
+ igraph_is_dag(&(object_topo->object_graph), &is_dag);
+ if (!is_dag) {
+ log_fatal(object_topo->logger, MODULE_OBJECT,
+ "[%s:%d] Sub object cycle detected!", __FUNCTION__, __LINE__);
+ return -1;
+ }
+
+ struct maat_object *object = NULL, *tmp_object = NULL;
+ HASH_ITER (hh_object_id, object_topo->hash_by_object_id, object, tmp_object) {
+ //Orphan, Not reference by any one, free it.
+ if (0 == object->ref_by_super_object_cnt
+ && 0 == object->ref_by_sub_object_cnt) {
+ object_topology_del_object(object_topo, object);
+ continue;
+ }
+ }
+
+ return 0;
+}
+
+int object2object_runtime_update(void *g2g_runtime, void *g2g_schema,
+ const char *table_name, const char *line,
+ int valid_column)
+{
+ if (NULL == g2g_runtime || NULL == g2g_schema ||
+ NULL == line) {
+ return -1;
+ }
+
+ struct object2object_schema *schema = (struct object2object_schema *)g2g_schema;
+ struct object2object_runtime *g2g_rt = (struct object2object_runtime *)g2g_runtime;
+ int is_valid = get_column_value(line, valid_column);
+ if (is_valid < 0) {
+ log_fatal(g2g_rt->logger, MODULE_OBJECT,
+ "[%s:%d] g2g table:<%s> has no is_valid(column seq:%d)"
+ " in table_line:%s", __FUNCTION__, __LINE__, table_name,
+ valid_column, line);
+ g2g_rt->update_err_cnt++;
+ return -1;
+ }
+
+ struct object2object_item *g2g_item = object2object_item_new(line, schema, table_name,
+ g2g_rt->logger);
+ if (NULL == g2g_item) {
+ g2g_rt->update_err_cnt++;
+ return -1;
+ }
+
+ if (0 == g2g_rt->updating_flag) {
+ assert(g2g_rt->updating_object_topo == NULL);
+ g2g_rt->updating_object_topo = maat_object_topology_clone(g2g_rt->object_topo);
+ g2g_rt->updating_flag = 1;
+ }
+
+ int ret = 0;
+ size_t i = 0;
+ int err_flag = 0;
+ long long *sub_object_id = NULL;
+ if (0 == is_valid) {
+ //delete
+ for (i = 0; i < utarray_len(g2g_item->incl_sub_object_ids); i++) {
+ sub_object_id = (long long *)utarray_eltptr(g2g_item->incl_sub_object_ids, i);
+ ret = object_topology_del_object_from_object(g2g_rt->updating_object_topo,
+ g2g_item->object_id, *sub_object_id, 0);
+ if (ret != 0) {
+ err_flag = 1;
+ }
+ }
+
+ for (i = 0; i < utarray_len(g2g_item->excl_sub_object_ids); i++) {
+ sub_object_id = (long long *)utarray_eltptr(g2g_item->excl_sub_object_ids, i);
+ ret = object_topology_del_object_from_object(g2g_rt->updating_object_topo,
+ g2g_item->object_id, *sub_object_id, 1);
+ if (ret != 0) {
+ err_flag = 1;
+ }
+ }
+
+ if (1 == err_flag) {
+ g2g_rt->update_err_cnt++;
+ } else {
+ if (utarray_len(g2g_item->excl_sub_object_ids) > 0) {
+ g2g_rt->excl_rule_num--;
+ }
+ g2g_rt->rule_num--;
+ }
+ } else {
+ //add
+ for (i = 0; i < utarray_len(g2g_item->incl_sub_object_ids); i++) {
+ sub_object_id = (long long *)utarray_eltptr(g2g_item->incl_sub_object_ids, i);
+ ret = object_topology_add_object_to_object(g2g_rt->updating_object_topo,
+ g2g_item->object_id, *sub_object_id, 0);
+ if (ret != 0) {
+ err_flag = 1;
+ }
+ }
+
+ for (i = 0; i < utarray_len(g2g_item->excl_sub_object_ids); i++) {
+ sub_object_id = (long long *)utarray_eltptr(g2g_item->excl_sub_object_ids, i);
+ ret = object_topology_add_object_to_object(g2g_rt->updating_object_topo,
+ g2g_item->object_id, *sub_object_id, 1);
+ if (ret != 0) {
+ err_flag = 1;
+ }
+ }
+
+ if (1 == err_flag) {
+ g2g_rt->update_err_cnt++;
+ } else {
+ if (utarray_len(g2g_item->excl_sub_object_ids) > 0) {
+ g2g_rt->excl_rule_num++;
+ }
+ g2g_rt->rule_num++;
+ }
+ }
+ object2object_item_free(g2g_item);
+
+ return ret;
+}
+
+static void garbage_maat_object_topology_free(void *data, void *arg)
+{
+ struct maat_object_topology *object_topo = (struct maat_object_topology *)data;
+ maat_object_topology_free(object_topo);
+}
+
+int object2object_runtime_commit(void *g2g_runtime, const char *table_name,
+ long long maat_rt_version)
+{
+ if (NULL == g2g_runtime) {
+ return -1;
+ }
+
+ struct object2object_runtime *g2g_rt = (struct object2object_runtime *)g2g_runtime;
+ if (0 == g2g_rt->updating_flag) {
+ return 0;
+ }
+
+ struct timespec start, end;
+ clock_gettime(CLOCK_MONOTONIC, &start);
+ int ret = object_topology_build_super_objects(g2g_rt->updating_object_topo);
+ 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 (ret < 0) {
+ log_fatal(g2g_rt->logger, MODULE_OBJECT,
+ "[%s:%d] table[%s] object2object runtime commit failed",
+ __FUNCTION__, __LINE__, table_name);
+ return -1;
+ }
+
+ struct maat_object_topology *old_object_topo = g2g_rt->object_topo;
+ g2g_rt->object_topo = g2g_rt->updating_object_topo;
+ g2g_rt->updating_object_topo = NULL;
+ g2g_rt->updating_flag = 0;
+
+ maat_garbage_bagging(g2g_rt->ref_garbage_bin, old_object_topo, NULL,
+ garbage_maat_object_topology_free);
+
+ log_info(g2g_rt->logger, MODULE_OBJECT,
+ "table[%s] commit %zu g2g rules and rebuild super_objects completed,"
+ " version:%lld, consume:%lldms", table_name, g2g_rt->rule_num,
+ maat_rt_version, time_elapse_ms);
+
+ return 0;
+}
+
+#define MAX_RECURSION_DEPTH 5
+static void get_candidate_super_object_ids(struct maat_object_topology *object_topo,
+ UT_array *hit_object_ids,
+ UT_array *super_object_ids)
+{
+ long long *p = NULL;
+
+ //Find super candidates
+ for (p = (long long *)utarray_front(hit_object_ids); p != NULL;
+ p = (long long *)utarray_next(hit_object_ids, p)) {
+ struct maat_object *object = object_topology_find_object(object_topo, *p);
+ if (NULL == object) {
+ //object_id not in object2object table
+ continue;
+ }
+
+ for (int i = 0; i < utarray_len(object->incl_super_object_ids); i++) {
+ long long *tmp = (long long *)utarray_eltptr(object->incl_super_object_ids, i);
+ utarray_push_back(super_object_ids, tmp);
+ }
+ }
+}
+
+static void verify_object_by_sub_include_objects(struct maat_object *object,
+ UT_array *candidate_object_ids,
+ UT_array *kept_super_object_ids,
+ UT_array *all_hit_object_ids)
+{
+ size_t remove_idx = 0;
+ long long *tmp_id = NULL;
+
+ // delete objects whose all incl sub not in all_hit_object_ids
+ if (utarray_len(object->incl_sub_object_ids) != 0) {
+ int sub_incl_flag = 0;
+
+ for (tmp_id = (long long *)utarray_front(object->incl_sub_object_ids); tmp_id != NULL;
+ tmp_id = (long long *)utarray_next(object->incl_sub_object_ids, tmp_id)) {
+ if (utarray_find(candidate_object_ids, tmp_id, compare_object_id)) {
+ sub_incl_flag = 1;
+ break;
+ }
+ }
+
+ if (0 == sub_incl_flag) {
+ tmp_id = utarray_find(all_hit_object_ids, &(object->object_id), compare_object_id);
+ if (tmp_id != NULL) {
+ remove_idx = utarray_eltidx(all_hit_object_ids, tmp_id);
+ utarray_erase(all_hit_object_ids, remove_idx, 1);
+ }
+
+ tmp_id = utarray_find(kept_super_object_ids, &(object->object_id), compare_object_id);
+ if (tmp_id != NULL) {
+ remove_idx = utarray_eltidx(kept_super_object_ids, tmp_id);
+ utarray_erase(kept_super_object_ids, remove_idx, 1);
+ }
+ }
+ }
+}
+
+static void verify_object_by_sub_exclude_objects(struct maat_object *object,
+ UT_array *candidate_object_ids,
+ UT_array *kept_super_object_ids,
+ UT_array *all_hit_object_ids)
+{
+ if (0 == utarray_len(object->excl_sub_object_ids)) {
+ return;
+ }
+
+ // delete objects whose excl sub in all_hit_object_ids
+ int sub_excl_flag = 0;
+ long long *tmp_id = NULL;
+ for (tmp_id = (long long *)utarray_front(object->excl_sub_object_ids); tmp_id != NULL;
+ tmp_id = (long long *)utarray_next(object->excl_sub_object_ids, tmp_id)) {
+ if (utarray_find(candidate_object_ids, tmp_id, compare_object_id)) {
+ sub_excl_flag = 1;
+ break;
+ }
+ }
+
+ if (1 == sub_excl_flag) {
+ size_t remove_idx = 0;
+ tmp_id = utarray_find(all_hit_object_ids, &(object->object_id), compare_object_id);
+ if (tmp_id != NULL) {
+ remove_idx = utarray_eltidx(all_hit_object_ids, tmp_id);
+ utarray_erase(all_hit_object_ids, remove_idx, 1);
+ }
+
+ tmp_id = utarray_find(kept_super_object_ids, &(object->object_id), compare_object_id);
+ if (tmp_id != NULL) {
+ remove_idx = utarray_eltidx(kept_super_object_ids, tmp_id);
+ utarray_erase(kept_super_object_ids, remove_idx, 1);
+ }
+ }
+}
+
+static void verify_candidate_super_object_ids(struct maat_object_topology *object_topo,
+ UT_array *candidate_super_object_ids,
+ UT_array *all_hit_object_ids,
+ UT_array *kept_super_object_ids)
+{
+ long long *p = NULL;
+ UT_array *candidate_object_ids;
+
+ utarray_new(candidate_object_ids, &ut_object_id_icd);
+
+ /* merge this round of candidate super objects with hit objects from the previous round */
+ for (p = (long long *)utarray_front(candidate_super_object_ids); p != NULL;
+ p = (long long *)utarray_next(candidate_super_object_ids, p)) {
+ utarray_push_back(candidate_object_ids, p);
+ }
+
+ for (p = (long long *)utarray_front(all_hit_object_ids); p != NULL;
+ p = (long long *)utarray_next(all_hit_object_ids, p)) {
+ utarray_push_back(candidate_object_ids, p);
+ }
+
+ utarray_sort(candidate_object_ids, compare_object_id);
+
+ /**
+ * verify sub exclude for candidate_super_object_ids
+ */
+ long long prev_object_id = -1;
+ for (p = (long long *)utarray_front(candidate_super_object_ids); p != NULL;
+ p = (long long *)utarray_next(candidate_super_object_ids, p)) {
+ //filter duplicated object id
+ if (*p == prev_object_id) {
+ continue;
+ }
+ prev_object_id = *p;
+
+ struct maat_object *object = object_topology_find_object(object_topo, *p);
+ if (NULL == object) {
+ continue;
+ }
+
+ //if object's sub excl in candidate_object_ids
+ int sub_excl_flag = 0;
+ long long *tmp_id = NULL;
+ for (tmp_id = (long long *)utarray_front(object->excl_sub_object_ids); tmp_id != NULL;
+ tmp_id = (long long *)utarray_next(object->excl_sub_object_ids, tmp_id)) {
+ if (utarray_find(candidate_object_ids, tmp_id, compare_object_id)) {
+ sub_excl_flag = 1;
+ break;
+ }
+ }
+
+ //kept super objects should not store this object
+ if (1 == sub_excl_flag) {
+ continue;
+ }
+
+ utarray_push_back(kept_super_object_ids, p);
+ utarray_push_back(all_hit_object_ids, p);
+ }
+
+ utarray_sort(all_hit_object_ids, compare_object_id);
+ utarray_sort(kept_super_object_ids, compare_object_id);
+
+ /**
+ * candidate_object_ids clone all_hit_object_ids
+ */
+ utarray_clear(candidate_object_ids);
+ for (p = (long long *)utarray_front(all_hit_object_ids); p != NULL;
+ p = (long long *)utarray_next(all_hit_object_ids, p)) {
+ utarray_push_back(candidate_object_ids, p);
+ }
+
+ /**
+ * 1. delete objects whose excl sub in all_hit_object_ids
+ * 2. delete objects whose all incl sub is non-exist in all_hit_object_ids
+ */
+ for (p = (long long *)utarray_front(candidate_object_ids); p != NULL;
+ p = (long long *)utarray_next(candidate_object_ids, p)) {
+ struct maat_object *object = object_topology_find_object(object_topo, *p);
+ if (NULL == object) {
+ continue;
+ }
+
+ verify_object_by_sub_exclude_objects(object, candidate_object_ids,
+ kept_super_object_ids, all_hit_object_ids);
+ verify_object_by_sub_include_objects(object, candidate_object_ids,
+ kept_super_object_ids, all_hit_object_ids);
+ }
+
+ utarray_free(candidate_object_ids);
+}
+
+static void get_super_object_ids(struct maat_object_topology *object_topo,
+ UT_array *hit_object_ids, UT_array *all_hit_object_ids,
+ size_t depth)
+{
+ UT_array *candidate_super_object_ids;
+ UT_array *kept_super_object_ids;
+
+ if (depth >= MAX_RECURSION_DEPTH) {
+ log_error(object_topo->logger, MODULE_OBJECT,
+ "[%s:%d]exceed max recursion depth(5)",
+ __FUNCTION__, __LINE__);
+ for (int i = 0; i < utarray_len(hit_object_ids); i++) {
+ long long *p = (long long *)utarray_eltptr(hit_object_ids, i);
+ log_error(object_topo->logger, MODULE_OBJECT,
+ "[%s:%d]object_id:%lld can't recursively get super object_id",
+ __FUNCTION__, __LINE__, *p);
+ }
+ return;
+ }
+
+ utarray_new(kept_super_object_ids, &ut_object_id_icd);
+ utarray_new(candidate_super_object_ids, &ut_object_id_icd);
+
+ /**
+ candidate super objects means all hit objects' super include object,
+ don't consider super exclude objects
+ for example:
+ hit_objects = {g4, g11}
+ g4's super include objects = {g7, g8}
+ g11's super include objects = {g12}
+
+ candidate super objects = {g7, g8, g12}
+ */
+ get_candidate_super_object_ids(object_topo, hit_object_ids, candidate_super_object_ids);
+
+ if (0 == utarray_len(candidate_super_object_ids)) {
+ goto next;
+ }
+
+ /**
+ verify if candidates should be kept for hit super objects, must consider exclude objects
+ for example:
+ hit_objects = {g4, g11}
+ \:include x:exclude
+ g12
+ x \
+ x \
+ x \
+ x \
+ g7 g8 \
+ x \ /\ \
+ x \ / \ \
+ x \ / \ \
+ x \/ \ \
+ g3 g4 g5 g11
+ candidate super objects = {g7, g8, g12}
+ verify logic:
+ 1. g12's sub_exclude g8 in candidates, so g12 should be dropped
+ 2. g7 & g8, their sub_include in hit objects, so kept them
+ if their all sub_include not exist in hit objects, they should be dropped
+ after verify candidates, kept super objects = {g7, g8},
+ all hit objects = {g4, g11, g7, g8}
+ */
+ verify_candidate_super_object_ids(object_topo, candidate_super_object_ids, all_hit_object_ids,
+ kept_super_object_ids);
+
+ depth++;
+ get_super_object_ids(object_topo, kept_super_object_ids, all_hit_object_ids, depth);
+next:
+ utarray_free(candidate_super_object_ids);
+ utarray_free(kept_super_object_ids);
+}
+
+static size_t object_topology_get_super_objects(struct maat_object_topology *object_topo,
+ long long *object_ids, size_t n_object_ids,
+ long long *super_object_ids,
+ size_t super_object_ids_size)
+{
+ size_t i = 0, idx = 0;
+ UT_array *all_hit_object_ids;
+ UT_array *candidate_object_ids;
+
+ utarray_new(all_hit_object_ids, &ut_object_id_icd);
+ utarray_new(candidate_object_ids, &ut_object_id_icd);
+
+ for (i = 0; i < n_object_ids; i++) {
+ utarray_push_back(all_hit_object_ids, &(object_ids[i]));
+ utarray_push_back(candidate_object_ids, &(object_ids[i]));
+ }
+
+ get_super_object_ids(object_topo, candidate_object_ids, all_hit_object_ids, 0);
+
+ for (i = 0; i < n_object_ids; i++) {
+ long long *tmp_id = utarray_find(all_hit_object_ids, &(object_ids[i]),
+ compare_object_id);
+ if (tmp_id != NULL) {
+ size_t remove_idx = utarray_eltidx(all_hit_object_ids, tmp_id);
+ utarray_erase(all_hit_object_ids, remove_idx, 1);
+ }
+ }
+
+ long long *p = NULL;
+ for (p = (long long *)utarray_front(all_hit_object_ids); p != NULL;
+ p = (long long *)utarray_next(all_hit_object_ids, p)) {
+ if (idx >= super_object_ids_size) {
+ break;
+ }
+ super_object_ids[idx++] = *p;
+ }
+
+ utarray_free(all_hit_object_ids);
+ utarray_free(candidate_object_ids);
+
+ return idx;
+}
+
+size_t object2object_runtime_get_super_objects(void *g2g_runtime, long long *object_ids,
+ size_t n_object_ids, long long *super_object_ids,
+ size_t super_object_ids_size)
+{
+ if (NULL == g2g_runtime || NULL == object_ids || 0 == n_object_ids) {
+ return 0;
+ }
+
+ struct object2object_runtime *g2g_rt = (struct object2object_runtime *)g2g_runtime;
+ long long g2g_object_ids[n_object_ids];
+ size_t g2g_object_ids_cnt = 0;
+
+ for (size_t i = 0; i < n_object_ids; i++) {
+ struct maat_object *object = object_topology_find_object(g2g_rt->object_topo, object_ids[i]);
+ if (NULL == object) {
+ continue;
+ }
+
+ g2g_object_ids[g2g_object_ids_cnt++] = object_ids[i];
+ }
+
+ if (0 == g2g_object_ids_cnt) {
+ return 0;
+ }
+
+ return object_topology_get_super_objects(g2g_rt->object_topo, g2g_object_ids, g2g_object_ids_cnt,
+ super_object_ids, super_object_ids_size);
+}
+
+long long object2object_runtime_rule_count(void *g2g_runtime)
+{
+ if (NULL == g2g_runtime) {
+ return 0;
+ }
+
+ struct object2object_runtime *g2g_rt = (struct object2object_runtime *)g2g_runtime;
+ return g2g_rt->rule_num;
+}
+
+long long object2object_runtime_exclude_rule_count(void *g2g_runtime)
+{
+ if (NULL == g2g_runtime) {
+ return 0;
+ }
+
+ struct object2object_runtime *g2g_rt = (struct object2object_runtime *)g2g_runtime;
+ return g2g_rt->excl_rule_num;
+}
+
+long long object2object_runtime_update_err_count(void *g2g_runtime)
+{
+ if (NULL == g2g_runtime) {
+ return 0;
+ }
+
+ struct object2object_runtime *g2g_rt = (struct object2object_runtime *)g2g_runtime;
+ return g2g_rt->update_err_cnt;
+} \ No newline at end of file
diff --git a/src/maat_rule.c b/src/maat_rule.c
index eb30f17..9fec6cc 100644
--- a/src/maat_rule.c
+++ b/src/maat_rule.c
@@ -21,7 +21,7 @@
#include "igraph/igraph.h"
#include "maat_rule.h"
#include "maat_garbage_collection.h"
-#include "maat_group.h"
+#include "maat_object.h"
#include "maat_ex_data.h"
#include "maat_table.h"
#include "alignment.h"
@@ -44,8 +44,8 @@ struct rule_schema {
struct log_handle *logger;
};
-struct group2rule_schema {
- int group_id_column;
+struct object2rule_schema {
+ int object_id_column;
int rule_id_column;
int negate_option_column;
int attribute_name_column;
@@ -62,8 +62,8 @@ struct rule_item {
size_t table_line_len;
};
-struct group2rule_item {
- UT_array *group_ids;
+struct object2rule_item {
+ UT_array *object_ids;
long long rule_id;
int negate_option;
int attribute_id;
@@ -71,7 +71,7 @@ struct group2rule_item {
};
struct condition_query_key {
- long long group_id;
+ long long object_id;
int attribute_id;
int negate_option;
};
@@ -86,17 +86,17 @@ struct table_condition {
int attribute_id;
int actual_condition_num;
UT_array *condition_ids;
- UT_array *group_ids;
+ UT_array *object_ids;
UT_hash_handle hh;
};
-struct table_group {
+struct table_object {
int attribute_id;
- UT_array *group_ids;
+ UT_array *object_ids;
UT_hash_handle hh;
};
-/* rule_runtime and group2rule_runtime share rule_hash_map */
+/* rule_runtime and object2rule_runtime share rule_hash_map */
struct rule_runtime {
struct bool_matcher *bm;
struct rcu_hash_table *cfg_hash; // <rule_id, struct maat_rule>
@@ -112,7 +112,7 @@ struct rule_runtime {
long long update_err_cnt;
};
-struct group2rule_runtime {
+struct object2rule_runtime {
long long not_condition_cnt;
long long rule_num;
long long update_err_cnt;
@@ -121,8 +121,8 @@ struct group2rule_runtime {
};
struct condition_literal {
- long long group_ids[MAX_GROUP_CNT];
- int group_cnt;
+ long long object_ids[MAX_OBJECT_CNT];
+ int object_cnt;
int attribute_id;
};
@@ -152,7 +152,7 @@ struct maat_rule {
struct internal_hit_path {
long long item_id;
- long long group_id;
+ long long object_id;
int Nth_scan;
int attribute_id;
int negate_option; // 1 means negate condition
@@ -173,17 +173,17 @@ struct rule_state {
UT_array *this_scan_hit_conditions;
UT_array *this_scan_hit_not_conditions;
UT_array *exclude_not_conditions;
- UT_array *direct_hit_groups;
- UT_array *indirect_hit_groups;
- UT_array *last_hit_groups;
+ UT_array *direct_hit_objects;
+ UT_array *indirect_hit_objects;
+ UT_array *last_hit_objects;
UT_array *hit_rule_table_ids;
- struct table_group *hit_not_tbl_groups;
+ struct table_object *hit_not_tbl_objects;
};
UT_icd ut_condition_id_icd = {sizeof(long long), NULL, NULL, NULL};
UT_icd ut_condition_literal_icd = {sizeof(struct condition_literal), 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_rule_object_id_icd = {sizeof(long long), NULL, NULL, NULL};
+UT_icd ut_maat_hit_object_icd = {sizeof(struct maat_hit_object), NULL, NULL, NULL};
UT_icd ut_hit_path_icd = {sizeof(struct internal_hit_path), NULL, NULL, NULL};
UT_icd ut_hit_rule_table_id_icd = {sizeof(struct rule2table_id), NULL, NULL, NULL};
@@ -415,10 +415,10 @@ void rule_schema_free(void *rule_schema)
FREE(rule_schema);
}
-void *group2rule_schema_new(cJSON *json, struct table_manager *tbl_mgr,
+void *object2rule_schema_new(cJSON *json, struct table_manager *tbl_mgr,
const char *table_name, struct log_handle *logger)
{
- struct group2rule_schema *g2c_schema = ALLOC(struct group2rule_schema, 1);
+ struct object2rule_schema *g2c_schema = ALLOC(struct object2rule_schema, 1);
cJSON *custom_item = NULL;
cJSON *item = cJSON_GetObjectItem(json, "table_id");
@@ -449,12 +449,12 @@ void *group2rule_schema_new(cJSON *json, struct table_manager *tbl_mgr,
goto error;
}
- custom_item = cJSON_GetObjectItem(item, "group_id");
+ custom_item = cJSON_GetObjectItem(item, "object_id");
if (custom_item != NULL && custom_item->type == cJSON_Number) {
- g2c_schema->group_id_column = custom_item->valueint;
+ g2c_schema->object_id_column = custom_item->valueint;
} else {
log_fatal(logger, MODULE_RULE,
- "[%s:%d] table: <%s> schema has no group_id column",
+ "[%s:%d] table: <%s> schema has no object_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
}
@@ -506,14 +506,14 @@ error:
return NULL;
}
-void group2rule_schema_free(void *g2c_schema)
+void object2rule_schema_free(void *g2c_schema)
{
FREE(g2c_schema);
}
-int group2rule_associated_rule_table_id(void *g2c_schema)
+int object2rule_associated_rule_table_id(void *g2c_schema)
{
- struct group2rule_schema *schema = (struct group2rule_schema *)g2c_schema;
+ struct object2rule_schema *schema = (struct object2rule_schema *)g2c_schema;
return schema->asso_rule_table_id;
}
@@ -609,7 +609,7 @@ void rule_runtime_init(void *rule_runtime, struct maat_runtime *maat_rt)
rule_rt->ref_maat_rt = maat_rt;
}
-void *group2rule_runtime_new(void *g2c_schema, size_t max_thread_num,
+void *object2rule_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 *group2rule_runtime_new(void *g2c_schema, size_t max_thread_num,
return NULL;
}
- struct group2rule_runtime *g2c_rt =
- ALLOC(struct group2rule_runtime, 1);
+ struct object2rule_runtime *g2c_rt =
+ ALLOC(struct object2rule_runtime, 1);
g2c_rt->tbl_not_condition_hash = NULL;
return g2c_rt;
}
-void group2rule_runtime_init(void *g2c_runtime, void *rule_runtime)
+void object2rule_runtime_init(void *g2c_runtime, void *rule_runtime)
{
- struct group2rule_runtime *g2c_rt =
- (struct group2rule_runtime *)g2c_runtime;
+ struct object2rule_runtime *g2c_rt =
+ (struct object2rule_runtime *)g2c_runtime;
g2c_rt->ref_rule_rt = (struct rule_runtime *)rule_runtime;
}
-void group2rule_runtime_free(void *g2c_runtime)
+void object2rule_runtime_free(void *g2c_runtime)
{
if (NULL == g2c_runtime) {
return;
}
- struct group2rule_runtime *g2c_rt =
- (struct group2rule_runtime *)g2c_runtime;
+ struct object2rule_runtime *g2c_rt =
+ (struct object2rule_runtime *)g2c_runtime;
if (g2c_rt->tbl_not_condition_hash != NULL) {
struct table_condition *not_condition = NULL, *tmp_not_condition = NULL;
@@ -671,54 +671,54 @@ static int is_valid_table_name(const char *str)
return 1;
}
-static void group2rule_item_free(struct group2rule_item *g2c_item)
+static void object2rule_item_free(struct object2rule_item *g2c_item)
{
if (NULL == g2c_item) {
return;
}
- if (g2c_item->group_ids != NULL) {
- utarray_free(g2c_item->group_ids);
- g2c_item->group_ids = NULL;
+ if (g2c_item->object_ids != NULL) {
+ utarray_free(g2c_item->object_ids);
+ g2c_item->object_ids = NULL;
}
FREE(g2c_item);
}
-static struct group2rule_item *
-group2rule_item_new(const char *line, struct group2rule_schema *g2c_schema,
+static struct object2rule_item *
+object2rule_item_new(const char *line, struct object2rule_schema *g2c_schema,
const char *table_name, struct log_handle *logger)
{
size_t column_offset = 0;
size_t column_len = 0;
char attribute_name[MAX_NAME_STR_LEN + 1] = {0};
- struct group2rule_item *g2c_item = ALLOC(struct group2rule_item, 1);
- utarray_new(g2c_item->group_ids, &ut_rule_group_id_icd);
+ struct object2rule_item *g2c_item = ALLOC(struct object2rule_item, 1);
+ utarray_new(g2c_item->object_ids, &ut_rule_object_id_icd);
- int ret = get_column_pos(line, g2c_schema->group_id_column, &column_offset,
+ int ret = get_column_pos(line, g2c_schema->object_id_column, &column_offset,
&column_len);
if (ret < 0) {
log_fatal(logger, MODULE_RULE,
- "[%s:%d] g2c table:<%s> has no group_id in line:%s",
+ "[%s:%d] g2c table:<%s> has no object_id in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
}
- char group_ids_str[MAX_GROUP_IDS_STR_LEN] = {0};
- memcpy(group_ids_str, line + column_offset, MIN(MAX_GROUP_IDS_STR_LEN, column_len));
+ char object_ids_str[MAX_OBJECT_IDS_STR_LEN] = {0};
+ memcpy(object_ids_str, line + column_offset, MIN(MAX_OBJECT_IDS_STR_LEN, column_len));
- ret = ids_str2longlong_array(group_ids_str, g2c_item->group_ids);
+ ret = ids_str2longlong_array(object_ids_str, g2c_item->object_ids);
if (ret < 0) {
log_fatal(logger, MODULE_RULE,
- "[%s:%d] g2c table:<%s> group_ids str2longlong failed in line:%s",
+ "[%s:%d] g2c table:<%s> object_ids str2longlong failed in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
}
- if (utarray_len(g2c_item->group_ids) > MAX_GROUP_CNT) {
+ if (utarray_len(g2c_item->object_ids) > MAX_OBJECT_CNT) {
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);
+ "[%s:%d] g2c table:<%s> object_ids exceed maximum:%d in line:%s",
+ __FUNCTION__, __LINE__, table_name, MAX_OBJECT_CNT, line);
goto error;
}
@@ -802,11 +802,11 @@ group2rule_item_new(const char *line, struct group2rule_schema *g2c_schema,
return g2c_item;
error:
- group2rule_item_free(g2c_item);
+ object2rule_item_free(g2c_item);
return NULL;
}
-static inline int compare_group_id(const void *a, const void *b)
+static inline int compare_object_id(const void *a, const void *b)
{
long long ret = *(const long long *)a - *(const long long *)b;
@@ -820,21 +820,21 @@ static inline int compare_group_id(const void *a, const void *b)
}
static void rule_condition_add_literal(struct rule_condition *condition,
- struct group2rule_item *g2c_item)
+ struct object2rule_item *g2c_item)
{
struct condition_literal tmp_literal;
tmp_literal.attribute_id = g2c_item->attribute_id;
- tmp_literal.group_cnt = utarray_len(g2c_item->group_ids);
- utarray_sort(g2c_item->group_ids, compare_group_id);
+ tmp_literal.object_cnt = utarray_len(g2c_item->object_ids);
+ utarray_sort(g2c_item->object_ids, compare_object_id);
- for (size_t i = 0; i < utarray_len(g2c_item->group_ids); i++) {
- tmp_literal.group_ids[i] = *(long long *)utarray_eltptr(g2c_item->group_ids, i);
+ for (size_t i = 0; i < utarray_len(g2c_item->object_ids); i++) {
+ tmp_literal.object_ids[i] = *(long long *)utarray_eltptr(g2c_item->object_ids, i);
}
utarray_push_back(condition->literals, &tmp_literal);
}
void rule_condition_remove_literal(struct rule_condition *condition,
- struct group2rule_item *g2c_item)
+ struct object2rule_item *g2c_item)
{
struct condition_literal *tmp_literal = NULL;
@@ -849,7 +849,7 @@ void rule_condition_remove_literal(struct rule_condition *condition,
}
static int maat_rule_condition_find_literal(struct maat_rule *rule,
- struct group2rule_item *g2c_item)
+ struct object2rule_item *g2c_item)
{
struct rule_condition *condition = rule->conditions + g2c_item->condition_index;
struct condition_literal *tmp_literal = NULL;
@@ -866,7 +866,7 @@ static int maat_rule_condition_find_literal(struct maat_rule *rule,
}
static void maat_rule_condition_add_literal(struct maat_rule *rule,
- struct group2rule_item *g2c_item)
+ struct object2rule_item *g2c_item)
{
struct rule_condition *condition = rule->conditions + g2c_item->condition_index;
@@ -881,7 +881,7 @@ static void maat_rule_condition_add_literal(struct maat_rule *rule,
}
static void maat_rule_condition_remove_literal(struct maat_rule *rule,
- struct group2rule_item *g2c_item)
+ struct object2rule_item *g2c_item)
{
struct rule_condition *condition = rule->conditions + g2c_item->condition_index;
@@ -941,9 +941,9 @@ maat_rule_bool_matcher_new(struct rule_runtime *rule_rt,
struct condition_literal *tmp_cl = NULL;
for(tmp_cl = (struct condition_literal *)utarray_front(iter_rule->conditions[i].literals); tmp_cl !=NULL;
tmp_cl = (struct condition_literal *)utarray_next(iter_rule->conditions[i].literals, tmp_cl)) {
- for (size_t it = 0; it < tmp_cl->group_cnt; it++) {
+ for (size_t it = 0; it < tmp_cl->object_cnt; it++) {
printf("<before bool_matcher_new> rule_rt:%p rule_id:%lld, condition_id:%llu, condition_query_key{%lld: %d, %d}\n",
- rule_rt, iter_rule->rule_id, iter_rule->conditions[i].condition_id, tmp_cl->group_ids[it],
+ rule_rt, iter_rule->rule_id, iter_rule->conditions[i].condition_id, tmp_cl->object_ids[it],
tmp_cl->attribute_id, iter_rule->conditions[i].negate_option);
}
}
@@ -954,7 +954,7 @@ maat_rule_bool_matcher_new(struct rule_runtime *rule_rt,
}
}
- // some rule may have zero groups, e.g. default policy.
+ // some rule may have zero objects, e.g. default policy.
if (j == (size_t)iter_rule->declared_condition_num && j > 0) {
bool_expr_array[expr_cnt].expr_id = iter_rule->rule_id;
bool_expr_array[expr_cnt].user_tag = iter_rule;
@@ -1002,14 +1002,14 @@ static inline int compare_condition_id(const void *a, const void *b)
}
}
-static inline int compare_hit_group(const void *pa, const void *pb)
+static inline int compare_hit_object(const void *pa, const void *pb)
{
- struct maat_hit_group *la=(struct maat_hit_group *)pa;
- struct maat_hit_group *lb=(struct maat_hit_group *)pb;
+ struct maat_hit_object *la=(struct maat_hit_object *)pa;
+ struct maat_hit_object *lb=(struct maat_hit_object *)pb;
long long ret = la->item_id - lb->item_id;
if (0 == ret) {
- ret = la->group_id - lb->group_id;
+ ret = la->object_id - lb->object_id;
if (0 == ret) {
ret = la->attribute_id - lb->attribute_id;
}
@@ -1074,9 +1074,9 @@ build_condition_id_kv_hash(struct rule_runtime *rule_rt, int negate_option)
for (size_t j = 0; j < utarray_len(condition->literals); j++) {
tmp_cl = (struct condition_literal *)utarray_eltptr(condition->literals, j);
- for (size_t k = 0; k < tmp_cl->group_cnt; k++) {
+ for (size_t k = 0; k < tmp_cl->object_cnt; k++) {
struct condition_query_key key =
- {tmp_cl->group_ids[k], tmp_cl->attribute_id, condition->negate_option};
+ {tmp_cl->object_ids[k], tmp_cl->attribute_id, condition->negate_option};
struct condition_id_kv *condition_id_kv = NULL;
HASH_FIND(hh, condition_id_kv_hash, &key, sizeof(struct condition_query_key),
@@ -1268,8 +1268,8 @@ maat_rule_clone(struct maat_rule *rule, int deep_copy)
return new_rule;
}
-static int maat_add_group_to_rule(struct rcu_hash_table *hash_tbl,
- struct group2rule_item *g2c_item,
+static int maat_add_object_to_rule(struct rcu_hash_table *hash_tbl,
+ struct object2rule_item *g2c_item,
struct log_handle *logger)
{
int ret = 0;
@@ -1340,8 +1340,8 @@ static int maat_add_group_to_rule(struct rcu_hash_table *hash_tbl,
return 0;
}
-static int maat_remove_group_from_rule(struct rcu_hash_table *hash_tbl,
- struct group2rule_item *g2c_item,
+static int maat_remove_object_from_rule(struct rcu_hash_table *hash_tbl,
+ struct object2rule_item *g2c_item,
struct log_handle *logger)
{
int ret = 0;
@@ -1429,33 +1429,33 @@ struct rule_state *rule_state_new(void)
utarray_new(rule_state->this_scan_hit_conditions, &ut_condition_id_icd);
utarray_new(rule_state->this_scan_hit_not_conditions, &ut_condition_id_icd);
utarray_new(rule_state->exclude_not_conditions, &ut_condition_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->direct_hit_objects, &ut_maat_hit_object_icd);
+ utarray_new(rule_state->indirect_hit_objects, &ut_maat_hit_object_icd);
+ utarray_new(rule_state->last_hit_objects, &ut_maat_hit_object_icd);
utarray_new(rule_state->hit_rule_table_ids, &ut_hit_rule_table_id_icd);
- rule_state->hit_not_tbl_groups = NULL;
+ rule_state->hit_not_tbl_objects = NULL;
return rule_state;
}
static long long
-rule_state_hit_not_tbl_groups_free(struct rule_state *rule_state)
+rule_state_hit_not_tbl_objects_free(struct rule_state *rule_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, rule_state->hit_not_tbl_groups, tbl_group, tmp_tbl_group) {
+ struct table_object *tbl_object = NULL, *tmp_tbl_object = NULL;
+ HASH_ITER(hh, rule_state->hit_not_tbl_objects, tbl_object, tmp_tbl_object) {
free_bytes +=
- (sizeof(tbl_group) + utarray_len(tbl_group->group_ids) * sizeof(long long));
- 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;
+ (sizeof(tbl_object) + utarray_len(tbl_object->object_ids) * sizeof(long long));
+ HASH_DEL(rule_state->hit_not_tbl_objects, tbl_object);
+ if (tbl_object->object_ids != NULL) {
+ utarray_free(tbl_object->object_ids);
+ tbl_object->object_ids = NULL;
}
- FREE(tbl_group);
+ FREE(tbl_object);
}
return free_bytes;
@@ -1476,14 +1476,14 @@ void rule_state_reset(struct rule_state *rule_state)
utarray_clear(rule_state->this_scan_hit_conditions);
utarray_clear(rule_state->this_scan_hit_not_conditions);
utarray_clear(rule_state->exclude_not_conditions);
- 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->direct_hit_objects);
+ utarray_clear(rule_state->indirect_hit_objects);
+ utarray_clear(rule_state->last_hit_objects);
utarray_clear(rule_state->hit_rule_table_ids);
- struct table_group *tbl_group = NULL, *tmp_tbl_group = NULL;
- HASH_ITER(hh, rule_state->hit_not_tbl_groups, tbl_group, tmp_tbl_group) {
- utarray_clear(tbl_group->group_ids);
+ struct table_object *tbl_object = NULL, *tmp_tbl_object = NULL;
+ HASH_ITER(hh, rule_state->hit_not_tbl_objects, tbl_object, tmp_tbl_object) {
+ utarray_clear(tbl_object->object_ids);
}
}
@@ -1530,25 +1530,25 @@ void rule_state_free(struct rule_state *rule_state,
rule_state->exclude_not_conditions = NULL;
}
- if (rule_state->direct_hit_groups != NULL) {
- free_bytes += utarray_size(rule_state->direct_hit_groups) *
- sizeof(struct maat_hit_group);
- utarray_free(rule_state->direct_hit_groups);
- rule_state->direct_hit_groups = NULL;
+ if (rule_state->direct_hit_objects != NULL) {
+ free_bytes += utarray_size(rule_state->direct_hit_objects) *
+ sizeof(struct maat_hit_object);
+ utarray_free(rule_state->direct_hit_objects);
+ rule_state->direct_hit_objects = NULL;
}
- if (rule_state->indirect_hit_groups != NULL) {
- free_bytes += utarray_size(rule_state->indirect_hit_groups) *
- sizeof(struct maat_hit_group);
- utarray_free(rule_state->indirect_hit_groups);
- rule_state->indirect_hit_groups = NULL;
+ if (rule_state->indirect_hit_objects != NULL) {
+ free_bytes += utarray_size(rule_state->indirect_hit_objects) *
+ sizeof(struct maat_hit_object);
+ utarray_free(rule_state->indirect_hit_objects);
+ rule_state->indirect_hit_objects = NULL;
}
- if (rule_state->last_hit_groups != NULL) {
- free_bytes += utarray_size(rule_state->last_hit_groups) *
- sizeof(struct maat_hit_group);
- utarray_free(rule_state->last_hit_groups);
- rule_state->last_hit_groups = NULL;
+ if (rule_state->last_hit_objects != NULL) {
+ free_bytes += utarray_size(rule_state->last_hit_objects) *
+ sizeof(struct maat_hit_object);
+ utarray_free(rule_state->last_hit_objects);
+ rule_state->last_hit_objects = NULL;
}
if (rule_state->hit_rule_table_ids != NULL) {
@@ -1558,7 +1558,7 @@ void rule_state_free(struct rule_state *rule_state,
rule_state->hit_rule_table_ids = NULL;
}
- free_bytes += rule_state_hit_not_tbl_groups_free(rule_state);
+ free_bytes += rule_state_hit_not_tbl_objects_free(rule_state);
FREE(rule_state);
@@ -1569,7 +1569,7 @@ void rule_state_free(struct rule_state *rule_state,
static void
rule_state_add_internal_hit_path(struct rule_state *rule_state,
- long long item_id, long long group_id,
+ long long item_id, long long object_id,
int attribute_id, int negate_option, int Nth_scan)
{
if (NULL == rule_state) {
@@ -1579,7 +1579,7 @@ rule_state_add_internal_hit_path(struct rule_state *rule_state,
struct internal_hit_path new_path;
new_path.item_id = item_id;
new_path.Nth_scan = Nth_scan;
- new_path.group_id = group_id;
+ new_path.object_id = object_id;
new_path.attribute_id = attribute_id;
new_path.negate_option = negate_option;
@@ -1606,10 +1606,10 @@ static int maat_rule_has_condition_query_key(struct maat_rule *rule,
continue;
}
- long long *tmp_group_id = bsearch(&(key->group_id), tmp_cl->group_ids,
- tmp_cl->group_cnt, sizeof(long long),
- compare_group_id);
- if (tmp_group_id != NULL) {
+ long long *tmp_object_id = bsearch(&(key->object_id), tmp_cl->object_ids,
+ tmp_cl->object_cnt, sizeof(long long),
+ compare_object_id);
+ if (tmp_object_id != NULL) {
return 1;
}
}
@@ -1620,7 +1620,7 @@ static int maat_rule_has_condition_query_key(struct maat_rule *rule,
static size_t
maat_rule_get_hit_condition_index(struct maat_rule *rule,
- int attribute_id, long long hit_group_id,
+ int attribute_id, long long hit_object_id,
int *condition_idx_array, size_t array_size)
{
size_t hit_condition_cnt = 0;
@@ -1639,10 +1639,10 @@ maat_rule_get_hit_condition_index(struct maat_rule *rule,
continue;
}
- long long *tmp_group_id = bsearch(&hit_group_id, tmp_cl->group_ids,
- tmp_cl->group_cnt, sizeof(long long),
- compare_group_id);
- if (tmp_group_id != NULL) {
+ long long *tmp_object_id = bsearch(&hit_object_id, tmp_cl->object_ids,
+ tmp_cl->object_cnt, sizeof(long long),
+ compare_object_id);
+ if (tmp_object_id != NULL) {
condition_idx_array[hit_condition_cnt++] = i;
break;
}
@@ -1676,8 +1676,8 @@ void populate_hit_path_with_rule(struct maat_hit_path *hit_path_array,
size_t new_hit_path_cnt = *n_new_hit_path;
int condition_index_array[MAX_ITEMS_PER_BOOL_EXPR] = {0};
- if (hit_path_array[idx].top_group_id < 0) {
- hit_path_array[idx].top_group_id = hit_path_array[idx].sub_group_id;
+ if (hit_path_array[idx].top_object_id < 0) {
+ hit_path_array[idx].top_object_id = hit_path_array[idx].sub_object_id;
}
struct maat_hit_path tmp_path;
@@ -1686,7 +1686,7 @@ void populate_hit_path_with_rule(struct maat_hit_path *hit_path_array,
// find out which condition in rule hit
n_condition_index =
maat_rule_get_hit_condition_index(rule, hit_path_array[idx].attribute_id,
- hit_path_array[idx].top_group_id,
+ hit_path_array[idx].top_object_id,
condition_index_array,
MAX_ITEMS_PER_BOOL_EXPR);
hit_path_array[idx].condition_index = condition_index_array[0];
@@ -1706,7 +1706,7 @@ void populate_hit_path_with_rule(struct maat_hit_path *hit_path_array,
hit_path_array[n_hit_path + new_hit_path_cnt] = tmp_path;
new_hit_path_cnt++;
n_condition_index =
- maat_rule_get_hit_condition_index(rule, tmp_path.attribute_id, tmp_path.top_group_id,
+ maat_rule_get_hit_condition_index(rule, tmp_path.attribute_id, tmp_path.top_object_id,
condition_index_array, MAX_ITEMS_PER_BOOL_EXPR);
hit_path_array[n_hit_path + new_hit_path_cnt - 1].condition_index = condition_index_array[0];
if (n_condition_index > 1) {
@@ -1754,10 +1754,10 @@ size_t rule_runtime_get_hit_paths(struct rule_runtime *rule_rt, int thread_id,
}
for (size_t j = 0; j < n_hit_path && (n_hit_path + n_new_hit_path) < array_size; j++) {
- if (hit_path_array[j].top_group_id < 0) {
- key.group_id = hit_path_array[j].sub_group_id;
+ if (hit_path_array[j].top_object_id < 0) {
+ key.object_id = hit_path_array[j].sub_object_id;
} else {
- key.group_id = hit_path_array[j].top_group_id;
+ key.object_id = hit_path_array[j].top_object_id;
}
key.attribute_id = hit_path_array[j].attribute_id;
@@ -1773,7 +1773,7 @@ size_t rule_runtime_get_hit_paths(struct rule_runtime *rule_rt, int thread_id,
}
static void
-rule_state_add_direct_hit_groups(struct rule_state *rule_state,
+rule_state_add_direct_hit_objects(struct rule_state *rule_state,
struct maat_item *hit_items,
size_t n_hit_items, int attribute_id)
{
@@ -1781,30 +1781,30 @@ rule_state_add_direct_hit_groups(struct rule_state *rule_state,
return;
}
- struct maat_hit_group hit_group;
+ struct maat_hit_object hit_object;
for (size_t i = 0; i < n_hit_items; i++) {
- hit_group.item_id = hit_items[i].item_id;
- hit_group.group_id = hit_items[i].group_id;
- hit_group.attribute_id = attribute_id;
- utarray_push_back(rule_state->direct_hit_groups, &hit_group);
+ hit_object.item_id = hit_items[i].item_id;
+ hit_object.object_id = hit_items[i].object_id;
+ hit_object.attribute_id = attribute_id;
+ utarray_push_back(rule_state->direct_hit_objects, &hit_object);
}
}
static void
-rule_state_add_indirect_hit_groups(struct rule_state *rule_state,
- long long *group_ids,
- size_t n_group_ids, int attribute_id)
+rule_state_add_indirect_hit_objects(struct rule_state *rule_state,
+ long long *object_ids,
+ size_t n_object_ids, int attribute_id)
{
- if (NULL == rule_state || NULL == group_ids) {
+ if (NULL == rule_state || NULL == object_ids) {
return;
}
- struct maat_hit_group hit_group;
- for (size_t i = 0; i < n_group_ids; i++) {
- hit_group.item_id = 0;
- hit_group.group_id = group_ids[i];
- hit_group.attribute_id = attribute_id;
- utarray_push_back(rule_state->indirect_hit_groups, &hit_group);
+ struct maat_hit_object hit_object;
+ for (size_t i = 0; i < n_object_ids; i++) {
+ hit_object.item_id = 0;
+ hit_object.object_id = object_ids[i];
+ hit_object.attribute_id = attribute_id;
+ utarray_push_back(rule_state->indirect_hit_objects, &hit_object);
}
}
@@ -1887,13 +1887,13 @@ rule_state_add_hit_not_conditions(struct rule_state *rule_state,
static void
rule_state_update_hit_conditions(struct rule_state *rule_state,
struct rule_runtime *rule_rt,
- long long group_id, int attribute_id)
+ long long object_id, int attribute_id)
{
if (NULL == rule_state || NULL == rule_rt) {
return;
}
- struct condition_query_key key = {group_id, attribute_id, 0};
+ struct condition_query_key key = {object_id, attribute_id, 0};
struct condition_id_kv *condition_id_kv = NULL;
HASH_FIND(hh, rule_rt->condition_id_kv_hash, &key, sizeof(key), condition_id_kv);
@@ -1909,31 +1909,31 @@ rule_state_update_hit_conditions(struct rule_state *rule_state,
}
static void
-rule_state_cache_hit_not_groups(struct rule_state *rule_state,
+rule_state_cache_hit_not_objects(struct rule_state *rule_state,
struct rule_runtime *rule_rt,
- long long *hit_group_ids,
- size_t n_hit_group_id, int attribute_id)
+ long long *hit_object_ids,
+ size_t n_hit_object_id, int attribute_id)
{
if (NULL == rule_state || NULL == rule_rt) {
return;
}
- if (n_hit_group_id != 0) {
- qsort(hit_group_ids, n_hit_group_id, sizeof(long long), compare_group_id);
+ if (n_hit_object_id != 0) {
+ qsort(hit_object_ids, n_hit_object_id, sizeof(long long), compare_object_id);
}
- struct table_group *tbl_group = NULL;
- HASH_FIND(hh, rule_state->hit_not_tbl_groups, &attribute_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,
- &hit_group_ids[i],
- compare_group_id);
- if (NULL == group_id) {
+ struct table_object *tbl_object = NULL;
+ HASH_FIND(hh, rule_state->hit_not_tbl_objects, &attribute_id, sizeof(int), tbl_object);
+ if (tbl_object != NULL) {
+ for (size_t i = 0; i < n_hit_object_id; i++) {
+ long long *object_id = (long long *)utarray_find(tbl_object->object_ids,
+ &hit_object_ids[i],
+ compare_object_id);
+ if (NULL == object_id) {
continue;
}
- size_t remove_idx = utarray_eltidx(tbl_group->group_ids, group_id);
- utarray_erase(tbl_group->group_ids, remove_idx, 1);
+ size_t remove_idx = utarray_eltidx(tbl_object->object_ids, object_id);
+ utarray_erase(tbl_object->object_ids, remove_idx, 1);
}
}
@@ -1943,28 +1943,28 @@ rule_state_cache_hit_not_groups(struct rule_state *rule_state,
continue;
}
- long long *tmp_group_id =
- bsearch(&(condition_id_kv->key.group_id), hit_group_ids,
- n_hit_group_id, sizeof(long long), compare_group_id);
- if (tmp_group_id != NULL) {
+ long long *tmp_object_id =
+ bsearch(&(condition_id_kv->key.object_id), hit_object_ids,
+ n_hit_object_id, sizeof(long long), compare_object_id);
+ if (tmp_object_id != NULL) {
continue;
}
- if (NULL == tbl_group) {
- tbl_group = ALLOC(struct table_group, 1);
- tbl_group->attribute_id = attribute_id;
- utarray_new(tbl_group->group_ids, &ut_rule_group_id_icd);
- HASH_ADD_INT(rule_state->hit_not_tbl_groups, attribute_id, tbl_group);
+ if (NULL == tbl_object) {
+ tbl_object = ALLOC(struct table_object, 1);
+ tbl_object->attribute_id = attribute_id;
+ utarray_new(tbl_object->object_ids, &ut_rule_object_id_icd);
+ HASH_ADD_INT(rule_state->hit_not_tbl_objects, attribute_id, tbl_object);
}
- if (!utarray_find(tbl_group->group_ids, &(condition_id_kv->key.group_id),
- compare_group_id)) {
- utarray_push_back(tbl_group->group_ids, &(condition_id_kv->key.group_id));
+ if (!utarray_find(tbl_object->object_ids, &(condition_id_kv->key.object_id),
+ compare_object_id)) {
+ utarray_push_back(tbl_object->object_ids, &(condition_id_kv->key.object_id));
}
}
- if (tbl_group != NULL) {
- utarray_sort(tbl_group->group_ids, compare_group_id);
+ if (tbl_object != NULL) {
+ utarray_sort(tbl_object->object_ids, compare_object_id);
}
}
@@ -2009,14 +2009,14 @@ rule_runtime_add_rule(struct rule_runtime *rule_rt,
sizeof(long long));
if (rule != NULL) {
/****************************************************************
- rule found in updating hash(added by group2rule runtime), which means
+ rule found in updating hash(added by object2rule runtime), which means
1. rcu_hash_add(htable, rule) ==> finished
2. rcu_hash_commit(htable) ==> undo
because it's in updating hash, we can modify it directly
******************************************************************/
- /* rule has group2rule_table info, so set rule_table info */
+ /* rule has object2rule_table info, so set rule_table info */
maat_rule_set(rule, table_id, rule_item->declared_condition_num, rule_item);
} else {
// rule neither in effective hash nor in updating hash
@@ -2029,7 +2029,7 @@ rule_runtime_add_rule(struct rule_runtime *rule_rt,
rule = rcu_hash_find(rule_rt->cfg_hash, (char *)&rule_id, sizeof(long long));
if (rule != NULL) {
/********************************************************************************
- rule found in effective hash(added by group2rule runtime), which means
+ rule found in effective hash(added by object2rule runtime), which means
1. rcu_hash_add(htable, rule) ==> finished
2. rcu_hash_commit(htable) ==> finished
@@ -2043,7 +2043,7 @@ rule_runtime_add_rule(struct rule_runtime *rule_rt,
/* delete rule from rcu hash */
rcu_hash_del(rule_rt->cfg_hash, (char *)&rule_id, sizeof(long long));
- /* copy_rule has group2rule_table info, so set rule_table info */
+ /* copy_rule has object2rule_table info, so set rule_table info */
maat_rule_set(copy_rule, table_id, rule_item->declared_condition_num, rule_item);
/* add copy_rule to rcu hash */
rcu_hash_add(rule_rt->cfg_hash, (char *)&rule_id, sizeof(long long), copy_rule);
@@ -2171,7 +2171,7 @@ int rule_runtime_update(void *rule_runtime, void *rule_schema,
return 0;
}
-static int validate_table_not_condition(struct group2rule_runtime *g2c_rt,
+static int validate_table_not_condition(struct object2rule_runtime *g2c_rt,
struct table_manager *tbl_mgr, int table_id,
int is_valid, struct log_handle *logger)
{
@@ -2207,7 +2207,7 @@ static int validate_table_not_condition(struct group2rule_runtime *g2c_rt,
return 0;
}
-int group2rule_runtime_update(void *g2c_runtime, void *g2c_schema,
+int object2rule_runtime_update(void *g2c_runtime, void *g2c_schema,
const char *table_name, const char *line,
int valid_column)
{
@@ -2215,8 +2215,8 @@ int group2rule_runtime_update(void *g2c_runtime, void *g2c_schema,
return -1;
}
- struct group2rule_schema *schema = (struct group2rule_schema *)g2c_schema;
- struct group2rule_runtime *g2c_rt = (struct group2rule_runtime *)g2c_runtime;
+ struct object2rule_schema *schema = (struct object2rule_schema *)g2c_schema;
+ struct object2rule_runtime *g2c_rt = (struct object2rule_runtime *)g2c_runtime;
struct rule_runtime *rule_rt = g2c_rt->ref_rule_rt;
int is_valid = get_column_value(line, valid_column);
@@ -2230,8 +2230,8 @@ int group2rule_runtime_update(void *g2c_runtime, void *g2c_schema,
}
int ret = -1;
- struct group2rule_item *g2c_item =
- group2rule_item_new(line, schema, table_name, rule_rt->logger);
+ struct object2rule_item *g2c_item =
+ object2rule_item_new(line, schema, table_name, rule_rt->logger);
if (NULL == g2c_item) {
g2c_rt->update_err_cnt++;
return -1;
@@ -2251,7 +2251,7 @@ int group2rule_runtime_update(void *g2c_runtime, void *g2c_schema,
if (0 == is_valid) {
//delete
- ret = maat_remove_group_from_rule(rule_rt->cfg_hash, g2c_item,
+ ret = maat_remove_object_from_rule(rule_rt->cfg_hash, g2c_item,
rule_rt->logger);
if (0 == ret) {
if (g2c_item->negate_option) {
@@ -2263,7 +2263,7 @@ int group2rule_runtime_update(void *g2c_runtime, void *g2c_schema,
}
} else {
//add
- ret = maat_add_group_to_rule(rule_rt->cfg_hash, g2c_item,
+ ret = maat_add_object_to_rule(rule_rt->cfg_hash, g2c_item,
rule_rt->logger);
if (0 == ret) {
if (g2c_item->negate_option) {
@@ -2276,42 +2276,42 @@ int group2rule_runtime_update(void *g2c_runtime, void *g2c_schema,
}
next:
- group2rule_item_free(g2c_item);
+ object2rule_item_free(g2c_item);
return ret;
}
-long long group2rule_runtime_not_condition_count(void *g2c_runtime)
+long long object2rule_runtime_not_condition_count(void *g2c_runtime)
{
if (NULL == g2c_runtime) {
return 0;
}
- struct group2rule_runtime *g2c_rt =
- (struct group2rule_runtime *)g2c_runtime;
+ struct object2rule_runtime *g2c_rt =
+ (struct object2rule_runtime *)g2c_runtime;
return g2c_rt->not_condition_cnt;
}
-long long group2rule_runtime_rule_count(void *g2c_runtime)
+long long object2rule_runtime_rule_count(void *g2c_runtime)
{
if (NULL == g2c_runtime) {
return 0;
}
- struct group2rule_runtime *g2c_rt =
- (struct group2rule_runtime *)g2c_runtime;
+ struct object2rule_runtime *g2c_rt =
+ (struct object2rule_runtime *)g2c_runtime;
return g2c_rt->rule_num;
}
-long long group2rule_runtime_update_err_count(void *g2c_runtime)
+long long object2rule_runtime_update_err_count(void *g2c_runtime)
{
if (NULL == g2c_runtime) {
return 0;
}
- struct group2rule_runtime *g2c_rt =
- (struct group2rule_runtime *)g2c_runtime;
+ struct object2rule_runtime *g2c_rt =
+ (struct object2rule_runtime *)g2c_runtime;
return g2c_rt->update_err_cnt;
}
@@ -2483,47 +2483,47 @@ int rule_state_update(struct rule_state *rule_state, struct maat *maat_inst,
{
size_t i = 0, j = 0;
size_t hit_cnt = n_hit_item;
- long long hit_group_ids[MAX_HIT_GROUP_NUM];
- struct maat_hit_group hit_group;
+ long long hit_object_ids[MAX_HIT_OBJECT_NUM];
+ struct maat_hit_object hit_object;
utarray_clear(rule_state->this_scan_hit_conditions);
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;
+ hit_object_ids[i] = hit_items[i].object_id;
- hit_group.item_id = hit_items[i].item_id;
- hit_group.group_id = hit_items[i].group_id;
- hit_group.attribute_id = attribute_id;
- utarray_push_back(rule_state->last_hit_groups, &hit_group);
+ hit_object.item_id = hit_items[i].item_id;
+ hit_object.object_id = hit_items[i].object_id;
+ hit_object.attribute_id = attribute_id;
+ utarray_push_back(rule_state->last_hit_objects, &hit_object);
}
- int g2g_table_id = table_manager_get_group2group_table_id(maat_inst->tbl_mgr);
+ int g2g_table_id = table_manager_get_object2object_table_id(maat_inst->tbl_mgr);
void *g2g_rt = table_manager_get_runtime(maat_inst->tbl_mgr, g2g_table_id);
- long long super_group_ids[MAX_HIT_GROUP_NUM];
- size_t super_group_cnt = group2group_runtime_get_super_groups(g2g_rt, hit_group_ids,
- hit_cnt, super_group_ids,
- MAX_HIT_GROUP_NUM);
- for (i = 0; i < super_group_cnt; i++) {
- hit_group.item_id = 0;
- hit_group.group_id = super_group_ids[i];
- hit_group.attribute_id = attribute_id;
- utarray_push_back(rule_state->last_hit_groups, &hit_group);
+ long long super_object_ids[MAX_HIT_OBJECT_NUM];
+ size_t super_object_cnt = object2object_runtime_get_super_objects(g2g_rt, hit_object_ids,
+ hit_cnt, super_object_ids,
+ MAX_HIT_OBJECT_NUM);
+ for (i = 0; i < super_object_cnt; i++) {
+ hit_object.item_id = 0;
+ hit_object.object_id = super_object_ids[i];
+ hit_object.attribute_id = attribute_id;
+ utarray_push_back(rule_state->last_hit_objects, &hit_object);
}
if (1 == maat_inst->opts.hit_path_on && hit_cnt > 0) {
for (i = 0; i < hit_cnt; i++) {
rule_state_add_internal_hit_path(rule_state, hit_items[i].item_id,
- hit_items[i].group_id, attribute_id, 0, Nth_scan);
+ hit_items[i].object_id, attribute_id, 0, Nth_scan);
}
}
- if (1 == maat_inst->opts.hit_group_on) {
- rule_state_add_direct_hit_groups(rule_state, hit_items, hit_cnt, attribute_id);
- rule_state_add_indirect_hit_groups(rule_state, super_group_ids,
- super_group_cnt, attribute_id);
+ if (1 == maat_inst->opts.hit_object_on) {
+ rule_state_add_direct_hit_objects(rule_state, hit_items, hit_cnt, attribute_id);
+ rule_state_add_indirect_hit_objects(rule_state, super_object_ids,
+ super_object_cnt, attribute_id);
}
/* update hit condition */
@@ -2538,27 +2538,27 @@ int rule_state_update(struct rule_state *rule_state, struct maat *maat_inst,
return 0;
}
- for (j = 0; j < super_group_cnt && hit_cnt < MAX_HIT_GROUP_NUM; j++) {
- hit_group_ids[hit_cnt++] = super_group_ids[j];
+ for (j = 0; j < super_object_cnt && hit_cnt < MAX_HIT_OBJECT_NUM; j++) {
+ hit_object_ids[hit_cnt++] = super_object_ids[j];
}
for (i = 0; i < hit_cnt; i++) {
rule_state_update_hit_conditions(rule_state, rule_rt,
- hit_group_ids[i], attribute_id);
+ hit_object_ids[i], attribute_id);
}
- rule_state_cache_hit_not_groups(rule_state, rule_rt, hit_group_ids,
+ rule_state_cache_hit_not_objects(rule_state, rule_rt, hit_object_ids,
hit_cnt, attribute_id);
return hit_cnt;
}
-void rule_state_clear_last_hit_group(struct rule_state *rule_state)
+void rule_state_clear_last_hit_object(struct rule_state *rule_state)
{
if (NULL == rule_state) {
return;
}
- utarray_clear(rule_state->last_hit_groups);
+ utarray_clear(rule_state->last_hit_objects);
}
void rule_state_not_logic_update(struct rule_state *rule_state,
@@ -2574,16 +2574,16 @@ void rule_state_not_logic_update(struct rule_state *rule_state,
rule_state->Nth_scan = Nth_scan;
utarray_clear(rule_state->this_scan_hit_not_conditions);
- struct table_group *tbl_group = NULL;
- HASH_FIND(hh, rule_state->hit_not_tbl_groups, &attribute_id, sizeof(int), tbl_group);
- if (NULL == tbl_group) {
+ struct table_object *tbl_object = NULL;
+ HASH_FIND(hh, rule_state->hit_not_tbl_objects, &attribute_id, sizeof(int), tbl_object);
+ if (NULL == tbl_object) {
return;
}
struct condition_id_kv *condition_id_kv = NULL;
- for (size_t i = 0; i < utarray_len(tbl_group->group_ids); i++) {
- long long *group_id = utarray_eltptr(tbl_group->group_ids, i);
- struct condition_query_key key = {*group_id, attribute_id, 1};
+ for (size_t i = 0; i < utarray_len(tbl_object->object_ids); i++) {
+ long long *object_id = utarray_eltptr(tbl_object->object_ids, i);
+ struct condition_query_key key = {*object_id, attribute_id, 1};
HASH_FIND(hh, rule_rt->not_condition_id_kv_hash, &key, sizeof(key), condition_id_kv);
if (NULL == condition_id_kv) {
@@ -2592,83 +2592,83 @@ void rule_state_not_logic_update(struct rule_state *rule_state,
rule_state_add_hit_not_conditions(rule_state, condition_id_kv->condition_ids);
if (1 == maat_inst->opts.hit_path_on) {
- rule_state_add_internal_hit_path(rule_state, -1, *group_id,
+ rule_state_add_internal_hit_path(rule_state, -1, *object_id,
attribute_id, 1, Nth_scan);
}
}
}
-size_t rule_state_get_indirect_hit_groups(struct rule_state *rule_state,
- struct maat_hit_group *group_array,
+size_t rule_state_get_indirect_hit_objects(struct rule_state *rule_state,
+ struct maat_hit_object *object_array,
size_t array_size)
{
size_t i = 0;
- struct maat_hit_group *hit_group = NULL;
- for (i = 0; i < utarray_len(rule_state->indirect_hit_groups) && i < array_size; i++) {
- hit_group =
- (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].attribute_id = hit_group->attribute_id;
+ struct maat_hit_object *hit_object = NULL;
+ for (i = 0; i < utarray_len(rule_state->indirect_hit_objects) && i < array_size; i++) {
+ hit_object =
+ (struct maat_hit_object *)utarray_eltptr(rule_state->indirect_hit_objects, i);
+ object_array[i].item_id = hit_object->item_id;
+ object_array[i].object_id = hit_object->object_id;
+ object_array[i].attribute_id = hit_object->attribute_id;
}
- utarray_clear(rule_state->indirect_hit_groups);
+ utarray_clear(rule_state->indirect_hit_objects);
return i;
}
-size_t rule_state_get_indirect_hit_group_cnt(struct rule_state *rule_state)
+size_t rule_state_get_indirect_hit_object_cnt(struct rule_state *rule_state)
{
- return utarray_len(rule_state->indirect_hit_groups);
+ return utarray_len(rule_state->indirect_hit_objects);
}
-size_t rule_state_get_last_hit_groups(struct rule_state *rule_state,
- struct maat_hit_group *group_array,
+size_t rule_state_get_last_hit_objects(struct rule_state *rule_state,
+ struct maat_hit_object *object_array,
size_t array_size)
{
size_t i = 0;
- for (i = 0; i < utarray_len(rule_state->last_hit_groups) && i < array_size; i++) {
- group_array[i] =
- *(struct maat_hit_group *)utarray_eltptr(rule_state->last_hit_groups, i);
+ for (i = 0; i < utarray_len(rule_state->last_hit_objects) && i < array_size; i++) {
+ object_array[i] =
+ *(struct maat_hit_object *)utarray_eltptr(rule_state->last_hit_objects, i);
}
return i;
}
-size_t rule_state_get_last_hit_group_cnt(struct rule_state *rule_state)
+size_t rule_state_get_last_hit_object_cnt(struct rule_state *rule_state)
{
- return utarray_len(rule_state->last_hit_groups);
+ return utarray_len(rule_state->last_hit_objects);
}
-size_t rule_state_get_direct_hit_groups(struct rule_state *rule_state,
- struct maat_hit_group *group_array,
+size_t rule_state_get_direct_hit_objects(struct rule_state *rule_state,
+ struct maat_hit_object *object_array,
size_t array_size)
{
- UT_array *direct_hit_group = rule_state->direct_hit_groups;
+ UT_array *direct_hit_object = rule_state->direct_hit_objects;
size_t i = 0;
- struct maat_hit_group *group = NULL;
- for (i = 0; i < utarray_len(direct_hit_group) && i < array_size; i++) {
- group = (struct maat_hit_group *)utarray_eltptr(direct_hit_group, i);
- group_array[i].item_id = group->item_id;
- group_array[i].group_id = group->group_id;
- group_array[i].attribute_id = group->attribute_id;
+ struct maat_hit_object *object = NULL;
+ for (i = 0; i < utarray_len(direct_hit_object) && i < array_size; i++) {
+ object = (struct maat_hit_object *)utarray_eltptr(direct_hit_object, i);
+ object_array[i].item_id = object->item_id;
+ object_array[i].object_id = object->object_id;
+ object_array[i].attribute_id = object->attribute_id;
}
- utarray_clear(rule_state->direct_hit_groups);
+ utarray_clear(rule_state->direct_hit_objects);
return i;
}
-size_t rule_state_get_direct_hit_group_cnt(struct rule_state *rule_state)
+size_t rule_state_get_direct_hit_object_cnt(struct rule_state *rule_state)
{
- return utarray_len(rule_state->direct_hit_groups);
+ return utarray_len(rule_state->direct_hit_objects);
}
size_t rule_state_get_internal_hit_paths(struct rule_state *rule_state,
struct rule_runtime *rule_rt,
- struct group2group_runtime *g2g_rt,
+ struct object2object_runtime *g2g_rt,
struct maat_hit_path *hit_path_array,
size_t array_size)
{
@@ -2681,37 +2681,37 @@ size_t rule_state_get_internal_hit_paths(struct rule_state *rule_state,
/*
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_rule_group_id_icd);
-
- size_t super_group_cnt =
- group2group_runtime_get_super_groups(g2g_rt, &(internal_path->group_id), 1,
- super_group_ids, MAX_HIT_GROUP_NUM);
- for (size_t idx = 0; idx < super_group_cnt; idx++) {
- utarray_push_back(valid_super_group_ids, &super_group_ids[idx]);
+ long long super_object_ids[MAX_HIT_OBJECT_NUM];
+ UT_array *valid_super_object_ids;
+ utarray_new(valid_super_object_ids, &ut_rule_object_id_icd);
+
+ size_t super_object_cnt =
+ object2object_runtime_get_super_objects(g2g_rt, &(internal_path->object_id), 1,
+ super_object_ids, MAX_HIT_OBJECT_NUM);
+ for (size_t idx = 0; idx < super_object_cnt; idx++) {
+ utarray_push_back(valid_super_object_ids, &super_object_ids[idx]);
}
/*
- internal_path->group_id can be referenced directly by rule,
- so add it to hit_path which super_group_ids is -1
+ internal_path->object_id can be referenced directly by rule,
+ so add it to hit_path which super_object_ids is -1
------------------------------------------------------------------------------
NOTE: Add the hit path as long as the item is hit
*/
- long long super_group_id = -1;
- utarray_push_back(valid_super_group_ids, &super_group_id);
+ long long super_object_id = -1;
+ utarray_push_back(valid_super_object_ids, &super_object_id);
long long *p = NULL;
struct maat_hit_path tmp_path;
- for (p = utarray_front(valid_super_group_ids);
+ for (p = utarray_front(valid_super_object_ids);
p != NULL && hit_path_cnt < array_size;
- p = utarray_next(valid_super_group_ids, p)) {
+ p = utarray_next(valid_super_object_ids, p)) {
memset(&tmp_path, 0, sizeof(tmp_path));
tmp_path.Nth_scan = internal_path->Nth_scan;
tmp_path.item_id = internal_path->item_id;
- tmp_path.sub_group_id = internal_path->group_id;
- tmp_path.top_group_id = *p;
+ tmp_path.sub_object_id = internal_path->object_id;
+ tmp_path.top_object_id = *p;
tmp_path.attribute_id = internal_path->attribute_id;
tmp_path.negate_option = internal_path->negate_option;
tmp_path.condition_index = -1;
@@ -2729,7 +2729,7 @@ size_t rule_state_get_internal_hit_paths(struct rule_state *rule_state,
hit_path_array[hit_path_cnt] = tmp_path;
hit_path_cnt++;
}
- utarray_free(valid_super_group_ids);
+ utarray_free(valid_super_object_ids);
}
return hit_path_cnt;
diff --git a/src/maat_stat.c b/src/maat_stat.c
index 7a30c44..13db5d9 100644
--- a/src/maat_stat.c
+++ b/src/maat_stat.c
@@ -17,7 +17,7 @@
#include "alignment.h"
#include "maat_ip.h"
#include "maat_rule.h"
-#include "maat_group.h"
+#include "maat_object.h"
#include "maat_plugin.h"
#include "maat_expr.h"
@@ -30,7 +30,7 @@ enum MAAT_FS_STATUS {
STATUS_PLUGIN_CACHE_NUM,
STATUS_PLUGIN_ACC_NUM,
STATUS_CONDITION_REF_NOT_NUM,
- STATUS_GROUP_REF_EXCL_NUM, //group reference exclude group num
+ STATUS_OBJECT_REF_EXCL_NUM, //object reference exclude object num
STATUS_HIT_RULE_NUM,
STATUS_MAAT_STATE_NUM,
STATUS_MAAT_PER_STATE_MEM,
@@ -78,7 +78,7 @@ static void fs_global_metric_register(struct maat_stat *stat)
stat->g_metric_id[STATUS_CONDITION_REF_NOT_NUM] =
fieldstat_easy_register_counter(stat->fs_handle, "NOT_condition_num");
- stat->g_metric_id[STATUS_GROUP_REF_EXCL_NUM] =
+ stat->g_metric_id[STATUS_OBJECT_REF_EXCL_NUM] =
fieldstat_easy_register_counter(stat->fs_handle, "excl_grp");
stat->g_metric_id[STATUS_GARBAGE_QUEUE_LEN] =
@@ -272,11 +272,11 @@ 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_GROUP2RULE:
- g2c_not_condition_num += group2rule_runtime_not_condition_count(runtime);
+ case TABLE_TYPE_OBJECT2RULE:
+ g2c_not_condition_num += object2rule_runtime_not_condition_count(runtime);
break;
- case TABLE_TYPE_GROUP2GROUP:
- g2g_excl_rule_num += group2group_runtime_exclude_rule_count(runtime);
+ case TABLE_TYPE_OBJECT2OBJECT:
+ g2g_excl_rule_num += object2object_runtime_exclude_rule_count(runtime);
break;
case TABLE_TYPE_EXPR:
case TABLE_TYPE_EXPR_PLUS:
@@ -419,7 +419,7 @@ static void fs_table_row_refresh(struct maat_stat *stat, int perf_on)
NULL, 0, g2c_not_condition_num);
fieldstat_easy_counter_set(stat->fs_handle, 0,
- stat->g_metric_id[STATUS_GROUP_REF_EXCL_NUM],
+ stat->g_metric_id[STATUS_OBJECT_REF_EXCL_NUM],
NULL, 0, g2g_excl_rule_num);
}
diff --git a/src/maat_table.c b/src/maat_table.c
index 52b5686..7de74b0 100644
--- a/src/maat_table.c
+++ b/src/maat_table.c
@@ -19,7 +19,7 @@
#include "maat_expr.h"
#include "maat_ip.h"
#include "maat_rule.h"
-#include "maat_group.h"
+#include "maat_object.h"
#include "maat_flag.h"
#include "maat_plugin.h"
#include "maat_ip_plugin.h"
@@ -289,26 +289,26 @@ struct table_operations table_ops[TABLE_TYPE_MAX] = {
.update_err_count = rule_runtime_update_err_count
},
{
- .type = TABLE_TYPE_GROUP2GROUP,
- .new_schema = group2group_schema_new,
- .free_schema = group2group_schema_free,
- .new_runtime = group2group_runtime_new,
- .free_runtime = group2group_runtime_free,
- .update_runtime = group2group_runtime_update,
- .commit_runtime = group2group_runtime_commit,
- .rule_count = group2group_runtime_rule_count,
- .update_err_count = group2group_runtime_update_err_count
+ .type = TABLE_TYPE_OBJECT2OBJECT,
+ .new_schema = object2object_schema_new,
+ .free_schema = object2object_schema_free,
+ .new_runtime = object2object_runtime_new,
+ .free_runtime = object2object_runtime_free,
+ .update_runtime = object2object_runtime_update,
+ .commit_runtime = object2object_runtime_commit,
+ .rule_count = object2object_runtime_rule_count,
+ .update_err_count = object2object_runtime_update_err_count
},
{
- .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,
+ .type = TABLE_TYPE_OBJECT2RULE,
+ .new_schema = object2rule_schema_new,
+ .free_schema = object2rule_schema_free,
+ .new_runtime = object2rule_runtime_new,
+ .free_runtime = object2rule_runtime_free,
+ .update_runtime = object2rule_runtime_update,
.commit_runtime = NULL,
- .rule_count = group2rule_runtime_rule_count,
- .update_err_count = group2rule_runtime_update_err_count
+ .rule_count = object2rule_runtime_rule_count,
+ .update_err_count = object2rule_runtime_update_err_count
}
};
@@ -500,8 +500,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, "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, "object2rule", TABLE_TYPE_OBJECT2RULE);
+ maat_kv_register(reserved_word_map, "object2object", TABLE_TYPE_OBJECT2OBJECT);
maat_kv_register(reserved_word_map, "flag", TABLE_TYPE_FLAG);
maat_kv_register(reserved_word_map, "flag_plus", TABLE_TYPE_FLAG_PLUS);
maat_kv_register(reserved_word_map, "expr", TABLE_TYPE_EXPR);
@@ -905,7 +905,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
}
}
- if (maat_tbl->table_type == TABLE_TYPE_GROUP2GROUP) {
+ if (maat_tbl->table_type == TABLE_TYPE_OBJECT2OBJECT) {
g2g_table_id = maat_tbl->table_id;
}
@@ -930,7 +930,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
tbl_mgr->g2g_table_id = g2g_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);
+ log_info(logger, MODULE_TABLE, "object2object table id: %d", g2g_table_id);
next:
FREE(json_buff);
maat_kv_store_free(reserved_word_map);
@@ -990,18 +990,18 @@ int table_manager_runtime_create(struct table_manager *tbl_mgr, size_t max_threa
garbage_bin, tbl_mgr->logger);
}
- /* group2rule runtime depends on associated rule runtime,
+ /* object2rule 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_GROUP2RULE) {
+ if (table_type != TABLE_TYPE_OBJECT2RULE) {
continue;
}
void *schema = table_manager_get_schema(tbl_mgr, i);
if (NULL == schema) {
log_fatal(tbl_mgr->logger, MODULE_TABLE,
- "[%s:%d] group2rule table(table_id:%d) schema is null",
+ "[%s:%d] object2rule 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_rule_table_id = group2rule_associated_rule_table_id(schema);
+ int asso_rule_table_id = object2rule_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);
+ object2rule_runtime_init(g2c_updating_rt, rule_updating_rt);
}
return 0;
@@ -1163,7 +1163,7 @@ int table_manager_get_default_rule_table_id(struct table_manager *tbl_mgr)
return tbl_mgr->default_rule_table_id;
}
-int table_manager_get_group2group_table_id(struct table_manager *tbl_mgr)
+int table_manager_get_object2object_table_id(struct table_manager *tbl_mgr)
{
if (NULL == tbl_mgr) {
return -1;
diff --git a/src/maat_utils.c b/src/maat_utils.c
index e3aca86..feaa351 100644
--- a/src/maat_utils.c
+++ b/src/maat_utils.c
@@ -603,8 +603,8 @@ int ids_str2longlong_array(const char *ids_str, UT_array *ids_array)
subtoken = strtok_r(str, seps, &saveptr);
if (subtoken == NULL)
break;
- long long group_id = atoll(subtoken);
- utarray_push_back(ids_array, &group_id);
+ long long object_id = atoll(subtoken);
+ utarray_push_back(ids_array, &object_id);
counter++;
}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 2dd8a2a..0a2c170 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -37,7 +37,7 @@ target_link_libraries(bool_matcher_gtest maat_frame_static gtest_static)
add_executable(maat_ex_data_gtest maat_ex_data_gtest.cpp)
target_link_libraries(maat_ex_data_gtest maat_frame_static gtest_static)
-add_subdirectory(group_nesting)
+add_subdirectory(object_nesting)
add_subdirectory(ipport_plugin)
add_subdirectory(benchmark)
@@ -52,7 +52,7 @@ file(COPY tsgrule DESTINATION ./)
file(COPY testdata DESTINATION ./)
file(COPY test_streamfiles DESTINATION ./)
file(COPY json_update DESTINATION ./)
-file(COPY group_nesting DESTINATION ./)
+file(COPY object_nesting DESTINATION ./)
file(COPY ipport_plugin DESTINATION ./)
file(COPY benchmark DESTINATION ./)
diff --git a/test/benchmark/benchmark_gtest.cpp b/test/benchmark/benchmark_gtest.cpp
index 1ddfe71..a9fbe81 100644
--- a/test/benchmark/benchmark_gtest.cpp
+++ b/test/benchmark/benchmark_gtest.cpp
@@ -137,7 +137,7 @@ void generate_rule_sample(const char *table_name, int sample_count)
fclose(fp);
}
-void generate_group2rule_sample(const char *table_name, const char *attribute_name,
+void generate_object2rule_sample(const char *table_name, const char *attribute_name,
int sample_count)
{
FILE *fp = fopen(table_name, "w+");
@@ -527,11 +527,11 @@ protected:
}
fprintf(fp, "REGEX_100\t100\t./regex_rules/REGEX_100\n");
fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF\t10\t./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_100", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "REGEX_100", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -623,7 +623,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("./RULE_PERF");
- system_cmd_rmdir("./GROUP2RULE_PERF");
+ system_cmd_rmdir("./OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -694,11 +694,11 @@ protected:
}
fprintf(fp, "REGEX_200\t200\t./regex_rules/REGEX_200\n");
fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF\t10\t./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_200", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "REGEX_200", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -790,7 +790,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("./RULE_PERF");
- system_cmd_rmdir("./GROUP2RULE_PERF");
+ system_cmd_rmdir("./OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -861,11 +861,11 @@ protected:
}
fprintf(fp, "REGEX_300\t300\t./regex_rules/REGEX_300\n");
fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF\t10\t./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_300", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "REGEX_300", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -957,7 +957,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("./RULE_PERF");
- system_cmd_rmdir("./GROUP2RULE_PERF");
+ system_cmd_rmdir("./OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -1028,11 +1028,11 @@ protected:
}
fprintf(fp, "REGEX_500\t500\t./regex_rules/REGEX_500\n");
fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF\t10\t./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_500", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "REGEX_500", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -1124,7 +1124,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("./RULE_PERF");
- system_cmd_rmdir("./GROUP2RULE_PERF");
+ system_cmd_rmdir("./OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -1195,11 +1195,11 @@ protected:
}
fprintf(fp, "REGEX_1K\t1000\t./regex_rules/REGEX_1K\n");
fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF\t10\t./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_1K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "REGEX_1K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -1291,7 +1291,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("./RULE_PERF");
- system_cmd_rmdir("./GROUP2RULE_PERF");
+ system_cmd_rmdir("./OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -1362,11 +1362,11 @@ protected:
}
fprintf(fp, "REGEX_2K\t2000\t./regex_rules/REGEX_2K\n");
fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF\t10\t./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_2K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "REGEX_2K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -1458,7 +1458,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("./RULE_PERF");
- system_cmd_rmdir("./GROUP2RULE_PERF");
+ system_cmd_rmdir("./OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -1529,11 +1529,11 @@ protected:
}
fprintf(fp, "REGEX_3K\t3000\t./regex_rules/REGEX_3K\n");
fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF\t10\t./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_3K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "REGEX_3K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -1625,7 +1625,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -1696,11 +1696,11 @@ protected:
}
fprintf(fp, "REGEX_5K\t5000\t./regex_rules/REGEX_5K\n");
fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF\t10\t./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_5K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "REGEX_5K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -1792,7 +1792,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -1863,11 +1863,11 @@ protected:
}
fprintf(fp, "REGEX_10K\t10000\t./regex_rules/REGEX_10K\n");
fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF\t10\t./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_10K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "REGEX_10K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -1959,7 +1959,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -2030,11 +2030,11 @@ protected:
}
fprintf(fp, "REGEX_15K\t15000\t./regex_rules/REGEX_15K\n");
fprintf(fp, "RULE_PERF\t10\t./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF\t10\t./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF\t10\t./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "REGEX_15K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "REGEX_15K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -2126,7 +2126,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -2198,11 +2198,11 @@ protected:
}
fprintf(fp, "EXPR_LITERAL_1K 1000 ./EXPR_LITERAL_1K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_1K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "EXPR_LITERAL_1K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -2294,7 +2294,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -2366,11 +2366,11 @@ protected:
}
fprintf(fp, "EXPR_LITERAL_5K 5000 ./EXPR_LITERAL_5K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_5K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "EXPR_LITERAL_5K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -2462,7 +2462,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -2534,11 +2534,11 @@ protected:
}
fprintf(fp, "EXPR_LITERAL_10K 10000 ./EXPR_LITERAL_10K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_10K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "EXPR_LITERAL_10K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -2630,7 +2630,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -2702,11 +2702,11 @@ protected:
}
fprintf(fp, "EXPR_LITERAL_50K 50000 ./EXPR_LITERAL_50K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_50K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "EXPR_LITERAL_50K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -2798,7 +2798,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -2870,11 +2870,11 @@ protected:
}
fprintf(fp, "EXPR_LITERAL_100K 100000 ./EXPR_LITERAL_100K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_100K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "EXPR_LITERAL_100K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -2966,7 +2966,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -3038,11 +3038,11 @@ protected:
}
fprintf(fp, "EXPR_LITERAL_500K 500000 ./EXPR_LITERAL_500K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_500K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "EXPR_LITERAL_500K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -3134,7 +3134,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -3206,11 +3206,11 @@ protected:
}
fprintf(fp, "EXPR_LITERAL_1M 1000000 ./EXPR_LITERAL_1M\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_1M", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "EXPR_LITERAL_1M", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -3302,7 +3302,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -3374,11 +3374,11 @@ protected:
}
fprintf(fp, "EXPR_LITERAL_2M 2000000 ./EXPR_LITERAL_2M\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "EXPR_LITERAL_2M", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "EXPR_LITERAL_2M", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -3470,7 +3470,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -3542,11 +3542,11 @@ protected:
}
fprintf(fp, "STREAM_1K 1000 ./STREAM_1K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_1K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "STREAM_1K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -3635,7 +3635,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -3704,11 +3704,11 @@ protected:
}
fprintf(fp, "STREAM_5K 5000 ./STREAM_5K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_5K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "STREAM_5K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -3797,7 +3797,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -3866,11 +3866,11 @@ protected:
}
fprintf(fp, "STREAM_10K 10000 ./STREAM_10K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_10K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "STREAM_10K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -3959,7 +3959,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -4028,11 +4028,11 @@ protected:
}
fprintf(fp, "STREAM_50K 50000 ./STREAM_50K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_50K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "STREAM_50K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -4121,7 +4121,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -4190,11 +4190,11 @@ protected:
}
fprintf(fp, "STREAM_100K 100000 ./STREAM_100K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_100K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "STREAM_100K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -4283,7 +4283,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -4352,11 +4352,11 @@ protected:
}
fprintf(fp, "STREAM_500K 500000 ./STREAM_500K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_500K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "STREAM_500K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -4445,7 +4445,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -4514,11 +4514,11 @@ protected:
}
fprintf(fp, "STREAM_1M 1000000 ./STREAM_1M\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_1M", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "STREAM_1M", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -4607,7 +4607,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -4676,11 +4676,11 @@ protected:
}
fprintf(fp, "STREAM_2M 2000000 ./STREAM_2M\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "STREAM_2M", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "STREAM_2M", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -4769,7 +4769,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -4838,11 +4838,11 @@ protected:
}
fprintf(fp, "IP_1K 1000 ./IP_1K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "IP_1K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "IP_1K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -4856,7 +4856,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -4928,11 +4928,11 @@ protected:
}
fprintf(fp, "IP_5K 5000 ./IP_5K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "IP_5K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "IP_5K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -4946,7 +4946,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -5018,11 +5018,11 @@ protected:
}
fprintf(fp, "IP_10K 10000 ./IP_10K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "IP_10K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "IP_10K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5036,7 +5036,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -5108,11 +5108,11 @@ protected:
}
fprintf(fp, "IP_50K 50000 ./IP_50K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "IP_50K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "IP_50K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5126,7 +5126,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -5198,11 +5198,11 @@ protected:
}
fprintf(fp, "IP_100K 100000 ./IP_100K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "IP_100K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "IP_100K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5216,7 +5216,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -5288,11 +5288,11 @@ protected:
}
fprintf(fp, "IP_500K 500000 ./IP_500K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "IP_500K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "IP_500K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5306,7 +5306,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -5378,11 +5378,11 @@ protected:
}
fprintf(fp, "IP_1M 1000000 ./IP_1M\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "IP_1M", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "IP_1M", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5396,7 +5396,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -5468,11 +5468,11 @@ protected:
}
fprintf(fp, "IP_5M 5000000 ./IP_5M\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "IP_5M", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "IP_5M", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5486,7 +5486,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -5558,11 +5558,11 @@ protected:
}
fprintf(fp, "IP_10M 10000000 ./IP_10M\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "IP_10M", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "IP_10M", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5576,7 +5576,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -5648,11 +5648,11 @@ protected:
}
fprintf(fp, "INTEGER_1K 1000 ./INTEGER_1K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "INTEGER_1K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "INTEGER_1K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5666,7 +5666,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -5738,11 +5738,11 @@ protected:
}
fprintf(fp, "INTEGER_5K 5000 ./INTEGER_5K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "INTEGER_5K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "INTEGER_5K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5756,7 +5756,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -5828,11 +5828,11 @@ protected:
}
fprintf(fp, "INTEGER_10K 10000 ./INTEGER_10K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "INTEGER_10K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "INTEGER_10K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5846,7 +5846,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -5918,11 +5918,11 @@ protected:
}
fprintf(fp, "FLAG_1K 1000 ./FLAG_1K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "FLAG_1K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "FLAG_1K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -5936,7 +5936,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -6008,11 +6008,11 @@ protected:
}
fprintf(fp, "FLAG_5K 5000 ./FLAG_5K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "FLAG_5K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "FLAG_5K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -6026,7 +6026,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
@@ -6098,11 +6098,11 @@ protected:
}
fprintf(fp, "FLAG_10K 10000 ./FLAG_10K\n");
fprintf(fp, "RULE_PERF 10 ./RULE_PERF\n");
- fprintf(fp, "GROUP2RULE_PERF 10 ./GROUP2RULE_PERF\n");
+ fprintf(fp, "OBJECT2RULE_PERF 10 ./OBJECT2RULE_PERF\n");
fclose(fp);
generate_rule_sample("RULE_PERF", 10);
- generate_group2rule_sample("GROUP2RULE_PERF", "FLAG_10K", 10);
+ generate_object2rule_sample("OBJECT2RULE_PERF", "FLAG_10K", 10);
struct maat_options *opts = maat_options_new();
maat_options_set_logger(opts, "./benchmark_gtest.log", LOG_LEVEL_INFO);
@@ -6116,7 +6116,7 @@ protected:
maat_free(_shared_maat_inst);
log_handle_destroy(logger);
system_cmd_rmdir("RULE_PERF");
- system_cmd_rmdir("GROUP2RULE_PERF");
+ system_cmd_rmdir("OBJECT2RULE_PERF");
}
static struct log_handle *logger;
diff --git a/test/benchmark/benchmark_table_info.conf b/test/benchmark/benchmark_table_info.conf
index 5601996..ad60009 100644
--- a/test/benchmark/benchmark_table_info.conf
+++ b/test/benchmark/benchmark_table_info.conf
@@ -6,7 +6,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -20,7 +20,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -34,7 +34,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -48,7 +48,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -62,7 +62,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -76,7 +76,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -90,7 +90,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -104,7 +104,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -118,7 +118,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -132,7 +132,7 @@
"valid_column":11,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"addr_type":3,
"addr_format":4,
"ip1":5,
@@ -150,7 +150,7 @@
"valid_column":11,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"addr_type":3,
"addr_format":4,
"ip1":5,
@@ -168,7 +168,7 @@
"valid_column":11,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"addr_type":3,
"addr_format":4,
"ip1":5,
@@ -186,7 +186,7 @@
"valid_column":11,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"addr_type":3,
"addr_format":4,
"ip1":5,
@@ -204,7 +204,7 @@
"valid_column":11,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"addr_type":3,
"addr_format":4,
"ip1":5,
@@ -222,7 +222,7 @@
"valid_column":11,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"addr_type":3,
"addr_format":4,
"ip1":5,
@@ -240,7 +240,7 @@
"valid_column":11,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"addr_type":3,
"addr_format":4,
"ip1":5,
@@ -258,7 +258,7 @@
"valid_column":11,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"addr_type":3,
"addr_format":4,
"ip1":5,
@@ -276,7 +276,7 @@
"valid_column":11,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"addr_type":3,
"addr_format":4,
"ip1":5,
@@ -294,7 +294,7 @@
"valid_column":11,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"addr_type":3,
"addr_format":4,
"ip1":5,
@@ -312,7 +312,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"low_boundary":3,
"up_boundary":4
}
@@ -324,7 +324,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"low_boundary":3,
"up_boundary":4
}
@@ -336,7 +336,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"low_boundary":3,
"up_boundary":4
}
@@ -348,7 +348,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"low_boundary":3,
"up_boundary":4
}
@@ -360,7 +360,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"low_boundary":3,
"up_boundary":4
}
@@ -372,7 +372,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"flag":3,
"flag_mask":4
}
@@ -384,7 +384,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"flag":3,
"flag_mask":4
}
@@ -396,7 +396,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"flag":3,
"flag_mask":4
}
@@ -408,7 +408,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"flag":3,
"flag_mask":4
}
@@ -420,7 +420,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"flag":3,
"flag_mask":4
}
@@ -432,7 +432,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -446,7 +446,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -460,7 +460,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -474,7 +474,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -488,7 +488,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -502,7 +502,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -516,7 +516,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -530,7 +530,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -544,7 +544,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -565,12 +565,12 @@
},
{
"table_id":40,
- "table_name":"GROUP2RULE_PERF",
- "table_type":"group2rule",
+ "table_name":"OBJECT2RULE_PERF",
+ "table_type":"object2rule",
"associated_rule_table_id":39,
"valid_column":6,
"custom": {
- "group_id":1,
+ "object_id":1,
"rule_id":2,
"negate_option":3,
"attribute_name":4,
@@ -584,7 +584,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -598,7 +598,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -612,7 +612,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -626,7 +626,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -640,7 +640,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -654,7 +654,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -668,7 +668,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -682,7 +682,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -696,7 +696,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -710,7 +710,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
diff --git a/test/file_test_tableinfo.conf b/test/file_test_tableinfo.conf
index c7bfd59..842ba4e 100644
--- a/test/file_test_tableinfo.conf
+++ b/test/file_test_tableinfo.conf
@@ -36,23 +36,23 @@
},
{
"table_id":3,
- "table_name":"NTC_GROUP2GROUP",
- "table_type":"group2group",
+ "table_name":"NTC_OBJECT2OBJECT",
+ "table_type":"object2object",
"valid_column":4,
"custom": {
- "group_id":1,
- "included_sub_group_ids":2,
- "excluded_sub_group_ids":3
+ "object_id":1,
+ "included_sub_object_ids":2,
+ "excluded_sub_object_ids":3
}
},
{
"table_id":4,
- "table_name":"NTC_GROUP2RULE",
- "table_type":"group2rule",
+ "table_name":"NTC_OBJECT2RULE",
+ "table_type":"object2rule",
"associated_rule_table_id":2,
"valid_column":3,
"custom": {
- "group_id":1,
+ "object_id":1,
"rule_id":2,
"negate_option":4,
"attribute_name":5,
@@ -66,7 +66,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"ip":3,
"port":4
}
@@ -78,7 +78,7 @@
"valid_column":4,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"interval":3
}
},
@@ -89,7 +89,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"ip":3,
"port":4
}
@@ -102,7 +102,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -117,7 +117,7 @@
"valid_column":8,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"district":3,
"keywords":4,
"expr_type":5,
@@ -133,7 +133,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -147,7 +147,7 @@
"valid_column":8,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"district":3,
"keywords":4,
"expr_type":5,
@@ -162,7 +162,7 @@
"valid_column":8,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"district":3,
"keywords":4,
"expr_type":5,
@@ -177,7 +177,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
@@ -191,7 +191,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,
diff --git a/test/group_nesting/CMakeLists.txt b/test/group_nesting/CMakeLists.txt
deleted file mode 100644
index 0947ef5..0000000
--- a/test/group_nesting/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-include_directories(${PROJECT_SOURCE_DIR}/src/inc_internal)
-
-add_executable(group_nesting_gtest group_nesting_gtest.cpp)
-target_link_libraries(group_nesting_gtest maat_frame_static gtest_static) \ No newline at end of file
diff --git a/test/group_nesting/group_nesting_L3.conf b/test/group_nesting/group_nesting_L3.conf
deleted file mode 100644
index 0e80d6a..0000000
--- a/test/group_nesting/group_nesting_L3.conf
+++ /dev/null
@@ -1,51 +0,0 @@
-{
- "add_items": [
- {
- "group_id": 5,
- "included_sub_group_ids": "8",
- "excluded_sub_group_ids": "9"
- },
- {
- "group_id": 1,
- "included_sub_group_ids": "6,9",
- "excluded_sub_group_ids": "5"
- },
- {
- "group_id": 6,
- "included_sub_group_ids": "10,11",
- "excluded_sub_group_ids": "7"
- },
- {
- "group_id": 7,
- "included_sub_group_ids": "11,12",
- "excluded_sub_group_ids": "10"
- },
- {
- "group_id": 2,
- "included_sub_group_ids": "7",
- "excluded_sub_group_ids": "6"
- },
- {
- "group_id": 4,
- "included_sub_group_ids": "7",
- "excluded_sub_group_ids": "13"
- },
- {
- "group_id": 3,
- "included_sub_group_ids": "13",
- "excluded_sub_group_ids": "6"
- }
- ],
- "del_items": [
- {
- "group_id": 6,
- "included_sub_group_ids": "null",
- "excluded_sub_group_ids": "7"
- },
- {
- "group_id": 4,
- "included_sub_group_ids": "null",
- "excluded_sub_group_ids": "13"
- }
- ]
-} \ No newline at end of file
diff --git a/test/group_nesting/group_nesting_L4.conf b/test/group_nesting/group_nesting_L4.conf
deleted file mode 100644
index da58a95..0000000
--- a/test/group_nesting/group_nesting_L4.conf
+++ /dev/null
@@ -1,76 +0,0 @@
-{
- "add_items": [
- {
- "group_id": 8,
- "included_sub_group_ids": "14",
- "excluded_sub_group_ids": "15"
- },
- {
- "group_id": 9,
- "included_sub_group_ids": "14,16",
- "excluded_sub_group_ids": "null"
- },
- {
- "group_id": 5,
- "included_sub_group_ids": "8",
- "excluded_sub_group_ids": "9"
- },
- {
- "group_id": 1,
- "included_sub_group_ids": "6,9",
- "excluded_sub_group_ids": "5"
- },
- {
- "group_id": 10,
- "included_sub_group_ids": "16",
- "excluded_sub_group_ids": "null"
- },
- {
- "group_id": 7,
- "included_sub_group_ids": "10,12",
- "excluded_sub_group_ids": "null"
- },
- {
- "group_id": 6,
- "included_sub_group_ids": "7,11",
- "excluded_sub_group_ids": "10"
- },
- {
- "group_id": 11,
- "included_sub_group_ids": "17",
- "excluded_sub_group_ids": "null"
- },
- {
- "group_id": 12,
- "included_sub_group_ids": "17",
- "excluded_sub_group_ids": "null"
- },
- {
- "group_id":13,
- "included_sub_group_ids": "17",
- "excluded_sub_group_ids": "18"
- },
- {
- "group_id": 2,
- "included_sub_group_ids": "7",
- "excluded_sub_group_ids": "6"
- },
- {
- "group_id": 4,
- "included_sub_group_ids": "7",
- "excluded_sub_group_ids": "13"
- },
- {
- "group_id": 3,
- "included_sub_group_ids": "13",
- "excluded_sub_group_ids": "6"
- }
- ],
- "del_items": [
- {
- "group_id": 6,
- "included_sub_group_ids": "null",
- "excluded_sub_group_ids": "10"
- }
- ]
-} \ No newline at end of file
diff --git a/test/group_nesting/group_nesting_exceed.conf b/test/group_nesting/group_nesting_exceed.conf
deleted file mode 100644
index 9af74ba..0000000
--- a/test/group_nesting/group_nesting_exceed.conf
+++ /dev/null
@@ -1,56 +0,0 @@
-{
- "add_items": [
- {
- "group_id": 3,
- "included_sub_group_ids": "6",
- "excluded_sub_group_ids": "7"
- },
- {
- "group_id": 1,
- "included_sub_group_ids": "3,7",
- "excluded_sub_group_ids": "4"
- },
- {
- "group_id": 10,
- "included_sub_group_ids": "13",
- "excluded_sub_group_ids": "null"
- },
- {
- "group_id": 11,
- "included_sub_group_ids": "10",
- "excluded_sub_group_ids": "null"
- },
- {
- "group_id": 8,
- "included_sub_group_ids": "11",
- "excluded_sub_group_ids": "null"
- },
- {
- "group_id": 5,
- "included_sub_group_ids": "8",
- "excluded_sub_group_ids": "null"
- },
- {
- "group_id": 4,
- "included_sub_group_ids": "5",
- "excluded_sub_group_ids": "null"
- },
- {
- "group_id": 12,
- "included_sub_group_ids": "5",
- "excluded_sub_group_ids": "2"
- },
- {
- "group_id": 2,
- "included_sub_group_ids": "4",
- "excluded_sub_group_ids": "null"
- }
- ],
- "del_items": [
- {
- "group_id": 10,
- "included_sub_group_ids": "13",
- "excluded_sub_group_ids": "null"
- }
- ]
-} \ No newline at end of file
diff --git a/test/group_nesting/group_nesting_gtest.cpp b/test/group_nesting/group_nesting_gtest.cpp
deleted file mode 100644
index be19bd2..0000000
--- a/test/group_nesting/group_nesting_gtest.cpp
+++ /dev/null
@@ -1,492 +0,0 @@
-#include "maat.h"
-#include "log/log.h"
-#include "cJSON/cJSON.h"
-#include "maat_core.h"
-#include "uthash/utarray.h"
-#include "maat_utils.h"
-#include "maat_command.h"
-#include "maat_group.h"
-#include <gtest/gtest.h>
-
-#define MODULE_GROUP_NESTING_GTEST module_name_str("maat.group_nesting_gtest")
-
-#define MAX_IDS_STR_LEN 64
-#define MAX_ITEM_NUM 64
-#define WAIT_FOR_EFFECTIVE_S 2
-#define MAX_G2G_SCAN_TIMES (1000 * 1000)
-
-const char *g_table_info_path = "./group_exclude_table_info.conf";
-const char *log_file = "./group_exclude_gtest.log";
-
-struct group_item {
- long long group_id;
- char incl_sub_ids_str[MAX_IDS_STR_LEN];
- char excl_sub_ids_str[MAX_IDS_STR_LEN];
-};
-
-struct group2group_rule {
- size_t n_add_item;
- size_t n_del_item;
- struct group_item add_items[MAX_ITEM_NUM];
- struct group_item del_items[MAX_ITEM_NUM];
-};
-
-UT_icd ut_ex_group_id_icd = {sizeof(long long), NULL, NULL, NULL};
-
-static int
-parse_config_file(const char *filename, struct group2group_rule *rules)
-{
- unsigned char *json_buff = NULL;
- size_t json_buff_size = 0;
-
- int ret = load_file_to_memory(filename, &json_buff, &json_buff_size);
- if (ret < 0) {
- printf("load file:%s to memory failed.\n", filename);
- return -1;
- }
-
- size_t rule_cnt = 0;
- cJSON *items_array = NULL;
- cJSON *root = cJSON_Parse((const char *)json_buff);
- if (NULL == root) {
- printf("Error before: %-200.200s\n", cJSON_GetErrorPtr());
- ret = -1;
- goto next;
- }
-
- items_array = cJSON_GetObjectItem(root, "add_items");
- if (NULL == items_array) {
- printf("Error before: %-200.200s\n", cJSON_GetErrorPtr());
- ret = -1;
- goto next;
- }
-
- rule_cnt = cJSON_GetArraySize(items_array);
- for (size_t i = 0; i < rule_cnt; i++) {
- cJSON *item_obj = cJSON_GetArrayItem(items_array, i);
- cJSON *tmp_item = cJSON_GetObjectItem(item_obj, "group_id");
- if (tmp_item != NULL && tmp_item->type == cJSON_Number) {
- rules->add_items[i].group_id = tmp_item->valueint;
- }
-
- tmp_item = cJSON_GetObjectItem(item_obj, "included_sub_group_ids");
- if (tmp_item != NULL && tmp_item->type == cJSON_String) {
- memcpy(rules->add_items[i].incl_sub_ids_str, tmp_item->valuestring,
- strlen(tmp_item->valuestring));
- }
-
- tmp_item = cJSON_GetObjectItem(item_obj, "excluded_sub_group_ids");
- if (tmp_item != NULL && tmp_item->type == cJSON_String) {
- memcpy(rules->add_items[i].excl_sub_ids_str, tmp_item->valuestring,
- strlen(tmp_item->valuestring));
- }
- }
- rules->n_add_item = rule_cnt;
-
- items_array = cJSON_GetObjectItem(root, "del_items");
- if (NULL == items_array) {
- printf("Error before: %-200.200s\n", cJSON_GetErrorPtr());
- ret = -1;
- goto next;
- }
-
- rule_cnt = cJSON_GetArraySize(items_array);
- for (size_t i = 0; i < rule_cnt; i++) {
- cJSON *item_obj = cJSON_GetArrayItem(items_array, i);
- cJSON *tmp_item = cJSON_GetObjectItem(item_obj, "group_id");
- if (tmp_item != NULL && tmp_item->type == cJSON_Number) {
- rules->del_items[i].group_id = tmp_item->valueint;
- }
-
- tmp_item = cJSON_GetObjectItem(item_obj, "included_sub_group_ids");
- if (tmp_item != NULL && tmp_item->type == cJSON_String) {
- memcpy(rules->del_items[i].incl_sub_ids_str, tmp_item->valuestring,
- strlen(tmp_item->valuestring));
- }
-
- tmp_item = cJSON_GetObjectItem(item_obj, "excluded_sub_group_ids");
- if (tmp_item != NULL && tmp_item->type == cJSON_String) {
- memcpy(rules->del_items[i].excl_sub_ids_str, tmp_item->valuestring,
- strlen(tmp_item->valuestring));
- }
- }
- rules->n_del_item = rule_cnt;
-
-next:
- cJSON_Delete(root);
- FREE(json_buff);
- return ret;
-}
-
-class MaatGroupExclude : public testing::Test
-{
-protected:
- static void SetUpTestCase() {
- unsigned char *json_buff = NULL;
- size_t json_buff_size = 0;
-
- logger = log_handle_create(log_file, 0);
- garbage_bin = maat_garbage_bin_new(60);
-
- int ret = load_file_to_memory(g_table_info_path, &json_buff, &json_buff_size);
- if (ret < 0) {
- log_fatal(logger, MODULE_GROUP_NESTING_GTEST, "load_file_to_memory failed.");
- assert(0);
- }
-
- cJSON *root = cJSON_Parse((const char *)json_buff);
- if (!root) {
- log_fatal(logger, MODULE_GROUP_NESTING_GTEST, "cJSON_Parse failed.");
- assert(0);
- }
-
- g2g_schema = group2group_schema_new(root, NULL, "EXCLUDE_GROUP2GROUP", logger);
- FREE(json_buff);
- cJSON_Delete(root);
-
- if (NULL == g2g_schema) {
- log_fatal(logger, MODULE_GROUP_NESTING_GTEST, "group2group_schema_new failed.");
- assert(0);
- }
- }
-
- static void TearDownTestCase() {
- log_handle_destroy(logger);
- maat_garbage_bin_free(garbage_bin);
- group2group_schema_free(g2g_schema);
- }
-
- static void *g2g_schema;
- static struct log_handle *logger;
- static struct maat_garbage_bin *garbage_bin;
-};
-
-void *MaatGroupExclude::g2g_schema;
-struct log_handle *MaatGroupExclude::logger;
-struct maat_garbage_bin *MaatGroupExclude::garbage_bin;
-
-TEST_F(MaatGroupExclude, level_3_function) {
- char table_line[1024];
- struct group2group_rule rules;
- const char *table_name = "EXCLUDE_GROUP2GROUP";
-
- void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
- if (NULL == g2g_runtime) {
- log_fatal(logger, MODULE_GROUP_NESTING_GTEST, "group2group_runtime_new failed.");
- assert(0);
- }
-
- memset(&rules, 0, sizeof(rules));
- int ret = parse_config_file("group_nesting_L3.conf", &rules);
- EXPECT_EQ(ret, 0);
-
- for (size_t i = 0; i < rules.n_add_item; i++) {
- memset(table_line, 0, sizeof(table_line));
-
- sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].group_id,
- rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
- group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
- }
-
- group2group_runtime_commit(g2g_runtime, table_name, 1);
-
- long long hit_group_ids[2] = {11, 13};
- long long super_group_ids[MAX_ITEM_NUM];
- size_t super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
- super_group_ids, MAX_ITEM_NUM);
- EXPECT_EQ(super_group_cnt, 2);
- EXPECT_EQ(super_group_ids[0], 2);
- EXPECT_EQ(super_group_ids[1], 7);
-
- //delete group_id = 7, super_group_id = 6, is_exclude = 1
- memset(table_line, 0, sizeof(table_line));
- sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].group_id,
- rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
- group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
- group2group_runtime_commit(g2g_runtime, table_name, 2);
-
- super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
- super_group_ids, MAX_ITEM_NUM);
- EXPECT_EQ(super_group_cnt, 3);
- EXPECT_EQ(super_group_ids[0], 1);
- EXPECT_EQ(super_group_ids[1], 6);
- EXPECT_EQ(super_group_ids[2], 7);
-
- //delete group_id = 13, super_group_id = 4, is_exclude = 1
- memset(table_line, 0, sizeof(table_line));
- sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[1].group_id,
- rules.del_items[1].incl_sub_ids_str, rules.del_items[1].excl_sub_ids_str, 0);
- group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
- group2group_runtime_commit(g2g_runtime, table_name, 3);
-
- super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
- super_group_ids, MAX_ITEM_NUM);
- EXPECT_EQ(super_group_cnt, 4);
- EXPECT_EQ(super_group_ids[0], 1);
- EXPECT_EQ(super_group_ids[1], 4);
- EXPECT_EQ(super_group_ids[2], 6);
- EXPECT_EQ(super_group_ids[3], 7);
-
- group2group_runtime_free(g2g_runtime);
-}
-
-TEST_F(MaatGroupExclude, level_3_perf) {
- char table_line[1024];
- struct group2group_rule rules;
- const char *table_name = "EXCLUDE_GROUP2GROUP";
-
- void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
- if (NULL == g2g_runtime) {
- log_fatal(logger, MODULE_GROUP_NESTING_GTEST, "group2group_runtime_new failed.");
- assert(0);
- }
-
- memset(&rules, 0, sizeof(rules));
- int ret = parse_config_file("group_nesting_L3.conf", &rules);
- EXPECT_EQ(ret, 0);
-
- for (size_t i = 0; i < rules.n_add_item; i++) {
- memset(table_line, 0, sizeof(table_line));
-
- sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].group_id,
- rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
- group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
- }
-
- group2group_runtime_commit(g2g_runtime, table_name, 4);
-
- long long hit_group_ids[2] = {11, 13};
- long long super_group_ids[MAX_ITEM_NUM];
- struct timespec start, end;
- struct log_handle *logger = MaatGroupExclude::logger;
-
- clock_gettime(CLOCK_MONOTONIC, &start);
- for (int i = 0; i < MAX_G2G_SCAN_TIMES; i++) {
- group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
- super_group_ids, MAX_ITEM_NUM);
- }
- clock_gettime(CLOCK_MONOTONIC, &end);
- long long time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
- log_info(logger, MODULE_GROUP_NESTING_GTEST, "level_3_basic hit 2 super_groups scan consume time %lldms",
- time_elapse_ms);
-
- //delete group_id = 7, super_group_id = 6, is_exclude = 1
- memset(table_line, 0, sizeof(table_line));
- sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].group_id,
- rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
- group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
- group2group_runtime_commit(g2g_runtime, table_name, 5);
-
- clock_gettime(CLOCK_MONOTONIC, &start);
- for (int i = 0; i < MAX_G2G_SCAN_TIMES; i++) {
- group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
- super_group_ids, MAX_ITEM_NUM);
- }
- clock_gettime(CLOCK_MONOTONIC, &end);
- time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
- log_info(logger, MODULE_GROUP_NESTING_GTEST, "level_3_basic hit 3 super_groups scan consume time %lldms",
- time_elapse_ms);
-
- //delete group_id = 13, super_group_id = 4, is_exclude = 1
- memset(table_line, 0, sizeof(table_line));
- sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[1].group_id,
- rules.del_items[1].incl_sub_ids_str, rules.del_items[1].excl_sub_ids_str, 0);
- group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
- group2group_runtime_commit(g2g_runtime, table_name, 6);
-
- clock_gettime(CLOCK_MONOTONIC, &start);
- for (int i = 0; i < MAX_G2G_SCAN_TIMES; i++) {
- group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
- super_group_ids, MAX_ITEM_NUM);
- }
- clock_gettime(CLOCK_MONOTONIC, &end);
- time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
- log_info(logger, MODULE_GROUP_NESTING_GTEST, "level_3_basic hit 4 super_groups scan consume time %lldms",
- time_elapse_ms);
-
- group2group_runtime_free(g2g_runtime);
-}
-
-TEST_F(MaatGroupExclude, level_4_function) {
- char table_line[1024];
- struct group2group_rule rules;
- const char *table_name = "EXCLUDE_GROUP2GROUP";
-
- void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
- if (NULL == g2g_runtime) {
- log_fatal(logger, MODULE_GROUP_NESTING_GTEST, "group2group_runtime_new failed.");
- assert(0);
- }
-
- memset(&rules, 0, sizeof(rules));
- int ret = parse_config_file("group_nesting_L4.conf", &rules);
- EXPECT_EQ(ret, 0);
-
- for (size_t i = 0; i < rules.n_add_item; i++) {
- memset(table_line, 0, sizeof(table_line));
-
- sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].group_id,
- rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
- group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
- }
-
- group2group_runtime_commit(g2g_runtime, table_name, 7);
-
- long long hit_group_ids[2] = {14, 16};
- long long super_group_ids[MAX_ITEM_NUM];
- size_t super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
- super_group_ids, MAX_ITEM_NUM);
- EXPECT_EQ(super_group_cnt, 5);
- EXPECT_EQ(super_group_ids[0], 4);
- EXPECT_EQ(super_group_ids[1], 7);
- EXPECT_EQ(super_group_ids[2], 8);
- EXPECT_EQ(super_group_ids[3], 9);
- EXPECT_EQ(super_group_ids[4], 10);
-
- //delete group_id = 10, super_group_id = 6, is_exclude = 1
- memset(table_line, 0, sizeof(table_line));
- sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].group_id,
- rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
- group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
- group2group_runtime_commit(g2g_runtime, table_name, 8);
-
- super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
- super_group_ids, MAX_ITEM_NUM);
- EXPECT_EQ(super_group_cnt, 7);
- EXPECT_EQ(super_group_ids[0], 1);
- EXPECT_EQ(super_group_ids[1], 4);
- EXPECT_EQ(super_group_ids[2], 6);
- EXPECT_EQ(super_group_ids[3], 7);
- EXPECT_EQ(super_group_ids[4], 8);
- EXPECT_EQ(super_group_ids[5], 9);
- EXPECT_EQ(super_group_ids[6], 10);
-
- group2group_runtime_free(g2g_runtime);
-}
-
-TEST_F(MaatGroupExclude, level_4_perf) {
- char table_line[1024];
- struct group2group_rule rules;
- const char *table_name = "EXCLUDE_GROUP2GROUP";
-
- void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
- if (NULL == g2g_runtime) {
- log_fatal(logger, MODULE_GROUP_NESTING_GTEST, "group2group_runtime_new failed.");
- assert(0);
- }
-
- memset(&rules, 0, sizeof(rules));
- int ret = parse_config_file("group_nesting_L4.conf", &rules);
- EXPECT_EQ(ret, 0);
-
- for (size_t i = 0; i < rules.n_add_item; i++) {
- memset(table_line, 0, sizeof(table_line));
-
- sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].group_id,
- rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
- group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
- }
-
- group2group_runtime_commit(g2g_runtime, table_name, 7);
-
- long long hit_group_ids[2] = {14, 16};
- long long super_group_ids[MAX_ITEM_NUM];
- struct timespec start, end;
- struct log_handle *logger = MaatGroupExclude::logger;
-
- clock_gettime(CLOCK_MONOTONIC, &start);
- for (int i = 0; i < MAX_G2G_SCAN_TIMES; i++) {
- group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
- super_group_ids, MAX_ITEM_NUM);
- }
- clock_gettime(CLOCK_MONOTONIC, &end);
- long long time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
- log_info(logger, MODULE_GROUP_NESTING_GTEST, "level_4_basic hit 5 super_groups scan consume time %lldms",
- time_elapse_ms);
-
- //delete group_id = 10, super_group_id = 6, is_exclude = 1
- memset(table_line, 0, sizeof(table_line));
- sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].group_id,
- rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
- group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
- group2group_runtime_commit(g2g_runtime, table_name, 8);
-
- clock_gettime(CLOCK_MONOTONIC, &start);
- for (int i = 0; i < MAX_G2G_SCAN_TIMES; i++) {
- group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
- super_group_ids, MAX_ITEM_NUM);
- }
- clock_gettime(CLOCK_MONOTONIC, &end);
- time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
- log_info(logger, MODULE_GROUP_NESTING_GTEST, "level_4_basic hit 7 super_groups scan consume time %lldms",
- time_elapse_ms);
-
- group2group_runtime_free(g2g_runtime);
-}
-
-TEST_F(MaatGroupExclude, level_exceed_function) {
- char table_line[1024];
- struct group2group_rule rules;
- const char *table_name = "EXCLUDE_GROUP2GROUP";
-
- void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
- if (NULL == g2g_runtime) {
- log_fatal(logger, MODULE_GROUP_NESTING_GTEST, "group2group_runtime_new failed.");
- assert(0);
- }
-
- memset(&rules, 0, sizeof(rules));
- int ret = parse_config_file("group_nesting_exceed.conf", &rules);
- EXPECT_EQ(ret, 0);
-
- for (size_t i = 0; i < rules.n_add_item; i++) {
- memset(table_line, 0, sizeof(table_line));
-
- sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].group_id,
- rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
- group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
- }
-
- group2group_runtime_commit(g2g_runtime, table_name, 8);
-
- long long hit_group_ids[2] = {7, 13};
- long long super_group_ids[MAX_ITEM_NUM];
- size_t super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
- super_group_ids, MAX_ITEM_NUM);
- EXPECT_EQ(super_group_cnt, 6);
- EXPECT_EQ(super_group_ids[0], 4);
- EXPECT_EQ(super_group_ids[1], 5);
- EXPECT_EQ(super_group_ids[2], 8);
- EXPECT_EQ(super_group_ids[3], 10);
- EXPECT_EQ(super_group_ids[4], 11);
- EXPECT_EQ(super_group_ids[5], 12);
-
- //delete group_id = 13, super_group_id = 10, is_exclude = 0
- memset(table_line, 0, sizeof(table_line));
- sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].group_id,
- rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
- group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
- group2group_runtime_commit(g2g_runtime, table_name, 9);
-
- hit_group_ids[0] = 7;
- hit_group_ids[1] = 10;
- super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
- super_group_ids, MAX_ITEM_NUM);
- EXPECT_EQ(super_group_cnt, 5);
- EXPECT_EQ(super_group_ids[0], 2);
- EXPECT_EQ(super_group_ids[1], 4);
- EXPECT_EQ(super_group_ids[2], 5);
- EXPECT_EQ(super_group_ids[3], 8);
- EXPECT_EQ(super_group_ids[4], 11);
-
- group2group_runtime_free(g2g_runtime);
-}
-
-int main(int argc, char ** argv)
-{
- int ret = 0;
- ::testing::InitGoogleTest(&argc, argv);
- ret = RUN_ALL_TESTS();
-
- return ret;
-} \ No newline at end of file
diff --git a/test/group_nesting/group_nesting_table_info.conf b/test/group_nesting/group_nesting_table_info.conf
deleted file mode 100644
index 2d55465..0000000
--- a/test/group_nesting/group_nesting_table_info.conf
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "table_id":1,
- "table_name":"EXCLUDE_GROUP2GROUP",
- "table_type":"group2group",
- "valid_column":4,
- "custom": {
- "group_id":1,
- "included_sub_group_ids":2,
- "excluded_sub_group_ids":3
- }
-} \ No newline at end of file
diff --git a/test/json_update/corrupted.json b/test/json_update/corrupted.json
index 0427a91..fdc6c7d 100644
--- a/test/json_update/corrupted.json
+++ b/test/json_update/corrupted.json
@@ -1,6 +1,6 @@
{
"rule_table": "RULE_DEFAULT",
- "group_table": "GROUP",
+ "object_table": "OBJECT",
"rules": [
{
"rule_id": 1,
@@ -10,9 +10,9 @@
"do_log": 1,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
- "group_name": "Untitled",
+ "object_name": "Untitled",
"regions": [
{
"table_name": "HTTP_URL",
diff --git a/test/json_update/new.json b/test/json_update/new.json
index 4fda461..ba07f69 100644
--- a/test/json_update/new.json
+++ b/test/json_update/new.json
@@ -1,7 +1,7 @@
{
"rule_table": "RULE_DEFAULT",
- "group2rule_table": "GROUP2RULE_DEFAULT",
- "group2group_table": "GROUP2GROUP",
+ "object2rule_table": "OBJECT2RULE_DEFAULT",
+ "object2object_table": "OBJECT2OBJECT",
"rules": [
{
"rule_id": 2,
@@ -11,7 +11,7 @@
"do_log": 1,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
"regions": [
diff --git a/test/json_update/old.json b/test/json_update/old.json
index c248157..c395d6f 100644
--- a/test/json_update/old.json
+++ b/test/json_update/old.json
@@ -1,7 +1,7 @@
{
"rule_table": "RULE_DEFAULT",
- "group2rule_table": "GROUP2RULE_DEFAULT",
- "group2group_table": "GROUP2GROUP",
+ "object2rule_table": "OBJECT2RULE_DEFAULT",
+ "object2object_table": "OBJECT2OBJECT",
"rules": [
{
"rule_id": 1,
@@ -11,9 +11,9 @@
"do_log": 1,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
- "group_name": "Untitled",
+ "object_name": "Untitled",
"attribute": "HTTP_URL",
"regions": [
{
diff --git a/test/maat_framework_gtest.cpp b/test/maat_framework_gtest.cpp
index bcfcf1b..6a206da 100644
--- a/test/maat_framework_gtest.cpp
+++ b/test/maat_framework_gtest.cpp
@@ -39,14 +39,14 @@ int test_add_expr_command(struct maat *maat_inst, const char *expr_table,
rule_id, huge_serv_def, 1, timeout);
EXPECT_EQ(ret, 1);
- long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, "GROUP2RULE_DEFAULT", MAAT_OP_ADD,
- group_id, rule_id, 0, expr_table, 1, timeout);
+ long long object_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, "OBJECT2RULE_DEFAULT", MAAT_OP_ADD,
+ object_id, rule_id, 0, expr_table, 1, timeout);
EXPECT_EQ(ret, 1);
long long item_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, expr_table, MAAT_OP_ADD, item_id,
- group_id, keywords, "null", 1, 0);
+ object_id, keywords, "null", 1, 0);
EXPECT_EQ(ret, 1);
return ret;
@@ -672,7 +672,7 @@ TEST_F(HsStringScan, BackslashR_N_Escape_IncUpdate) {
maat_state_reset(state);
const char *rule_table_name = "RULE_DEFAULT";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
/* rule table add line */
long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
@@ -680,10 +680,10 @@ TEST_F(HsStringScan, BackslashR_N_Escape_IncUpdate) {
rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2rule table add line */
- long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, rule_id, 0, table_name, 1, 0);
+ /* object2rule table add line */
+ long long object_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* expr table add line */
@@ -692,7 +692,7 @@ TEST_F(HsStringScan, BackslashR_N_Escape_IncUpdate) {
/* EXPR_TYPE_AND MATCH_METHOD_SUB */
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item_id,
- group_id, keywords, NULL, 1, 0);
+ object_id, keywords, NULL, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 3);
@@ -1445,7 +1445,7 @@ TEST_F(HsStringScan, dynamic_config) {
maat_state_reset(state);
const char *rule_table_name = "RULE_DEFAULT";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
/* rule table add line */
long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
@@ -1453,10 +1453,10 @@ TEST_F(HsStringScan, dynamic_config) {
rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2rule table add line */
- long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, rule_id, 0, table_name, 1, 0);
+ /* object2rule table add line */
+ long long object_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* expr table add line */
@@ -1465,7 +1465,7 @@ TEST_F(HsStringScan, dynamic_config) {
/* EXPR_TYPE_AND MATCH_METHOD_SUB */
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item_id,
- group_id, keywords, NULL, 1, 0);
+ object_id, keywords, NULL, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 3);
@@ -1484,12 +1484,12 @@ TEST_F(HsStringScan, dynamic_config) {
/* EXPR_TYPE_AND MATCH_METHOD_SUB */
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_DEL, item_id,
- group_id, keywords, NULL, 1, 0);
+ object_id, keywords, NULL, 1, 0);
EXPECT_EQ(ret, 1);
- /* 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);
+ /* object2rule table del line */
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ object_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* rule table del line */
@@ -1710,7 +1710,7 @@ TEST_F(RsStringScan, BackslashR_N_Escape_IncUpdate) {
maat_state_reset(state);
const char *rule_table_name = "RULE_DEFAULT";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
/* rule table add line */
long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
@@ -1718,10 +1718,10 @@ TEST_F(RsStringScan, BackslashR_N_Escape_IncUpdate) {
rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2rule table add line */
- long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, rule_id, 0, table_name, 1, 0);
+ /* object2rule table add line */
+ long long object_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* expr table add line */
@@ -1730,7 +1730,7 @@ TEST_F(RsStringScan, BackslashR_N_Escape_IncUpdate) {
/* EXPR_TYPE_AND MATCH_METHOD_SUB */
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item_id,
- group_id, keywords, NULL, 1, 0);
+ object_id, keywords, NULL, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 3);
@@ -2490,7 +2490,7 @@ TEST_F(RsStringScan, dynamic_config) {
EXPECT_EQ(ret, MAAT_SCAN_OK);
const char *rule_table_name = "RULE_DEFAULT";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
/* rule table add line */
long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
@@ -2498,10 +2498,10 @@ TEST_F(RsStringScan, dynamic_config) {
rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2rule table add line */
- long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, rule_id, 0, table_name, 1, 0);
+ /* object2rule table add line */
+ long long object_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* expr table add line */
@@ -2510,7 +2510,7 @@ TEST_F(RsStringScan, dynamic_config) {
/* EXPR_TYPE_AND MATCH_METHOD_SUB */
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item_id,
- group_id, keywords, NULL, 1, 0);
+ object_id, keywords, NULL, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -2529,12 +2529,12 @@ TEST_F(RsStringScan, dynamic_config) {
/* EXPR_TYPE_AND MATCH_METHOD_SUB*/
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_DEL, item_id,
- group_id, keywords, NULL, 1, 0);
+ object_id, keywords, NULL, 1, 0);
EXPECT_EQ(ret, 1);
- /* 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);
+ /* object2rule table del line */
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ object_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* rule table del line */
@@ -3184,7 +3184,7 @@ TEST_F(IPScan, RuleUpdates) {
maat_state_reset(state);
const char *rule_table_name = "RULE_DEFAULT";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
/* rule table add line */
long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
@@ -3192,16 +3192,16 @@ TEST_F(IPScan, RuleUpdates) {
rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2rule table add line */
- long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, rule_id, 0, table_name, 1, 0);
+ /* object2rule table add line */
+ long long object_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* ip table add line */
long long item_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = ip_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item_id,
- group_id, "100.100.100.100", 0);
+ object_id, "100.100.100.100", 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -3220,12 +3220,12 @@ TEST_F(IPScan, RuleUpdates) {
/* ip table del line */
ret = ip_table_set_line(maat_inst, table_name, MAAT_OP_DEL, item_id,
- group_id, "100.100.100.100", 0);
+ object_id, "100.100.100.100", 0);
EXPECT_EQ(ret, 1);
- /* 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);
+ /* object2rule table del line */
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ object_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* rule table del line */
@@ -3257,7 +3257,7 @@ TEST_F(IPScan, RuleChangeConditionId) {
int ret;
const char *rule_table_name = "RULE_DEFAULT";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
/* rule table add line */
long long rule_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
@@ -3265,28 +3265,28 @@ TEST_F(IPScan, RuleChangeConditionId) {
rule_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- /* group2rule table add line */
- long long group_id1 = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id1, rule_id, 0, src_table_name, 1, 0);
+ /* object2rule table add line */
+ long long object_id1 = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object_id1, rule_id, 0, src_table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* ip table add line */
long long item_id1 = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = ip_table_set_line(maat_inst, phy_ip_table_name, MAAT_OP_ADD, item_id1,
- group_id1, "1.1.1.1", 0);
+ object_id1, "1.1.1.1", 0);
EXPECT_EQ(ret, 1);
- /* group2rule table add line */
- long long group_id2 = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id2, rule_id, 0, dst_table_name, 2, 0);
+ /* object2rule table add line */
+ long long object_id2 = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object_id2, rule_id, 0, dst_table_name, 2, 0);
EXPECT_EQ(ret, 1);
/* ip table add line */
long long item_id2 = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = ip_table_set_line(maat_inst, phy_ip_table_name, MAAT_OP_ADD, item_id2,
- group_id2, "11.11.11.11", 0);
+ object_id2, "11.11.11.11", 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -3327,25 +3327,25 @@ TEST_F(IPScan, RuleChangeConditionId) {
EXPECT_EQ(ret, 1);
- /* 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);
+ /* object2rule table del line */
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ object_id1, rule_id, 0, src_table_name, 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group_id2, rule_id, 0, dst_table_name, 2, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ object_id2, rule_id, 0, dst_table_name, 2, 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id1, rule_id, 0, src_table_name, 2, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object_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);
- /* group2rule table add line */
- long long group_id3 = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id3, rule_id, 0, app_id_table_name, 1, 0);
+ /* object2rule table add line */
+ long long object_id3 = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object_id3, rule_id, 0, app_id_table_name, 1, 0);
EXPECT_EQ(ret, 1);
@@ -3354,12 +3354,12 @@ TEST_F(IPScan, RuleChangeConditionId) {
//maat_state_reset(state);
n_hit_result = 0;
- struct maat_hit_group group;
- group.item_id = 0;
- group.attribute_id = 0;
- group.group_id = group_id3;
+ struct maat_hit_object object;
+ object.item_id = 0;
+ object.attribute_id = 0;
+ object.object_id = object_id3;
- ret = maat_scan_group(maat_inst, app_id_table_id, &group, 1, results, ARRAY_SIZE, &n_hit_result, state);
+ ret = maat_scan_object(maat_inst, app_id_table_id, &object, 1, results, ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
EXPECT_EQ(n_hit_result, 0);
@@ -3508,7 +3508,7 @@ TEST_F(IntervalScan, IntervalPlus) {
state = NULL;
}
-class GroupScan : public testing::Test
+class ObjectScan : public testing::Test
{
protected:
static void SetUpTestCase() {
@@ -3536,7 +3536,7 @@ protected:
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
log_fatal(logger, MODULE_FRAMEWORK_GTEST,
- "[%s:%d] create maat instance in GroupScan failed.",
+ "[%s:%d] create maat instance in ObjectScan failed.",
__FUNCTION__, __LINE__);
}
}
@@ -3550,24 +3550,24 @@ protected:
static struct maat *_shared_maat_inst;
};
-struct maat *GroupScan::_shared_maat_inst;
-struct log_handle *GroupScan::logger;
+struct maat *ObjectScan::_shared_maat_inst;
+struct log_handle *ObjectScan::logger;
-TEST_F(GroupScan, PhysicalTable) {
+TEST_F(ObjectScan, PhysicalTable) {
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
const char *table_name = "KEYWORDS_TABLE";
- struct maat *maat_inst = GroupScan::_shared_maat_inst;
+ struct maat *maat_inst = ObjectScan::_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);
- struct maat_hit_group hit_group;
- hit_group.group_id = 247;
- hit_group.attribute_id = table_id;
- int ret = maat_scan_group(maat_inst, table_id, &hit_group, 1, results,
+ struct maat_hit_object hit_object;
+ hit_object.object_id = 247;
+ hit_object.attribute_id = table_id;
+ int ret = maat_scan_object(maat_inst, table_id, &hit_object, 1, results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
@@ -3578,21 +3578,21 @@ TEST_F(GroupScan, PhysicalTable) {
sleep(2);
}
-TEST_F(GroupScan, Attribute) {
+TEST_F(ObjectScan, Attribute) {
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
const char *table_name = "HTTP_RESPONSE_KEYWORDS";
- struct maat *maat_inst = GroupScan::_shared_maat_inst;
+ struct maat *maat_inst = ObjectScan::_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);
- struct maat_hit_group hit_group;
- hit_group.group_id = 259;
- hit_group.attribute_id = table_id;
- int ret = maat_scan_group(maat_inst, table_id, &hit_group, 1, results,
+ struct maat_hit_object hit_object;
+ hit_object.object_id = 259;
+ hit_object.attribute_id = table_id;
+ int ret = maat_scan_object(maat_inst, table_id, &hit_object, 1, results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
@@ -3603,12 +3603,12 @@ TEST_F(GroupScan, Attribute) {
sleep(2);
}
-TEST_F(GroupScan, SetScanRuleTable) {
+TEST_F(ObjectScan, SetScanRuleTable) {
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
const char *table_name = "KEYWORDS_TABLE";
- struct maat *maat_inst = GroupScan::_shared_maat_inst;
+ struct maat *maat_inst = ObjectScan::_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);
@@ -3620,10 +3620,10 @@ TEST_F(GroupScan, SetScanRuleTable) {
int ret = maat_state_set_scan_rule_table(state, rule_table_id);
EXPECT_EQ(ret, 0);
- struct maat_hit_group hit_group;
- hit_group.group_id = 248;
- hit_group.attribute_id = table_id;
- ret = maat_scan_group(maat_inst, table_id, &hit_group, 1, results,
+ struct maat_hit_object hit_object;
+ hit_object.object_id = 248;
+ hit_object.attribute_id = table_id;
+ ret = maat_scan_object(maat_inst, table_id, &hit_object, 1, results,
ARRAY_SIZE, &n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
@@ -4325,7 +4325,7 @@ TEST_F(NOTLogic, EightNotCondition) {
state = NULL;
}
-TEST_F(NOTLogic, NotConditionAndExcludeGroup1) {
+TEST_F(NOTLogic, NotConditionAndExcludeObject1) {
const char *string_should_not_hit = "This string ONLY contains must-contained-string-of-rule-200 and "
"must-not-contained-string-of-rule-200";
const char *string_should_half_hit = "This string ONLY contains must-contained-string-of-rule-200";
@@ -4377,7 +4377,7 @@ TEST_F(NOTLogic, NotConditionAndExcludeGroup1) {
state = NULL;
}
-TEST_F(NOTLogic, NotConditionAndExcludeGroup2) {
+TEST_F(NOTLogic, NotConditionAndExcludeObject2) {
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-rule-217";
@@ -4553,7 +4553,7 @@ TEST_F(NOTLogic, MultiNotConditions) {
state = NULL;
}
-TEST_F(NOTLogic, MultiGroupsInOneNotCondition) {
+TEST_F(NOTLogic, MultiObjectsInOneNotCondition) {
const char *src_asn1 = "AS1234";
const char *src_asn2 = "AS6789";
const char *src_asn3 = "AS9001";
@@ -6199,7 +6199,7 @@ 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";
+ const char *g2c_table_name = "OBJECT2RULE";
struct maat *maat_inst = TableSchemaTag::_shared_maat_inst;
//RULE_DEFAULT
@@ -6229,14 +6229,14 @@ TEST_F(TableSchemaTag, RuleTable) {
ret = strcmp(tag3, "{\"rule_conjunction\": \"rule\"}");
EXPECT_EQ(ret, 0);
- //GROUP2RULE
+ //OBJECT2RULE
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, "{\"group2rule\": \"group2rule\"}");
+ ret = strcmp(tag4, "{\"object2rule\": \"object2rule\"}");
EXPECT_EQ(ret, 0);
//RULE_PLUGIN
@@ -6675,7 +6675,7 @@ TEST_F(Policy, RuleEXData) {
state = NULL;
}
-TEST_F(Policy, SubGroup) {
+TEST_F(Policy, SubObject) {
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
@@ -6746,38 +6746,38 @@ TEST_F(Policy, EvaluationOrder) {
EXPECT_EQ(n_hit_path, 6);
EXPECT_EQ(hit_path[0].attribute_id, table_id);
- EXPECT_EQ(hit_path[0].sub_group_id, 158);
- EXPECT_EQ(hit_path[0].top_group_id, 158);
+ EXPECT_EQ(hit_path[0].sub_object_id, 158);
+ EXPECT_EQ(hit_path[0].top_object_id, 158);
EXPECT_EQ(hit_path[0].condition_index, 2);
EXPECT_EQ(hit_path[0].rule_id, 168);
EXPECT_EQ(hit_path[1].attribute_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].sub_object_id, 157);
+ EXPECT_EQ(hit_path[1].top_object_id, 157);
EXPECT_EQ(hit_path[1].condition_index, 0);
EXPECT_EQ(hit_path[1].rule_id, 166);
EXPECT_EQ(hit_path[2].attribute_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].sub_object_id, 155);
+ EXPECT_EQ(hit_path[2].top_object_id, -1);
EXPECT_EQ(hit_path[2].condition_index, -1);
EXPECT_EQ(hit_path[2].rule_id, -1);
EXPECT_EQ(hit_path[3].attribute_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].sub_object_id, 158);
+ EXPECT_EQ(hit_path[3].top_object_id, 158);
EXPECT_EQ(hit_path[3].condition_index, 6);
EXPECT_EQ(hit_path[3].rule_id, 168);
EXPECT_EQ(hit_path[4].attribute_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].sub_object_id, 158);
+ EXPECT_EQ(hit_path[4].top_object_id, 158);
EXPECT_EQ(hit_path[4].condition_index, 1);
EXPECT_EQ(hit_path[4].rule_id, 167);
EXPECT_EQ(hit_path[5].attribute_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].sub_object_id, 158);
+ EXPECT_EQ(hit_path[5].top_object_id, 158);
EXPECT_EQ(hit_path[5].condition_index, 3);
EXPECT_EQ(hit_path[5].rule_id, 167);
@@ -6847,32 +6847,32 @@ TEST_F(Policy, NotConditionHitPath) {
EXPECT_EQ(hit_path[0].attribute_id, url_table_id);
EXPECT_EQ(hit_path[0].negate_option, 0);
EXPECT_EQ(hit_path[0].condition_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].sub_object_id, 249);
+ EXPECT_EQ(hit_path[0].top_object_id, 249);
EXPECT_EQ(hit_path[0].rule_id, 228);
EXPECT_EQ(hit_path[1].Nth_scan, 2);
EXPECT_EQ(hit_path[1].attribute_id, ip_table_id);
EXPECT_EQ(hit_path[1].negate_option, 1);
EXPECT_EQ(hit_path[1].condition_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].sub_object_id, 100);
+ EXPECT_EQ(hit_path[1].top_object_id, 144);
EXPECT_EQ(hit_path[1].rule_id, -1);
EXPECT_EQ(hit_path[2].Nth_scan, 2);
EXPECT_EQ(hit_path[2].attribute_id, ip_table_id);
EXPECT_EQ(hit_path[2].negate_option, 1);
EXPECT_EQ(hit_path[2].condition_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].sub_object_id, 100);
+ EXPECT_EQ(hit_path[2].top_object_id, -1);
EXPECT_EQ(hit_path[2].rule_id, -1);
EXPECT_EQ(hit_path[3].Nth_scan, 2);
EXPECT_EQ(hit_path[3].attribute_id, ip_table_id);
EXPECT_EQ(hit_path[3].negate_option, 1);
EXPECT_EQ(hit_path[3].condition_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].sub_object_id, 250);
+ EXPECT_EQ(hit_path[3].top_object_id, 250);
EXPECT_EQ(hit_path[3].rule_id, 228);
maat_state_free(state);
@@ -7068,7 +7068,7 @@ TEST_F(FileTest, StreamFiles) {
free(name_list);
}
-class GroupHierarchy : public testing::Test
+class ObjectHierarchy : public testing::Test
{
protected:
static void SetUpTestCase() {
@@ -7097,7 +7097,7 @@ protected:
maat_options_free(opts);
if (NULL == _shared_maat_inst) {
log_fatal(logger, MODULE_FRAMEWORK_GTEST,
- "[%s:%d] create maat instance in GroupHierarchy failed.",
+ "[%s:%d] create maat instance in ObjectHierarchy failed.",
__FUNCTION__, __LINE__);
}
}
@@ -7111,10 +7111,10 @@ protected:
static struct maat *_shared_maat_inst;
};
-struct maat *GroupHierarchy::_shared_maat_inst;
-struct log_handle *GroupHierarchy::logger;
+struct maat *ObjectHierarchy::_shared_maat_inst;
+struct log_handle *ObjectHierarchy::logger;
-TEST_F(GroupHierarchy, AttributeOfOnePhysical)
+TEST_F(ObjectHierarchy, AttributeOfOnePhysical)
{
const char *http_content = "Batman\\:Take me Home.Superman/:Fine,stay with me.";
const char *http_url = "https://blog.csdn.net/littlefang/article/details/8213058";
@@ -7123,7 +7123,7 @@ TEST_F(GroupHierarchy, AttributeOfOnePhysical)
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
- struct maat *maat_inst = GroupHierarchy::_shared_maat_inst;
+ struct maat *maat_inst = ObjectHierarchy::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
int table_id = maat_get_table_id(maat_inst, url_table_name);
@@ -7167,7 +7167,7 @@ TEST_F(GroupHierarchy, AttributeOfOnePhysical)
state = NULL;
}
-TEST_F(GroupHierarchy, AttributeWithAttribute) {
+TEST_F(ObjectHierarchy, AttributeWithAttribute) {
const char *http_req_hdr_ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/78.0.3904.108 Safari/537.36";
@@ -7179,7 +7179,7 @@ TEST_F(GroupHierarchy, AttributeWithAttribute) {
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
- struct maat *maat_inst = GroupHierarchy::_shared_maat_inst;
+ struct maat *maat_inst = ObjectHierarchy::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
int table_id = maat_get_table_id(maat_inst, req_table_name);
@@ -7220,7 +7220,7 @@ TEST_F(GroupHierarchy, AttributeWithAttribute) {
state = NULL;
}
-TEST_F(GroupHierarchy, OneGroupInTwoAttribute) {
+TEST_F(ObjectHierarchy, OneObjectInTwoAttribute) {
const char *http_resp_hdr_cookie = "sessionid=888888;BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; sugstore=1;";
const char *req_table_name = "HTTP_REQUEST_HEADER";
const char *res_table_name = "HTTP_RESPONSE_HEADER";
@@ -7228,7 +7228,7 @@ TEST_F(GroupHierarchy, OneGroupInTwoAttribute) {
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
- struct maat *maat_inst = GroupHierarchy::_shared_maat_inst;
+ struct maat *maat_inst = ObjectHierarchy::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
int table_id = maat_get_table_id(maat_inst, req_table_name);
@@ -7269,7 +7269,7 @@ TEST_F(GroupHierarchy, OneGroupInTwoAttribute) {
state = NULL;
}
-TEST_F(GroupHierarchy, MultiGroupsInOneCondition) {
+TEST_F(ObjectHierarchy, MultiObjectsInOneCondition) {
const char *src_asn1 = "AS1234";
const char *src_asn2 = "AS6789";
const char *src_asn3 = "AS9001";
@@ -7279,7 +7279,7 @@ TEST_F(GroupHierarchy, MultiGroupsInOneCondition) {
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
- struct maat *maat_inst = GroupHierarchy::_shared_maat_inst;
+ struct maat *maat_inst = ObjectHierarchy::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
//--------------------------------------
@@ -7359,7 +7359,7 @@ TEST_F(GroupHierarchy, MultiGroupsInOneCondition) {
state = NULL;
}
-TEST_F(GroupHierarchy, MultiLiteralsInOneCondition) {
+TEST_F(ObjectHierarchy, MultiLiteralsInOneCondition) {
const char *src_asn1 = "AS1234";
const char *src_asn2 = "AS6789";
const char *my_county = "Greece.Sparta";
@@ -7369,7 +7369,7 @@ TEST_F(GroupHierarchy, MultiLiteralsInOneCondition) {
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
- struct maat *maat_inst = GroupHierarchy::_shared_maat_inst;
+ struct maat *maat_inst = ObjectHierarchy::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
int src_table_id = maat_get_table_id(maat_inst, src_asn_table_name);
@@ -7450,7 +7450,7 @@ protected:
maat_options_set_perf_on(opts);
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_FATAL);
maat_options_set_hit_path_enabled(opts);
- maat_options_set_hit_group_enabled(opts);
+ maat_options_set_hit_object_enabled(opts);
_shared_maat_inst = maat_new(opts, g_table_info_path);
assert(_shared_maat_inst != NULL);
@@ -7483,7 +7483,7 @@ TEST_F(MaatCmd, SetIP) {
int thread_id = 0;
const char *ip_table_name = "IP_CONFIG";
const char *rule_table_name = "RULE_DEFAULT";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2c_table_name = "OBJECT2RULE_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);
@@ -7494,17 +7494,17 @@ TEST_F(MaatCmd, SetIP) {
rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2rule table add line */
- long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, rule_id, 0, ip_table_name, 1, 0);
+ /* object2rule table add line */
+ long long object_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object_id, rule_id, 0, ip_table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* item table add line */
const char *ip1 = "172.0.0.1";
long long item_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = ip_table_set_line(maat_inst, ip_table_name, MAAT_OP_ADD, item_id,
- group_id, ip1, 0);
+ object_id, ip1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -7608,7 +7608,7 @@ TEST_F(MaatCmd, SetExpr8) {
const char *scan_data7 = "string1, string2, string3, string4, string5, string6, string7";
const char *rule_table_name = "RULE_DEFAULT";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
const char *table_name = "KEYWORDS_TABLE";
const char *keywords8 = "string1&string2&string3&string4&string5&string6&string7&string8";
@@ -7626,16 +7626,16 @@ TEST_F(MaatCmd, SetExpr8) {
rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2rule table add line */
- long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, rule_id, 0, table_name, 1, 0);
+ /* object2rule table add line */
+ long long object_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
/* EXPR_TYPE_AND MATCH_METHOD_SUB */
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,
- group_id, keywords8, NULL, 1, 0);
+ object_id, keywords8, NULL, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -7656,11 +7656,11 @@ TEST_F(MaatCmd, SetExpr8) {
maat_state_reset(state);
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_DEL, item_id,
- group_id, keywords8, NULL, 1, 0);
+ object_id, keywords8, NULL, 1, 0);
EXPECT_EQ(ret, 1);
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item_id,
- group_id, keywords7, NULL, 1, 0);
+ object_id, keywords7, NULL, 1, 0);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -7679,13 +7679,13 @@ TEST_F(MaatCmd, SetExpr8) {
state = NULL;
}
-TEST_F(MaatCmd, GroupScan) {
+TEST_F(MaatCmd, ObjectScan) {
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
const char *table_name = "HTTP_URL";
const char *rule_table_name = "RULE_DEFAULT";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
@@ -7698,18 +7698,18 @@ TEST_F(MaatCmd, GroupScan) {
rule_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2rule table add line */
- long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, rule_id, 0, table_name, 1, 0);
+ /* object2rule table add line */
+ long long object_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object_id, rule_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
- struct maat_hit_group hit_group;
- hit_group.group_id = group_id;
- hit_group.attribute_id = table_id;
- ret = maat_scan_group(maat_inst, table_id, &hit_group, 1, results, ARRAY_SIZE,
+ struct maat_hit_object hit_object;
+ hit_object.object_id = object_id;
+ hit_object.attribute_id = table_id;
+ ret = maat_scan_object(maat_inst, table_id, &hit_object, 1, results, ARRAY_SIZE,
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_HIT);
EXPECT_EQ(n_hit_result, 1);
@@ -7720,7 +7720,7 @@ TEST_F(MaatCmd, GroupScan) {
}
/**
- * Filter such as URL: http://filtermenot.com => {attribute_id, group_id}
+ * Filter such as URL: http://filtermenot.com => {attribute_id, object_id}
One rule reference this filter twice, the rule should be hit.
*/
TEST_F(MaatCmd, SameFilterRefByOneRule) {
@@ -7728,7 +7728,7 @@ TEST_F(MaatCmd, SameFilterRefByOneRule) {
const char *scan_data = "http://filtermenot.com";
const char *keywords = "menot.com";
const char *rule_table_name = "RULE_DEFAULT";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
int thread_id = 0;
@@ -7743,18 +7743,18 @@ TEST_F(MaatCmd, SameFilterRefByOneRule) {
rule_id, "null", 2, 0); // rule has two condition
EXPECT_EQ(ret, 1);
- //condition1 & condition2 has same filter => {attribute_id, group_id}
- long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, rule_id, 0, attribute_name, 1, 0);
+ //condition1 & condition2 has same filter => {attribute_id, object_id}
+ long long object_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object_id, rule_id, 0, attribute_name, 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group_id, rule_id, 0, attribute_name, 2, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object_id, rule_id, 0, attribute_name, 2, 0);
EXPECT_EQ(ret, 1);
long long item_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
- ret = expr_table_set_line(maat_inst, "HTTP_URL", MAAT_OP_ADD, item_id, group_id,
+ ret = expr_table_set_line(maat_inst, "HTTP_URL", MAAT_OP_ADD, item_id, object_id,
keywords, "null", 1, 0);
EXPECT_EQ(ret, 1);
@@ -7877,11 +7877,11 @@ TEST_F(MaatCmd, ReturnRuleIDWithDescendingOrder) {
maat_state_free(state);
}
-TEST_F(MaatCmd, SubGroup) {
+TEST_F(MaatCmd, SubObject) {
const char *table_name = "HTTP_URL";
const char *rule_table_name = "RULE_DEFAULT";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
- const char *g2g_table_name = "GROUP2GROUP";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
+ const char *g2g_table_name = "OBJECT2OBJECT";
const char *scan_data1 = "www.v2ex.com/t/573028#程序员的核心竞争力是什么";
const char *keyword1 = "程序员&核心竞争力";
const char *scan_data2 = "https://ask.leju.com/bj/detail/12189672562229248/?bi=tg&type=sina-pc"
@@ -7908,31 +7908,31 @@ TEST_F(MaatCmd, SubGroup) {
rule2_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- /* group2rule table add line */
- //group1 -> rule1
- long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule1_id, 0, table_name, 1, 0);
+ /* object2rule table add line */
+ //object1 -> rule1
+ long long object1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- //group1 -> rule2
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule2_id, 0, table_name, 1, 0);
+ //object1 -> rule2
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule2_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- //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);
+ //object2 -> object1 -> rule1
+ long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2object_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
+ object1_id, object2_id, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group2 -> group1 -> rule1
+ /* item1 -> object2 -> object1 -> rule1
\
\ _ 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,
- group2_id, keyword1, NULL, 1, 0);/* EXPR_TYPE_AND MATCH_METHOD_SUB */
+ object2_id, keyword1, NULL, 1, 0);/* EXPR_TYPE_AND MATCH_METHOD_SUB */
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -7951,12 +7951,12 @@ TEST_F(MaatCmd, SubGroup) {
maat_state_reset(state);
- /* item1 -> group2 -> group1 -> rule1
+ /* item1 -> object2 -> object1 -> rule1
\
\_ X -> rule2
*/
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group1_id, rule2_id, 0, table_name, 1, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ object1_id, rule2_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -7972,19 +7972,19 @@ TEST_F(MaatCmd, SubGroup) {
maat_state_reset(state);
- /* item1 -> group2 -> group1 -> X
+ /* item1 -> object2 -> object1 -> X
\
\_ -> rule2
*/
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group1_id, rule1_id, 0, table_name, 1, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ object1_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, rule2_id, 0, table_name, 1, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object2_id, rule2_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -8000,19 +8000,19 @@ TEST_F(MaatCmd, SubGroup) {
maat_state_reset(state);
- /* item1 -> group2 -> group1 -> X
+ /* item1 -> object2 -> object1 -> X
\
\_ -> rule2
- item2 -> group3
+ item2 -> object3
*/
- long long group3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2group_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
- group1_id, group3_id, 0);
+ long long object3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2object_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
+ object1_id, object3_id, 0);
EXPECT_EQ(ret, 1);
long long item2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item2_id,
- group3_id, keyword2, NULL, 1, 0);/* EXPR_TYPE_AND MATCH_METHOD_SUB */
+ object3_id, keyword2, NULL, 1, 0);/* EXPR_TYPE_AND MATCH_METHOD_SUB */
sleep(2);
ret = maat_scan_string(maat_inst, table_id, scan_data2, strlen(scan_data2),
results, ARRAY_SIZE, &n_hit_result, state);
@@ -8024,23 +8024,23 @@ TEST_F(MaatCmd, SubGroup) {
maat_state_reset(state);
- /* item1 -> group2 -> group1 -> X
+ /* item1 -> object2 -> object1 -> X
\
\_ -> rule2
- item2 -> group3
+ item2 -> object3
*/
ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule1_id, 0, table_name, 1, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group1_id, rule1_id, 0, table_name, 1, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ object1_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -8058,10 +8058,10 @@ TEST_F(MaatCmd, SubGroup) {
state = NULL;
}
-TEST_F(MaatCmd, RefGroup) {
+TEST_F(MaatCmd, RefObject) {
const char *table_name = "HTTP_URL";
const char* rule_table_name = "RULE_DEFAULT";
- const char* g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char* g2c_table_name = "OBJECT2RULE_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";
@@ -8078,33 +8078,33 @@ TEST_F(MaatCmd, RefGroup) {
rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //group1 -> rule1
- long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule1_id, 0, table_name, 1, 0);
+ //object1 -> rule1
+ long long object1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> rule1
+ //item1 -> object1 -> 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 */
+ object1_id, keyword1, NULL, 1, 0); /* EXPR_TYPE_AND MATCH_METHOD_SUB */
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
- /* item1 -> group1 -> X -> rule1
+ /* item1 -> object1 -> X -> rule1
/
/
- item2 -> group2
+ item2 -> object2
*/
- long long group2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, rule1_id, 0, table_name, 1, 0);
+ long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object2_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
long long item2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item2_id,
- group2_id, keyword2, NULL, 1, 0);/* EXPR_TYPE_AND MATCH_METHOD_SUB */
+ object2_id, keyword2, NULL, 1, 0);/* EXPR_TYPE_AND MATCH_METHOD_SUB */
EXPECT_EQ(ret, 1);
ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
@@ -8113,11 +8113,11 @@ TEST_F(MaatCmd, RefGroup) {
ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_ADD,
rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group1_id, rule1_id, 0, table_name, 1, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ object1_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, rule1_id, 0, table_name, 1, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object2_id, rule1_id, 0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -8140,7 +8140,7 @@ TEST_F(MaatCmd, RefGroup) {
TEST_F(MaatCmd, Attribute) {
const char* rule_table_name = "RULE_DEFAULT";
- const char* g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char* g2c_table_name = "OBJECT2RULE_DEFAULT";
const char* table_name="HTTP_SIGNATURE";
int thread_id = 0;
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
@@ -8151,36 +8151,36 @@ TEST_F(MaatCmd, Attribute) {
rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- //group1 -> rule1
- long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule1_id, 0,
+ //object1 -> rule1
+ long long object1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule1_id, 0,
"HTTP_REQUEST_HEADER", 1, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> rule1
+ //item1 -> object1 -> 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 */
+ object1_id, "AppleWebKit", "User-Agent", 0, 0);/*EXPR_TYPE_STRING MATCH_METHOD_SUB */
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- group2_/
+ object2_/
*/
- long long group2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, rule1_id, 0,
+ long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object2_id, rule1_id, 0,
"HTTP_RESPONSE_HEADER", 2, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- item2 -> group2/
+ item2 -> object2/
*/
long long item2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item2_id,
- group2_id, "uid=12345678;", "Cookie", 0, 0);/*EXPR_TYPE_STRING MATCH_METHOD_SUB */
+ object2_id, "uid=12345678;", "Cookie", 0, 0);/*EXPR_TYPE_STRING MATCH_METHOD_SUB */
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -8229,9 +8229,9 @@ TEST_F(MaatCmd, Attribute) {
maat_state_reset(state);
- //delete group1
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group1_id, rule1_id, 0,
+ //delete object1
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ object1_id, rule1_id, 0,
"HTTP_REQUEST_HEADER", 1, 0);
EXPECT_EQ(ret, 1);
ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
@@ -8934,8 +8934,8 @@ TEST_F(MaatCmd, UpdateBoolPlugin) {
}
#define RULE_ID_NUMS 1000
-TEST_F(MaatCmd, GroupInMassRules) {
- const char* g2c_table_name = "GROUP2RULE_DEFAULT";
+TEST_F(MaatCmd, ObjectInMassRules) {
+ const char* g2c_table_name = "OBJECT2RULE_DEFAULT";
const char* rule_table_name = "RULE_DEFAULT";
const char* table_url = "HTTP_URL";
const char* table_appid = "APP_ID";
@@ -8943,30 +8943,30 @@ TEST_F(MaatCmd, GroupInMassRules) {
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
struct maat_state *state = maat_state_new(maat_inst, thread_id);
- //item_url1 -> group1
- long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
+ //item_url1 -> object1
+ long long object1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
long long item1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
int ret = expr_table_set_line(maat_inst, table_url, MAAT_OP_ADD, item1_id,
- group1_id, "baidu.com&tsg", NULL, 1, 0);/* EXPR_TYPE_AND MATCH_METHOD_SUB */
+ object1_id, "baidu.com&tsg", NULL, 1, 0);/* EXPR_TYPE_AND MATCH_METHOD_SUB */
EXPECT_EQ(ret, 1);
- //item_url2 -> group2
- long long group2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
+ //item_url2 -> object2
+ long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
long long item2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, table_url, MAAT_OP_ADD, item2_id,
- group2_id, "baidu.com&zhengzhou", NULL, 1, 0);/* EXPR_TYPE_AND MATCH_METHOD_SUB */
+ object2_id, "baidu.com&zhengzhou", NULL, 1, 0);/* EXPR_TYPE_AND MATCH_METHOD_SUB */
EXPECT_EQ(ret, 1);
- //item_appid -> group3
- long long group3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
+ //item_appid -> object3
+ long long object3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
long long item3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = interval_table_set_line(maat_inst, table_appid, MAAT_OP_ADD, item3_id,
- group3_id, "100", NULL, 0);
+ object3_id, "100", NULL, 0);
EXPECT_EQ(ret, 1);
- /* item_url1 -> group1 -> rule[0 ~ RULE_ID_NUMS]
+ /* item_url1 -> object1 -> rule[0 ~ RULE_ID_NUMS]
/
- item_appid -> group3_/
+ item_appid -> object3_/
*/
int i = 0;
long long rule_id[RULE_ID_NUMS] = {0};
@@ -8978,28 +8978,28 @@ TEST_F(MaatCmd, GroupInMassRules) {
}
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);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule_id[i], 0, table_url, 0, 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group3_id, rule_id[i], 0, table_appid, 2, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object3_id, rule_id[i], 0, table_appid, 2, 0);
EXPECT_EQ(ret, 1);
}
- /* item_url2 -> group2 -> target_rule
+ /* item_url2 -> object2 -> target_rule
/
- item_appid -> group3_/
+ item_appid -> object3_/
*/
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 = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, target_rule_id, 0, table_url, 1, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object2_id, target_rule_id, 0, table_url, 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group3_id, target_rule_id, 0, table_appid, 2, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object3_id, target_rule_id, 0, table_appid, 2, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -9057,10 +9057,10 @@ TEST_F(MaatCmd, GroupInMassRules) {
state = NULL;
}
-TEST_F(MaatCmd, HitGroup) {
+TEST_F(MaatCmd, HitObject) {
const char *rule_table_name = "RULE_DEFAULT";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
- const char *g2g_table_name = "GROUP2GROUP";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
+ const char *g2g_table_name = "OBJECT2OBJECT";
const char *http_sig_table_name = "HTTP_SIGNATURE";
const char *ip_table_name = "IP_CONFIG";
const char *keywords_table_name = "KEYWORDS_TABLE";
@@ -9074,94 +9074,94 @@ TEST_F(MaatCmd, HitGroup) {
rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- //group1 -> rule1
- long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule1_id, 0,
+ //object1 -> rule1
+ long long object1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule1_id, 0,
"HTTP_REQUEST_HEADER", 1, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> rule1
+ //item1 -> object1 -> 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",
+ item1_id, object1_id, "hit object item first",
"URL", 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- group21_/
+ object21_/
*/
- long long group21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group21_id, rule1_id, 0,
+ long long object21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object21_id, rule1_id, 0,
"HTTP_RESPONSE_HEADER", 2, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- group2 -> group21 _/
+ object2 -> object21 _/
*/
- 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,
- group21_id, group2_id, 0);
+ long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2object_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
+ object21_id, object2_id, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- item2 -> group2 -> group21 _/
+ item2 -> object2 -> object21 _/
*/
long long item2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, http_sig_table_name, MAAT_OP_ADD,
- item2_id, group2_id, "hit group item second",
+ item2_id, object2_id, "hit object item second",
"Cookie", 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
/*
- item1 -> group1 -> group11
+ item1 -> object1 -> object11
\
\ -> rule1
/
- item2 -> group2 -> group21 _/
+ item2 -> object2 -> object21 _/
*/
- long long group11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2group_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
- group11_id, group1_id, 0);
+ long long object11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2object_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
+ object11_id, object1_id, 0);
EXPECT_EQ(ret, 1);
- //item3 -> group3, group3 is not referenced by any rule.
+ //item3 -> object3, object3 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);
+ long long object3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 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);
+ object3_id, "220.181.38.150-220.181.38.151", 0);
EXPECT_EQ(ret, 1);
- //item4 -> group4, group4 is not referenced by any rule.
+ //item4 -> object4, object4 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);
+ long long object4_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
ret = expr_table_set_line(maat_inst, keywords_table_name, MAAT_OP_ADD,
- item4_id, group4_id, "hit group item forth", NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
+ item4_id, object4_id, "hit object item forth", NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
/*
- item1 -> group1 -> group11
+ item1 -> object1 -> object11
/ \
item5 -> / \ -> rule1
/
- item2 -> group2 -> group21 _/
+ item2 -> object2 -> object21 _/
*/
- //item5 -> group1 which means group1 has multi items
+ //item5 -> object1 which means object1 has multi items
long long item5_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, keywords_table_name, MAAT_OP_ADD,
- item5_id, group1_id,
- "hit group item fifth",
+ item5_id, object1_id,
+ "hit object item fifth",
NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
- const char* http_url = "en.wikipedia.org hit group item first";
- const char* http_resp_hdr_cookie = "laptop=thinkpad X1 extrem;hit group item second"
+ const char* http_url = "en.wikipedia.org hit object item first";
+ const char* http_resp_hdr_cookie = "laptop=thinkpad X1 extrem;hit object item second"
"main[XWJOKE]=hoho; Hm_lvt_bbac0322e6ee13093f98d5c4b5a10912=1578874808;";
int http_req_table_id = maat_get_table_id(maat_inst, "HTTP_REQUEST_HEADER");
@@ -9179,36 +9179,36 @@ TEST_F(MaatCmd, HitGroup) {
size_t scan_times = maat_state_get_scan_count(state);
EXPECT_EQ(scan_times, 1);
- struct maat_hit_group hit_groups[128];
- memset(hit_groups, 0, sizeof(hit_groups));
-
- size_t n_hit_group = maat_state_get_direct_hit_group_cnt(state);
- maat_state_get_direct_hit_groups(state, hit_groups, n_hit_group);
- EXPECT_EQ(n_hit_group, 1);
- EXPECT_EQ(hit_groups[0].item_id, item1_id);
- EXPECT_EQ(hit_groups[0].group_id, group1_id);
- EXPECT_EQ(hit_groups[0].attribute_id, http_req_table_id);
-
- memset(hit_groups, 0, sizeof(hit_groups));
- n_hit_group = maat_state_get_indirect_hit_group_cnt(state);
- maat_state_get_indirect_hit_groups(state, hit_groups, n_hit_group);
- EXPECT_EQ(n_hit_group, 1);
- EXPECT_EQ(hit_groups[0].item_id, 0);
- EXPECT_EQ(hit_groups[0].group_id, group11_id);
- EXPECT_EQ(hit_groups[0].attribute_id, http_req_table_id);
-
- size_t n_last_hit_group = maat_state_get_last_hit_group_cnt(state);
- struct maat_hit_group last_hit_groups[128] = {0};
- maat_state_get_last_hit_groups(state, last_hit_groups, 128);
- EXPECT_EQ(n_last_hit_group, 2);
-
- EXPECT_EQ(last_hit_groups[0].item_id, item1_id);
- EXPECT_EQ(last_hit_groups[0].group_id, group1_id);
- EXPECT_EQ(last_hit_groups[0].attribute_id, http_req_table_id);
-
- EXPECT_EQ(last_hit_groups[1].item_id, 0);
- EXPECT_EQ(last_hit_groups[1].group_id, group11_id);
- EXPECT_EQ(last_hit_groups[1].attribute_id, http_req_table_id);
+ struct maat_hit_object hit_objects[128];
+ memset(hit_objects, 0, sizeof(hit_objects));
+
+ size_t n_hit_object = maat_state_get_direct_hit_object_cnt(state);
+ maat_state_get_direct_hit_objects(state, hit_objects, n_hit_object);
+ EXPECT_EQ(n_hit_object, 1);
+ EXPECT_EQ(hit_objects[0].item_id, item1_id);
+ EXPECT_EQ(hit_objects[0].object_id, object1_id);
+ EXPECT_EQ(hit_objects[0].attribute_id, http_req_table_id);
+
+ memset(hit_objects, 0, sizeof(hit_objects));
+ n_hit_object = maat_state_get_indirect_hit_object_cnt(state);
+ maat_state_get_indirect_hit_objects(state, hit_objects, n_hit_object);
+ EXPECT_EQ(n_hit_object, 1);
+ EXPECT_EQ(hit_objects[0].item_id, 0);
+ EXPECT_EQ(hit_objects[0].object_id, object11_id);
+ EXPECT_EQ(hit_objects[0].attribute_id, http_req_table_id);
+
+ size_t n_last_hit_object = maat_state_get_last_hit_object_cnt(state);
+ struct maat_hit_object last_hit_objects[128] = {0};
+ maat_state_get_last_hit_objects(state, last_hit_objects, 128);
+ EXPECT_EQ(n_last_hit_object, 2);
+
+ EXPECT_EQ(last_hit_objects[0].item_id, item1_id);
+ EXPECT_EQ(last_hit_objects[0].object_id, object1_id);
+ EXPECT_EQ(last_hit_objects[0].attribute_id, http_req_table_id);
+
+ EXPECT_EQ(last_hit_objects[1].item_id, 0);
+ EXPECT_EQ(last_hit_objects[1].object_id, object11_id);
+ EXPECT_EQ(last_hit_objects[1].attribute_id, http_req_table_id);
int http_res_table_id = maat_get_table_id(maat_inst, "HTTP_RESPONSE_HEADER");
ASSERT_GT(http_res_table_id, 0);
@@ -9228,37 +9228,37 @@ TEST_F(MaatCmd, HitGroup) {
scan_times = maat_state_get_scan_count(state);
EXPECT_EQ(scan_times, 2);
- memset(hit_groups, 0, sizeof(hit_groups));
- n_hit_group = maat_state_get_direct_hit_group_cnt(state);
- maat_state_get_direct_hit_groups(state, hit_groups, n_hit_group);
- EXPECT_EQ(n_hit_group, 1);
-
- EXPECT_EQ(hit_groups[0].item_id, item2_id);
- EXPECT_EQ(hit_groups[0].group_id, group2_id);
- EXPECT_EQ(hit_groups[0].attribute_id, http_res_table_id);
-
- memset(hit_groups, 0, sizeof(hit_groups));
- n_hit_group = maat_state_get_indirect_hit_group_cnt(state);
- maat_state_get_indirect_hit_groups(state, hit_groups, n_hit_group);
- EXPECT_EQ(n_hit_group, 1);
- EXPECT_EQ(hit_groups[0].item_id, 0);
- EXPECT_EQ(hit_groups[0].group_id, group21_id);
- EXPECT_EQ(hit_groups[0].attribute_id, http_res_table_id);
+ memset(hit_objects, 0, sizeof(hit_objects));
+ n_hit_object = maat_state_get_direct_hit_object_cnt(state);
+ maat_state_get_direct_hit_objects(state, hit_objects, n_hit_object);
+ EXPECT_EQ(n_hit_object, 1);
+
+ EXPECT_EQ(hit_objects[0].item_id, item2_id);
+ EXPECT_EQ(hit_objects[0].object_id, object2_id);
+ EXPECT_EQ(hit_objects[0].attribute_id, http_res_table_id);
+
+ memset(hit_objects, 0, sizeof(hit_objects));
+ n_hit_object = maat_state_get_indirect_hit_object_cnt(state);
+ maat_state_get_indirect_hit_objects(state, hit_objects, n_hit_object);
+ EXPECT_EQ(n_hit_object, 1);
+ EXPECT_EQ(hit_objects[0].item_id, 0);
+ EXPECT_EQ(hit_objects[0].object_id, object21_id);
+ EXPECT_EQ(hit_objects[0].attribute_id, http_res_table_id);
- n_last_hit_group = maat_state_get_last_hit_group_cnt(state);
- maat_state_get_last_hit_groups(state, last_hit_groups, 128);
- EXPECT_EQ(n_last_hit_group, 2);
+ n_last_hit_object = maat_state_get_last_hit_object_cnt(state);
+ maat_state_get_last_hit_objects(state, last_hit_objects, 128);
+ EXPECT_EQ(n_last_hit_object, 2);
- EXPECT_EQ(last_hit_groups[0].item_id, item2_id);
- EXPECT_EQ(last_hit_groups[0].group_id, group2_id);
- EXPECT_EQ(last_hit_groups[0].attribute_id, http_res_table_id);
+ EXPECT_EQ(last_hit_objects[0].item_id, item2_id);
+ EXPECT_EQ(last_hit_objects[0].object_id, object2_id);
+ EXPECT_EQ(last_hit_objects[0].attribute_id, http_res_table_id);
- EXPECT_EQ(last_hit_groups[1].item_id, 0);
- EXPECT_EQ(last_hit_groups[1].group_id, group21_id);
- EXPECT_EQ(last_hit_groups[1].attribute_id, http_res_table_id);
+ EXPECT_EQ(last_hit_objects[1].item_id, 0);
+ EXPECT_EQ(last_hit_objects[1].object_id, object21_id);
+ EXPECT_EQ(last_hit_objects[1].attribute_id, http_res_table_id);
- const char* keywords1="In graph theory, hit group item forth";
- const char *keywords2="To test one group hit group item fifth";
+ const char* keywords1="In graph theory, hit object item forth";
+ const char *keywords2="To test one object hit object item fifth";
int keywords_table_id = maat_get_table_id(maat_inst, keywords_table_name);
ASSERT_GT(keywords_table_id, 0);
@@ -9282,18 +9282,18 @@ TEST_F(MaatCmd, HitGroup) {
scan_times = maat_state_get_scan_count(state);
EXPECT_EQ(scan_times, 4);
- memset(hit_groups, 0, sizeof(hit_groups));
- n_hit_group = maat_state_get_direct_hit_group_cnt(state);
- maat_state_get_direct_hit_groups(state, hit_groups, n_hit_group);
- EXPECT_EQ(n_hit_group, 2);
+ memset(hit_objects, 0, sizeof(hit_objects));
+ n_hit_object = maat_state_get_direct_hit_object_cnt(state);
+ maat_state_get_direct_hit_objects(state, hit_objects, n_hit_object);
+ EXPECT_EQ(n_hit_object, 2);
- EXPECT_EQ(hit_groups[0].item_id, item4_id);
- EXPECT_EQ(hit_groups[0].group_id, group4_id);
- EXPECT_EQ(hit_groups[0].attribute_id, keywords_table_id); //physical table(keywords_table) attribute_id is 0
+ EXPECT_EQ(hit_objects[0].item_id, item4_id);
+ EXPECT_EQ(hit_objects[0].object_id, object4_id);
+ EXPECT_EQ(hit_objects[0].attribute_id, keywords_table_id); //physical table(keywords_table) attribute_id is 0
- EXPECT_EQ(hit_groups[1].item_id, item3_id);
- EXPECT_EQ(hit_groups[1].group_id, group3_id);
- EXPECT_EQ(hit_groups[1].attribute_id, ip_table_id);
+ EXPECT_EQ(hit_objects[1].item_id, item3_id);
+ EXPECT_EQ(hit_objects[1].object_id, object3_id);
+ EXPECT_EQ(hit_objects[1].attribute_id, ip_table_id);
ret = maat_stream_scan(stream, keywords2, strlen(keywords2), results,
ARRAY_SIZE, &n_hit_result, state);
@@ -9302,34 +9302,34 @@ TEST_F(MaatCmd, HitGroup) {
scan_times = maat_state_get_scan_count(state);
EXPECT_EQ(scan_times, 5);
- memset(hit_groups, 0, sizeof(hit_groups));
- n_hit_group = maat_state_get_direct_hit_group_cnt(state);
- maat_state_get_direct_hit_groups(state, hit_groups, n_hit_group);
- EXPECT_EQ(n_hit_group, 2);
+ memset(hit_objects, 0, sizeof(hit_objects));
+ n_hit_object = maat_state_get_direct_hit_object_cnt(state);
+ maat_state_get_direct_hit_objects(state, hit_objects, n_hit_object);
+ EXPECT_EQ(n_hit_object, 2);
- EXPECT_EQ(hit_groups[0].item_id, item5_id);
- EXPECT_EQ(hit_groups[0].group_id, group1_id);
- EXPECT_EQ(hit_groups[0].attribute_id, keywords_table_id); //physical table(keywords_table) attribute_id is 0
+ EXPECT_EQ(hit_objects[0].item_id, item5_id);
+ EXPECT_EQ(hit_objects[0].object_id, object1_id);
+ EXPECT_EQ(hit_objects[0].attribute_id, keywords_table_id); //physical table(keywords_table) attribute_id is 0
- EXPECT_EQ(hit_groups[1].item_id, item4_id);
- EXPECT_EQ(hit_groups[1].group_id, group4_id);
- EXPECT_EQ(hit_groups[1].attribute_id, keywords_table_id); //physical table(keywords_table) attribute_id is 0
+ EXPECT_EQ(hit_objects[1].item_id, item4_id);
+ EXPECT_EQ(hit_objects[1].object_id, object4_id);
+ EXPECT_EQ(hit_objects[1].attribute_id, keywords_table_id); //physical table(keywords_table) attribute_id is 0
- n_last_hit_group = maat_state_get_last_hit_group_cnt(state);
- maat_state_get_last_hit_groups(state, last_hit_groups, 128);
- EXPECT_EQ(n_last_hit_group, 3);
+ n_last_hit_object = maat_state_get_last_hit_object_cnt(state);
+ maat_state_get_last_hit_objects(state, last_hit_objects, 128);
+ EXPECT_EQ(n_last_hit_object, 3);
- EXPECT_EQ(last_hit_groups[0].item_id, item5_id);
- EXPECT_EQ(last_hit_groups[0].group_id, group1_id);
- EXPECT_EQ(last_hit_groups[0].attribute_id, keywords_table_id);
+ EXPECT_EQ(last_hit_objects[0].item_id, item5_id);
+ EXPECT_EQ(last_hit_objects[0].object_id, object1_id);
+ EXPECT_EQ(last_hit_objects[0].attribute_id, keywords_table_id);
- EXPECT_EQ(last_hit_groups[1].item_id, item4_id);
- EXPECT_EQ(last_hit_groups[1].group_id, group4_id);
- EXPECT_EQ(last_hit_groups[1].attribute_id, keywords_table_id);
+ EXPECT_EQ(last_hit_objects[1].item_id, item4_id);
+ EXPECT_EQ(last_hit_objects[1].object_id, object4_id);
+ EXPECT_EQ(last_hit_objects[1].attribute_id, keywords_table_id);
- EXPECT_EQ(last_hit_groups[2].item_id, 0);
- EXPECT_EQ(last_hit_groups[2].group_id, group11_id);
- EXPECT_EQ(last_hit_groups[2].attribute_id, keywords_table_id);
+ EXPECT_EQ(last_hit_objects[2].item_id, 0);
+ EXPECT_EQ(last_hit_objects[2].object_id, object11_id);
+ EXPECT_EQ(last_hit_objects[2].attribute_id, keywords_table_id);
maat_stream_free(stream);
maat_state_free(state);
@@ -9337,8 +9337,8 @@ TEST_F(MaatCmd, HitGroup) {
}
TEST_F(MaatCmd, HitPathBasic) {
- const char *g2g_table_name = "GROUP2GROUP";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2g_table_name = "OBJECT2OBJECT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
const char *rule_table_name = "RULE_DEFAULT";
const char *http_sig_table_name = "HTTP_SIGNATURE";
const char *ip_table_name = "IP_CONFIG";
@@ -9353,73 +9353,73 @@ TEST_F(MaatCmd, HitPathBasic) {
rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- //group1 -> rule1
- long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule1_id, 0,
+ //object1 -> rule1
+ long long object1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule1_id, 0,
"HTTP_REQUEST_HEADER", 1, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> rule1
+ //item1 -> object1 -> 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",
+ item1_id, object1_id, "graph_theory", "URL",
0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- group21_/
+ object21_/
*/
- long long group21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group21_id, rule1_id, 0,
+ long long object21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object21_id, rule1_id, 0,
"HTTP_RESPONSE_HEADER", 2, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- group2 -> group21 _/
+ object2 -> object21 _/
*/
- 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,
- group21_id, group2_id, 0);
+ long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2object_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
+ object21_id, object2_id, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- item2 -> group2 -> group21 _/
+ item2 -> object2 -> object21 _/
*/
long long item2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, http_sig_table_name, MAAT_OP_ADD,
- item2_id, group2_id, "time=2020-02-11", "Cookie",
+ item2_id, object2_id, "time=2020-02-11", "Cookie",
0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
/*
- item1 -> group1 -> group11
+ item1 -> object1 -> object11
\
\ -> rule1
/
- item2 -> group2 -> group21 _/
+ item2 -> object2 -> object21 _/
*/
- long long group11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2group_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
- group11_id, group1_id, 0);
+ long long object11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2object_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
+ object11_id, object1_id, 0);
EXPECT_EQ(ret, 1);
- //item3 -> group3, group3 is not referenced by any rule.
+ //item3 -> object3, object3 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);
+ long long object3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 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);
+ object3_id, "220.181.38.148-220.181.38.149", 0);
EXPECT_EQ(ret, 1);
- //item4 -> group4, group4 is not referenced by any rule.
+ //item4 -> object4, object4 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);
+ long long object4_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
ret = expr_table_set_line(maat_inst, keywords_table_name, MAAT_OP_ADD,
- item4_id, group4_id,
+ item4_id, object4_id,
"a finite or infinite",
NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
@@ -9460,16 +9460,16 @@ TEST_F(MaatCmd, HitPathBasic) {
int path_idx = 0;
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
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].sub_object_id, object1_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object11_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, http_req_table_id);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
path_idx++;
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
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, -1);
+ EXPECT_EQ(hit_path[path_idx].sub_object_id, object1_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, -1);
EXPECT_EQ(hit_path[path_idx].attribute_id, http_req_table_id);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
@@ -9501,24 +9501,24 @@ TEST_F(MaatCmd, HitPathBasic) {
path_idx = 0;
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan-1);
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].sub_object_id, object1_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object11_id);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
path_idx++;
ASSERT_EQ(path_idx, 1);
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan-1);
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].sub_object_id, object1_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object1_id);
EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
path_idx++;
ASSERT_EQ(path_idx, 2);
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
EXPECT_EQ(hit_path[path_idx].item_id, item2_id);
- 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].sub_object_id, object2_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object21_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, http_res_table_id);
EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
@@ -9526,8 +9526,8 @@ TEST_F(MaatCmd, HitPathBasic) {
ASSERT_EQ(path_idx, 3);
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
EXPECT_EQ(hit_path[path_idx].item_id, item2_id);
- 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].sub_object_id, object2_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, -1);
EXPECT_EQ(hit_path[path_idx].attribute_id, http_res_table_id);
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 \
@@ -9560,8 +9560,8 @@ that the edges be all directed in the same direction.";
ASSERT_EQ(path_idx, 4);
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
EXPECT_EQ(hit_path[path_idx].item_id, item4_id);
- 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].sub_object_id, object4_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, -1);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
@@ -9590,8 +9590,8 @@ that the edges be all directed in the same direction.";
ASSERT_EQ(path_idx, 5);
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
EXPECT_EQ(hit_path[path_idx].item_id, item3_id);
- 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].sub_object_id, object3_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, -1);
EXPECT_EQ(hit_path[path_idx].attribute_id, ip_table_id);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
@@ -9614,8 +9614,8 @@ that the edges be all directed in the same direction.";
ASSERT_EQ(path_idx, 6);
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
EXPECT_EQ(hit_path[path_idx].item_id, item4_id);
- 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].sub_object_id, object4_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, -1);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
maat_stream_free(stream);
@@ -9623,23 +9623,23 @@ that the edges be all directed in the same direction.";
state = NULL;
}
-/* same group in multi rule */
+/* same object in multi rule */
/*
- item1 -> group1 -> rule1
+ item1 -> object1 -> rule1
/
/
- item2 -> group2 -> group21
+ item2 -> object2 -> object21
\
\
- item3 -> group3 -> rule2
+ item3 -> object3 -> rule2
\
\--> rule3
/
- item4 -> group4 -/
+ item4 -> object4 -/
*/
TEST_F(MaatCmd, HitPathAdvanced) {
- const char *g2g_table_name = "GROUP2GROUP";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2g_table_name = "OBJECT2OBJECT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
const char *rule_table_name = "RULE_DEFAULT";
const char *ip_table_name = "IP_CONFIG";
const char *keywords_table_name = "KEYWORDS_TABLE";
@@ -9653,46 +9653,46 @@ TEST_F(MaatCmd, HitPathAdvanced) {
rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- //group1 -> rule1
- long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule1_id, 0,
+ //object1 -> rule1
+ long long object1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule1_id, 0,
"KEYWORDS_TABLE", 1, 0); //condition_index:1
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> rule1
+ //item1 -> object1 -> 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,
+ item1_id, object1_id, "computer_theory", NULL,
0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- group21_/
+ object21_/
*/
- long long group21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group21_id, rule1_id, 0,
+ long long object21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object21_id, rule1_id, 0,
"KEYWORDS_TABLE", 2, 0); //condition_index:2
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- group2 -> group21 _/
+ object2 -> object21 _/
*/
- 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,
- group21_id, group2_id, 0);
+ long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2object_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
+ object21_id, object2_id, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- item2 -> group2 -> group21 _/
+ item2 -> object2 -> object21 _/
*/
long long item2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, keywords_table_name, MAAT_OP_ADD,
- item2_id, group2_id, "social_theory", NULL,
+ item2_id, object2_id, "social_theory", NULL,
0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
@@ -9702,42 +9702,42 @@ TEST_F(MaatCmd, HitPathAdvanced) {
rule2_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- item2 -> group2 -> group21 _/
+ item2 -> object2 -> object21 _/
\
\
rule2
*/
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group21_id, rule2_id, 0,
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object21_id, rule2_id, 0,
"KEYWORDS_TABLE", 3, 0); //condition_index:3
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- item2 -> group2 -> group21 _/
+ item2 -> object2 -> object21 _/
\
\
- item3 -> group3 -> rule2
+ item3 -> object3 -> 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);
+ long long object3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
ret = ip_table_set_line(maat_inst, ip_table_name, MAAT_OP_ADD, item3_id,
- group3_id, "220.181.38.168-220.181.38.169", 0);
+ object3_id, "220.181.38.168-220.181.38.169", 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group3_id, rule2_id, 0,
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object3_id, rule2_id, 0,
"IP_CONFIG", 4, 0); //condition_index:4
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- item2 -> group2 -> group21 _/
+ item2 -> object2 -> object21 _/
\
\
- item3 -> group3 -> rule2
+ item3 -> object3 -> rule2
\
\ --> rule3
*/
@@ -9746,35 +9746,35 @@ TEST_F(MaatCmd, HitPathAdvanced) {
rule3_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group3_id, rule3_id, 0,
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object3_id, rule3_id, 0,
"IP_CONFIG", 5, 0); //condition_index:5
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
/
- item2 -> group2 -> group21
+ item2 -> object2 -> object21
\
\
- item3 -> group3 -> rule2
+ item3 -> object3 -> rule2
\
\
rule3
/
/
- item4 -> group4
+ item4 -> object4
*/
long long item4_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
- long long group4_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
+ long long object4_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
ret = expr_table_set_line(maat_inst, keywords_table_name, MAAT_OP_ADD,
- item4_id, group4_id,
+ item4_id, object4_id,
"basic and advanced",
NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group4_id, rule3_id, 0,
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object4_id, rule3_id, 0,
"KEYWORDS_TABLE", 6, 0); //condition_index:6
EXPECT_EQ(ret, 1);
@@ -9801,8 +9801,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
int path_idx = 0;
EXPECT_EQ(hit_path[path_idx].Nth_scan, 1);
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, -1);
+ EXPECT_EQ(hit_path[path_idx].sub_object_id, object1_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, -1);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, -1);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
@@ -9820,8 +9820,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
path_idx = 0;
EXPECT_EQ(hit_path[path_idx].Nth_scan, 1);
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].sub_object_id, object1_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object1_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, 1);
EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
@@ -9830,8 +9830,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
ASSERT_EQ(path_idx, 1);
EXPECT_EQ(hit_path[path_idx].Nth_scan, 2);
EXPECT_EQ(hit_path[path_idx].item_id, item2_id);
- 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].sub_object_id, object2_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object21_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, 2);
EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
@@ -9840,8 +9840,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
ASSERT_EQ(path_idx, 2);
EXPECT_EQ(hit_path[path_idx].Nth_scan, 2);
EXPECT_EQ(hit_path[path_idx].item_id, item2_id);
- 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].sub_object_id, object2_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, -1);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, -1);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
@@ -9865,8 +9865,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
path_idx = 0;
EXPECT_EQ(hit_path[path_idx].Nth_scan, 1);
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].sub_object_id, object1_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object1_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, 1);
EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
@@ -9875,8 +9875,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
ASSERT_EQ(path_idx, 1);
EXPECT_EQ(hit_path[path_idx].Nth_scan, 2);
EXPECT_EQ(hit_path[path_idx].item_id, item2_id);
- 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].sub_object_id, object2_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object21_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, 3);
EXPECT_EQ(hit_path[path_idx].rule_id, rule2_id);
@@ -9885,8 +9885,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
ASSERT_EQ(path_idx, 2);
EXPECT_EQ(hit_path[path_idx].Nth_scan, 2);
EXPECT_EQ(hit_path[path_idx].item_id, item2_id);
- 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].sub_object_id, object2_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, -1);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, -1);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
@@ -9895,8 +9895,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
ASSERT_EQ(path_idx, 3);
EXPECT_EQ(hit_path[path_idx].Nth_scan, 3);
EXPECT_EQ(hit_path[path_idx].item_id, item3_id);
- EXPECT_EQ(hit_path[path_idx].sub_group_id, group3_id);
- EXPECT_EQ(hit_path[path_idx].top_group_id, group3_id);
+ EXPECT_EQ(hit_path[path_idx].sub_object_id, object3_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object3_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, ip_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, 4);
EXPECT_EQ(hit_path[path_idx].rule_id, rule2_id);
@@ -9905,8 +9905,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
ASSERT_EQ(path_idx, 4);
EXPECT_EQ(hit_path[path_idx].Nth_scan, 2);
EXPECT_EQ(hit_path[path_idx].item_id, item2_id);
- 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].sub_object_id, object2_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object21_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, 2);
EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
@@ -9926,8 +9926,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
path_idx = 0;
EXPECT_EQ(hit_path[path_idx].Nth_scan, 1);
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].sub_object_id, object1_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object1_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, 1);
EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
@@ -9936,8 +9936,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
ASSERT_EQ(path_idx, 1);
EXPECT_EQ(hit_path[path_idx].Nth_scan, 2);
EXPECT_EQ(hit_path[path_idx].item_id, item2_id);
- 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].sub_object_id, object2_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object21_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, 3);
EXPECT_EQ(hit_path[path_idx].rule_id, rule2_id);
@@ -9946,8 +9946,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
ASSERT_EQ(path_idx, 2);
EXPECT_EQ(hit_path[path_idx].Nth_scan, 2);
EXPECT_EQ(hit_path[path_idx].item_id, item2_id);
- 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].sub_object_id, object2_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, -1);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, -1);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
@@ -9956,8 +9956,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
ASSERT_EQ(path_idx, 3);
EXPECT_EQ(hit_path[path_idx].Nth_scan, 3);
EXPECT_EQ(hit_path[path_idx].item_id, item3_id);
- EXPECT_EQ(hit_path[path_idx].sub_group_id, group3_id);
- EXPECT_EQ(hit_path[path_idx].top_group_id, group3_id);
+ EXPECT_EQ(hit_path[path_idx].sub_object_id, object3_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object3_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, ip_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, 5);
EXPECT_EQ(hit_path[path_idx].rule_id, rule3_id);
@@ -9966,8 +9966,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
ASSERT_EQ(path_idx, 4);
EXPECT_EQ(hit_path[path_idx].Nth_scan, 4);
EXPECT_EQ(hit_path[path_idx].item_id, item4_id);
- EXPECT_EQ(hit_path[path_idx].sub_group_id, group4_id);
- EXPECT_EQ(hit_path[path_idx].top_group_id, group4_id);
+ EXPECT_EQ(hit_path[path_idx].sub_object_id, object4_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object4_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, 6);
EXPECT_EQ(hit_path[path_idx].rule_id, rule3_id);
@@ -9976,8 +9976,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
ASSERT_EQ(path_idx, 5);
EXPECT_EQ(hit_path[path_idx].Nth_scan, 3);
EXPECT_EQ(hit_path[path_idx].item_id, item3_id);
- EXPECT_EQ(hit_path[path_idx].sub_group_id, group3_id);
- EXPECT_EQ(hit_path[path_idx].top_group_id, group3_id);
+ EXPECT_EQ(hit_path[path_idx].sub_object_id, object3_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object3_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, ip_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, 4);
EXPECT_EQ(hit_path[path_idx].rule_id, rule2_id);
@@ -9986,8 +9986,8 @@ TEST_F(MaatCmd, HitPathAdvanced) {
ASSERT_EQ(path_idx, 6);
EXPECT_EQ(hit_path[path_idx].Nth_scan, 2);
EXPECT_EQ(hit_path[path_idx].item_id, item2_id);
- 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].sub_object_id, object2_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object21_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].condition_index, 2);
EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
@@ -9996,9 +9996,9 @@ TEST_F(MaatCmd, HitPathAdvanced) {
state = NULL;
}
-TEST_F(MaatCmd, HitPathHasNotGroup) {
- const char *g2g_table_name = "GROUP2GROUP";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+TEST_F(MaatCmd, HitPathHasNotObject) {
+ const char *g2g_table_name = "OBJECT2OBJECT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
const char *rule_table_name = "RULE_DEFAULT";
const char *http_sig_table_name = "HTTP_SIGNATURE";
const char *ip_table_name = "IP_CONFIG";
@@ -10013,72 +10013,72 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- // !group1 -> rule1
- long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule1_id, 1,
+ // !object1 -> rule1
+ long long object1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule1_id, 1,
"HTTP_REQUEST_HEADER", 1, 0);
EXPECT_EQ(ret, 1);
- // !(item1 -> group1) -> rule1
+ // !(item1 -> object1) -> 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*/
+ item1_id, object1_id, "math_theory", "URL", 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* !(item1 -> group1) -> rule1
+ /* !(item1 -> object1) -> rule1
/
- group21_/
+ object21_/
*/
- long long group21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group21_id, rule1_id, 0,
+ long long object21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object21_id, rule1_id, 0,
"HTTP_RESPONSE_HEADER", 2, 0);
EXPECT_EQ(ret, 1);
- /* !(item1 -> group1) -> rule1
+ /* !(item1 -> object1) -> rule1
/
- group2 -> group21 _/
+ object2 -> object21 _/
*/
- 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,
- group21_id, group2_id, 0);
+ long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2object_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
+ object21_id, object2_id, 0);
EXPECT_EQ(ret, 1);
- /* !(item1 -> group1) -> rule1
+ /* !(item1 -> object1) -> rule1
/
- item2 -> group2 -> group21 _/
+ item2 -> object2 -> object21 _/
*/
long long item2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = expr_table_set_line(maat_inst, http_sig_table_name, MAAT_OP_ADD,
- item2_id, group2_id, "time=2020-02-12", "Cookie",
+ item2_id, object2_id, "time=2020-02-12", "Cookie",
0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
/*
- item1 -> group1 -> group11
+ item1 -> object1 -> object11
- !(item1 -> group1) -> rule1
+ !(item1 -> object1) -> rule1
/
- item2 -> group2 -> group21 _/
+ item2 -> object2 -> object21 _/
*/
- long long group11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2group_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
- group11_id, group1_id, 0);
+ long long object11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2object_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
+ object11_id, object1_id, 0);
EXPECT_EQ(ret, 1);
- //item3 -> group3, group3 is not referenced by any rule.
+ //item3 -> object3, object3 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);
+ long long object3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 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);
+ object3_id, "220.181.38.158-220.181.38.159", 0);
EXPECT_EQ(ret, 1);
- //item4 -> group4, group4 is not referenced by any rule.
+ //item4 -> object4, object4 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);
+ long long object4_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
ret = expr_table_set_line(maat_inst, keywords_table_name, MAAT_OP_ADD,
- item4_id, group4_id,
+ item4_id, object4_id,
"a finite and infinite",
NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
@@ -10119,8 +10119,8 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
int path_idx = 0;
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
EXPECT_EQ(hit_path[path_idx].item_id, -1);
- 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].sub_object_id, object1_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object11_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, http_req_table_id);
EXPECT_EQ(hit_path[path_idx].negate_option, 1);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
@@ -10128,8 +10128,8 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
path_idx++;
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
EXPECT_EQ(hit_path[path_idx].item_id, -1);
- 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].sub_object_id, object1_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, -1);
EXPECT_EQ(hit_path[path_idx].attribute_id, http_req_table_id);
EXPECT_EQ(hit_path[path_idx].negate_option, 1);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
@@ -10162,8 +10162,8 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
path_idx = 0;
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan-1);
EXPECT_EQ(hit_path[path_idx].item_id, -1);
- 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].sub_object_id, object1_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object11_id);
EXPECT_EQ(hit_path[path_idx].negate_option, 1);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
@@ -10171,8 +10171,8 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
ASSERT_EQ(path_idx, 1);
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan-1);
EXPECT_EQ(hit_path[path_idx].item_id, -1);
- 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].sub_object_id, object1_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object1_id);
EXPECT_EQ(hit_path[path_idx].negate_option, 1);
EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
@@ -10180,8 +10180,8 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
ASSERT_EQ(path_idx, 2);
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
EXPECT_EQ(hit_path[path_idx].item_id, item2_id);
- 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].sub_object_id, object2_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object21_id);
EXPECT_EQ(hit_path[path_idx].attribute_id, http_res_table_id);
EXPECT_EQ(hit_path[path_idx].negate_option, 0);
EXPECT_EQ(hit_path[path_idx].rule_id, rule1_id);
@@ -10190,8 +10190,8 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
ASSERT_EQ(path_idx, 3);
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
EXPECT_EQ(hit_path[path_idx].item_id, item2_id);
- 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].sub_object_id, object2_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, -1);
EXPECT_EQ(hit_path[path_idx].attribute_id, http_res_table_id);
EXPECT_EQ(hit_path[path_idx].negate_option, 0);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
@@ -10222,8 +10222,8 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
ASSERT_EQ(path_idx, 4);
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
EXPECT_EQ(hit_path[path_idx].item_id, item4_id);
- 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].sub_object_id, object4_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, -1);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].negate_option, 0);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
@@ -10252,8 +10252,8 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
ASSERT_EQ(path_idx, 5);
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
EXPECT_EQ(hit_path[path_idx].item_id, item3_id);
- 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].sub_object_id, object3_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, -1);
EXPECT_EQ(hit_path[path_idx].attribute_id, ip_table_id);
EXPECT_EQ(hit_path[path_idx].negate_option, 0);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
@@ -10277,8 +10277,8 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
ASSERT_EQ(path_idx, 6);
EXPECT_EQ(hit_path[path_idx].Nth_scan, Nth_scan);
EXPECT_EQ(hit_path[path_idx].item_id, item4_id);
- 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].sub_object_id, object4_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, -1);
EXPECT_EQ(hit_path[path_idx].attribute_id, keywords_table_id);
EXPECT_EQ(hit_path[path_idx].negate_option, 0);
EXPECT_EQ(hit_path[path_idx].rule_id, -1);
@@ -10288,29 +10288,29 @@ TEST_F(MaatCmd, HitPathHasNotGroup) {
state = NULL;
}
-TEST_F(MaatCmd, SameSuperGroupRefByMultiRule) {
+TEST_F(MaatCmd, SameSuperObjectRefByMultiRule) {
int thread_id = 0;
- const char *g2g_table_name = "GROUP2GROUP";
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2g_table_name = "OBJECT2OBJECT";
+ const char *g2c_table_name = "OBJECT2RULE_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 -> rule2
+ /* item5 -> object5 -> object52 -> rule2
\
\ -> 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);
+ long long object5_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 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 rule",
+ item5_id, object5_id,
+ "same superobject referenced by multi rule",
"KEY", 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- long long group52_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2group_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
- group52_id, group5_id, 0);
+ long long object52_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2object_table_set_line(maat_inst, g2g_table_name, MAAT_OP_ADD,
+ object52_id, object5_id, 0);
EXPECT_EQ(ret, 1);
long long rule2_id = maat_cmd_incrby(maat_inst, "TEST_SEQ", 1);
@@ -10318,8 +10318,8 @@ TEST_F(MaatCmd, SameSuperGroupRefByMultiRule) {
rule2_id, "HTTP_RESPONSE_HEADER", 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group52_id, rule2_id, 0,
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object52_id, rule2_id, 0,
"HTTP_RESPONSE_HEADER", 0, 0);
EXPECT_EQ(ret, 1);
@@ -10328,8 +10328,8 @@ TEST_F(MaatCmd, SameSuperGroupRefByMultiRule) {
rule3_id, "HTTP_RESPONSE_HEADER", 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group52_id, rule3_id, 0,
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object52_id, rule3_id, 0,
"HTTP_RESPONSE_HEADER", 0, 0);
EXPECT_EQ(ret, 1);
@@ -10342,7 +10342,7 @@ TEST_F(MaatCmd, SameSuperGroupRefByMultiRule) {
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 rule";
+ const char *http_res_key_str = "same superobject referenced by multi rule";
long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0;
struct maat_hit_path hit_path[128];
@@ -10366,22 +10366,22 @@ TEST_F(MaatCmd, SameSuperGroupRefByMultiRule) {
int path_idx = 0;
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].sub_object_id, object5_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object52_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].sub_object_id, object5_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_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].sub_object_id, object5_id);
+ EXPECT_EQ(hit_path[path_idx].top_object_id, object52_id);
EXPECT_EQ(hit_path[path_idx].rule_id, rule2_id);
maat_state_free(state);
@@ -10389,7 +10389,7 @@ TEST_F(MaatCmd, SameSuperGroupRefByMultiRule) {
}
TEST_F(MaatCmd, SameScanStatusWhenConditionUpdate_TSG6419) {
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
const char* rule_table_name = "RULE_DEFAULT";
const char* ip_table_name = "IP_PLUS_CONFIG";
const char *app_id_table_name = "APP_ID";
@@ -10402,28 +10402,28 @@ TEST_F(MaatCmd, SameScanStatusWhenConditionUpdate_TSG6419) {
rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- /* item11 -> group11 -> condition1 -> rule1
+ /* item11 -> object11 -> condition1 -> rule1
/
- item21 -> group21 -> condition2 _/
+ item21 -> object21 -> condition2 _/
*/
- long long group11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group11_id, rule1_id, 0, ip_table_name, 1, 0);
+ long long object11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object11_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);
ret = ip_table_set_line(maat_inst, ip_table_name, MAAT_OP_ADD, item11_id,
- group11_id, "192.168.2.1-192.168.2.4", 0);
+ object11_id, "192.168.2.1-192.168.2.4", 0);
EXPECT_EQ(ret, 1);
- long long group21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group21_id, rule1_id, 0, app_id_table_name, 2, 0);
+ long long object21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object21_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);
ret = interval_table_set_line(maat_inst, app_id_table_name, MAAT_OP_ADD,
- item21_id, group21_id, "31", NULL, 0);
+ item21_id, object21_id, "31", NULL, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -10451,10 +10451,10 @@ TEST_F(MaatCmd, SameScanStatusWhenConditionUpdate_TSG6419) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
- /* item11 -> group11 -> condition1 -> rule1
+ /* item11 -> object11 -> condition1 -> rule1
/
- item21 -> group21 -> condition2 _/
- item22 -> group22 -> condition3 _/
+ item21 -> object21 -> condition2 _/
+ item22 -> object22 -> condition3 _/
*/
ret = rule_table_set_line(maat_inst, rule_table_name, MAAT_OP_DEL,
rule1_id, "null", 2, 0);
@@ -10463,14 +10463,14 @@ TEST_F(MaatCmd, SameScanStatusWhenConditionUpdate_TSG6419) {
rule1_id, "null", 3, 0);
EXPECT_EQ(ret, 1);
- long long group22_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group22_id, rule1_id, 0, app_id_table_name, 3, 0);
+ long long object22_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object22_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);
ret = interval_table_set_line(maat_inst, app_id_table_name, MAAT_OP_ADD,
- item22_id, group22_id, "32", NULL, 0);
+ item22_id, object22_id, "32", NULL, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -10498,8 +10498,8 @@ TEST_F(MaatCmd, SameScanStatusWhenConditionUpdate_TSG6419) {
state = NULL;
}
-TEST_F(MaatCmd, GroupEdit) {
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+TEST_F(MaatCmd, ObjectEdit) {
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
const char *rule_table_name = "RULE_DEFAULT";
const char *ip_table_name = "IP_PLUS_CONFIG";
const char *app_id_table_name = "APP_ID";
@@ -10512,27 +10512,27 @@ TEST_F(MaatCmd, GroupEdit) {
rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- /* item11 -> group11 -> condition1 -> rule1
- item21 -> group21 -> condition2 _/
+ /* item11 -> object11 -> condition1 -> rule1
+ item21 -> object21 -> condition2 _/
*/
- long long group11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group11_id, rule1_id, 0, ip_table_name, 1, 0);
+ long long object11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object11_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);
ret = ip_table_set_line(maat_inst, ip_table_name, MAAT_OP_ADD, item11_id,
- group11_id, "192.168.3.1-192.168.3.4", 0);
+ object11_id, "192.168.3.1-192.168.3.4", 0);
EXPECT_EQ(ret, 1);
- long long group21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group21_id, rule1_id, 0, app_id_table_name, 2, 0);
+ long long object21_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object21_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);
ret = interval_table_set_line(maat_inst, app_id_table_name, MAAT_OP_ADD,
- item21_id, group21_id, "41", NULL, 0);
+ item21_id, object21_id, "41", NULL, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -10568,15 +10568,15 @@ TEST_F(MaatCmd, GroupEdit) {
maat_state_reset(state);
- /* item11 -> group11 -> condition1 -> rule1
- item21 -> group21 -> condition2 _/
+ /* item11 -> object11 -> condition1 -> rule1
+ item21 -> object21 -> condition2 _/
item22 -> /
*/
char scan_app_id_str[8] = {0};
snprintf(scan_app_id_str, sizeof(scan_app_id_str), "%d", scan_app_id);
long long item22_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = interval_table_set_line(maat_inst, app_id_table_name, MAAT_OP_ADD,
- item22_id, group21_id, scan_app_id_str, NULL, 0);
+ item22_id, object21_id, scan_app_id_str, NULL, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -10608,11 +10608,11 @@ TEST_F(MaatCmd, GroupEdit) {
EXPECT_EQ(n_read, 2);
maat_state_reset(state);
- /* item11 -> group11 -> condition1 -> rule1
- item21 -> group21 -> condition2 _/
+ /* item11 -> object11 -> condition1 -> rule1
+ item21 -> object21 -> condition2 _/
*/
ret = interval_table_set_line(maat_inst, app_id_table_name, MAAT_OP_DEL,
- item22_id, group21_id, scan_app_id_str, NULL, 0);
+ item22_id, object21_id, scan_app_id_str, NULL, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -10641,7 +10641,7 @@ TEST_F(MaatCmd, GroupEdit) {
}
TEST_F(MaatCmd, RuleDelete_TSG6548) {
- const char* g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char* g2c_table_name = "OBJECT2RULE_DEFAULT";
const char* rule_table_name = "RULE_DEFAULT";
const char* ip_table_name = "IP_PLUS_CONFIG";
int thread_id = 0;
@@ -10653,15 +10653,15 @@ TEST_F(MaatCmd, RuleDelete_TSG6548) {
rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //item11 -> group11 -> condition1 -> rule1
- long long group11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group11_id, rule1_id, 0, ip_table_name, 1, 0);
+ //item11 -> object11 -> condition1 -> rule1
+ long long object11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object11_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);
ret = ip_table_set_line(maat_inst, ip_table_name, MAAT_OP_ADD, item11_id,
- group11_id, "192.168.73.163-192.168.73.180", 0);
+ object11_id, "192.168.73.163-192.168.73.180", 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -10689,8 +10689,8 @@ TEST_F(MaatCmd, RuleDelete_TSG6548) {
rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
- group11_id, rule1_id, 0, ip_table_name, 1, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_DEL,
+ object11_id, rule1_id, 0, ip_table_name, 1, 0);
EXPECT_EQ(ret, 1);
int hit_cnt = 0;
@@ -10716,7 +10716,7 @@ TEST_F(MaatCmd, RuleDelete_TSG6548) {
}
TEST_F(MaatCmd, UpdateDeadLockDetection) {
- const char* g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char* g2c_table_name = "OBJECT2RULE_DEFAULT";
const char* rule_table_name = "RULE_DEFAULT";
const char* table_http_url = "HTTP_URL";
int thread_id = 0;
@@ -10728,16 +10728,16 @@ TEST_F(MaatCmd, UpdateDeadLockDetection) {
rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //group1 -> rule1
- long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule1_id, 0, table_http_url, 0, 0);
+ //object1 -> rule1
+ long long object1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule1_id, 0, table_http_url, 0, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> rule1
+ //item1 -> object1 -> 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*/
+ object1_id, "part-1", NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -10766,16 +10766,16 @@ TEST_F(MaatCmd, UpdateDeadLockDetection) {
rule2_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //group2 -> rule2
- long long group2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, rule2_id, 0, table_http_url, 0, 0);
+ //object2 -> rule2
+ long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object2_id, rule2_id, 0, table_http_url, 0, 0);
EXPECT_EQ(ret, 1);
- //item2 -> group2 -> rule2
+ //item2 -> object2 -> 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*/
+ object2_id, "part-2", NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
//DON'T DO THIS!!!
@@ -10801,7 +10801,7 @@ TEST_F(MaatCmd, UpdateDeadLockDetection) {
}
TEST_F(MaatCmd, StreamScanWhenExprTableIncUpdate) {
- const char* g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char* g2c_table_name = "OBJECT2RULE_DEFAULT";
const char* rule_table_name = "RULE_DEFAULT";
const char* scan_table_name = "KEYWORDS_TABLE";
int thread_id = 0;
@@ -10813,10 +10813,10 @@ TEST_F(MaatCmd, StreamScanWhenExprTableIncUpdate) {
rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //group1 -> rule1
- long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule1_id, 0, scan_table_name, 0, 0);
+ //object1 -> rule1
+ long long object1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule1_id, 0, scan_table_name, 0, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S);
@@ -10837,10 +10837,10 @@ TEST_F(MaatCmd, StreamScanWhenExprTableIncUpdate) {
&n_hit_result, state);
EXPECT_EQ(ret, MAAT_SCAN_OK);
- //item1 -> group1 -> rule1
+ //item1 -> object1 -> 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",
+ item1_id, object1_id, "stream-keywords-001-inc-update",
NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
@@ -10876,7 +10876,7 @@ TEST_F(MaatCmd, StreamScanWhenExprTableIncUpdate) {
}
TEST_F(MaatCmd, StreamScanSegfaultWhenVersionRollBack_TSG6324) {
- const char* g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char* g2c_table_name = "OBJECT2RULE_DEFAULT";
const char* rule_table_name = "RULE_DEFAULT";
const char* scan_table_name = "KEYWORDS_TABLE";
int thread_id = 0;
@@ -10888,16 +10888,16 @@ TEST_F(MaatCmd, StreamScanSegfaultWhenVersionRollBack_TSG6324) {
rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //group1 -> rule1
- long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule1_id, 0, scan_table_name, 0, 0);
+ //object1 -> rule1
+ long long object1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule1_id, 0, scan_table_name, 0, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> rule1
+ //item1 -> object1 -> 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*/
+ object1_id, "stream-keywords-002", NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -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 condition 2 of rule 979 failed, group is already existed
+ //For example: Add object 22 vt_id 0 to condition 2 of rule 979 failed, object is already existed
maat_cmd_incrby(maat_inst, "MAAT_VERSION", -100);
//Wating for scanner garbage collect expiration.
@@ -10943,7 +10943,7 @@ TEST_F(MaatCmd, StreamScanSegfaultWhenVersionRollBack_TSG6324) {
}
TEST_F(MaatCmd, IPAndStreamScanWhenIncUpdate) {
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
const char *rule_table_name = "RULE_DEFAULT";
const char *expr_table_name = "KEYWORDS_TABLE";
const char *ip_table_name = "IP_PLUS_CONFIG";
@@ -10956,30 +10956,30 @@ TEST_F(MaatCmd, IPAndStreamScanWhenIncUpdate) {
rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- //group1 -> rule1
- long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule1_id, 0, expr_table_name, 0, 0);
+ //object1 -> rule1
+ long long object1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule1_id, 0, expr_table_name, 0, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> rule1
+ //item1 -> object1 -> 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*/
+ object1_id, "stream-keywords-003", NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- item2 -> group2 --/
+ item2 -> object2 --/
*/
long long item2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
- long long group2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
+ long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
ret = ip_table_set_line(maat_inst, ip_table_name, MAAT_OP_ADD, item2_id,
- group2_id, "100.100.100.1", 0);
+ object2_id, "100.100.100.1", 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, rule1_id, 0, ip_table_name, 1, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object2_id, rule1_id, 0, ip_table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -11044,7 +11044,7 @@ TEST_F(MaatCmd, IPAndStreamScanWhenIncUpdate) {
}
TEST_F(MaatCmd, IPAndStreamScanWhenFullUpdate) {
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
const char *rule_table_name = "RULE_DEFAULT";
const char *ip_table_name = "IP_PLUS_CONFIG";
const char *expr_table_name = "KEYWORDS_TABLE";
@@ -11057,31 +11057,31 @@ TEST_F(MaatCmd, IPAndStreamScanWhenFullUpdate) {
rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //group1 -> rule1
- long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule1_id, 0, expr_table_name, 0, 0);
+ //object1 -> rule1
+ long long object1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule1_id, 0, expr_table_name, 0, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> rule1
+ //item1 -> object1 -> 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",
+ item1_id, object1_id, "stream-keywords-004",
NULL, 0, 0); /*EXPR_TYPE_STRING MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- item2 -> group2 --/
+ item2 -> object2 --/
*/
long long item2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
- long long group2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
+ long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
ret = ip_table_set_line(maat_inst, ip_table_name, MAAT_OP_ADD,
- item2_id, group2_id, "100.100.100.2", 0);
+ item2_id, object2_id, "100.100.100.2", 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, rule1_id, 0, ip_table_name, 1, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object2_id, rule1_id, 0, ip_table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -11144,7 +11144,7 @@ TEST_F(MaatCmd, IPAndStreamScanWhenFullUpdate) {
}
TEST_F(MaatCmd, IPAndStringScanWhenIncUpdate) {
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
const char *rule_table_name = "RULE_DEFAULT";
const char *expr_table_name = "HTTP_URL";
const char *ip_table_name = "IP_PLUS_CONFIG";
@@ -11158,30 +11158,30 @@ TEST_F(MaatCmd, IPAndStringScanWhenIncUpdate) {
rule1_id, "null", 2, 0);
EXPECT_EQ(ret, 1);
- //group1 -> rule1
- long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule1_id, 0, expr_table_name, 0, 0);
+ //object1 -> rule1
+ long long object1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule1_id, 0, expr_table_name, 0, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> rule1
+ //item1 -> object1 -> 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*/
+ object1_id, keywords, NULL, 1, 0); /*EXPR_TYPE_AND MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- item2 -> group2 --/
+ item2 -> object2 --/
*/
long long item2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
- long long group2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
+ long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
ret = ip_table_set_line(maat_inst, ip_table_name, MAAT_OP_ADD, item2_id,
- group2_id, "100.100.100.1", 0);
+ object2_id, "100.100.100.1", 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, rule1_id, 0, ip_table_name, 1, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object2_id, rule1_id, 0, ip_table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -11244,7 +11244,7 @@ TEST_F(MaatCmd, IPAndStringScanWhenIncUpdate) {
}
TEST_F(MaatCmd, IPAndStringScanWhenFullupdate) {
- const char *g2c_table_name = "GROUP2RULE_DEFAULT";
+ const char *g2c_table_name = "OBJECT2RULE_DEFAULT";
const char *rule_table_name = "RULE_DEFAULT";
const char *ip_table_name = "IP_PLUS_CONFIG";
const char *expr_table_name = "HTTP_URL";
@@ -11258,30 +11258,30 @@ TEST_F(MaatCmd, IPAndStringScanWhenFullupdate) {
rule1_id, "null", 1, 0);
EXPECT_EQ(ret, 1);
- //group1 -> rule1
- long long group1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group1_id, rule1_id, 0, expr_table_name, 0, 0);
+ //object1 -> rule1
+ long long object1_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object1_id, rule1_id, 0, expr_table_name, 0, 0);
EXPECT_EQ(ret, 1);
- //item1 -> group1 -> rule1
+ //item1 -> object1 -> 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*/
+ object1_id, keywords, "null", 1, 0); /*EXPR_TYPE_AND MATCH_METHOD_SUB*/
EXPECT_EQ(ret, 1);
- /* item1 -> group1 -> rule1
+ /* item1 -> object1 -> rule1
/
- item2 -> group2 --/
+ item2 -> object2 --/
*/
long long item2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
- long long group2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
+ long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
ret = ip_table_set_line(maat_inst, ip_table_name, MAAT_OP_ADD, item2_id,
- group2_id, "100.100.100.3", 0);
+ object2_id, "100.100.100.3", 0);
EXPECT_EQ(ret, 1);
- ret = group2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
- group2_id, rule1_id, 0, ip_table_name, 1, 0);
+ ret = object2rule_table_set_line(maat_inst, g2c_table_name, MAAT_OP_ADD,
+ object2_id, rule1_id, 0, ip_table_name, 1, 0);
EXPECT_EQ(ret, 1);
sleep(WAIT_FOR_EFFECTIVE_S * 2);
@@ -11435,7 +11435,7 @@ static int clear_config_in_redis(redisContext *c, struct log_handle *logger)
append_cmd_cnt++;
redisAppendCommand(c, "SET %s 1", mr_region_id_var);
append_cmd_cnt++;
- redisAppendCommand(c, "SET %s 1", mr_group_id_var);
+ redisAppendCommand(c, "SET %s 1", mr_object_id_var);
append_cmd_cnt++;
redisAppendCommand(c, "EXEC");
append_cmd_cnt++;
diff --git a/test/maat_framework_perf_gtest.cpp b/test/maat_framework_perf_gtest.cpp
index 6dcc07f..f7e7857 100644
--- a/test/maat_framework_perf_gtest.cpp
+++ b/test/maat_framework_perf_gtest.cpp
@@ -40,15 +40,15 @@ test_add_expr_command(struct maat *maat_inst, const char *table_name,
1, 0);
EXPECT_EQ(ret, 1);
- long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, "GROUP2RULE_DEFAULT",
- MAAT_OP_ADD, group_id, rule_id,
+ long long object_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, "OBJECT2RULE_DEFAULT",
+ MAAT_OP_ADD, object_id, rule_id,
0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
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,
- group_id, keywords, "null", 1, 0);
+ object_id, keywords, "null", 1, 0);
EXPECT_EQ(ret, 1);
}
@@ -62,15 +62,15 @@ test_add_ip_command(struct maat *maat_inst, const char *table_name,
1, 0);
EXPECT_EQ(ret, 1);
- long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, "GROUP2RULE_DEFAULT",
- MAAT_OP_ADD, group_id, rule_id,
+ long long object_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, "OBJECT2RULE_DEFAULT",
+ MAAT_OP_ADD, object_id, rule_id,
0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
long long item_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = ip_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item_id,
- group_id, ip, 0);
+ object_id, ip, 0);
EXPECT_EQ(ret, 1);
}
@@ -84,9 +84,9 @@ test_add_integer_command(struct maat *maat_inst, const char *table_name,
1, 0);
EXPECT_EQ(ret, 1);
- long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, "GROUP2RULE_DEFAULT",
- MAAT_OP_ADD, group_id, rule_id,
+ long long object_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, "OBJECT2RULE_DEFAULT",
+ MAAT_OP_ADD, object_id, rule_id,
0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
@@ -94,7 +94,7 @@ test_add_integer_command(struct maat *maat_inst, const char *table_name,
char interval_range_str[64] = {0};
snprintf(interval_range_str, sizeof(interval_range_str), "%d-%d", low_boundary, up_boundary);
ret = interval_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item_id,
- group_id, interval_range_str, NULL, 0);
+ object_id, interval_range_str, NULL, 0);
EXPECT_EQ(ret, 1);
}
@@ -108,15 +108,15 @@ test_add_flag_command(struct maat *maat_inst, const char *table_name,
1, 0);
EXPECT_EQ(ret, 1);
- long long group_id = maat_cmd_incrby(maat_inst, "SEQUENCE_GROUP", 1);
- ret = group2rule_table_set_line(maat_inst, "GROUP2RULE_DEFAULT",
- MAAT_OP_ADD, group_id, rule_id,
+ long long object_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
+ ret = object2rule_table_set_line(maat_inst, "OBJECT2RULE_DEFAULT",
+ MAAT_OP_ADD, object_id, rule_id,
0, table_name, 1, 0);
EXPECT_EQ(ret, 1);
long long item_id = maat_cmd_incrby(maat_inst, "SEQUENCE_REGION", 1);
ret = flag_table_set_line(maat_inst, table_name, MAAT_OP_ADD, item_id,
- group_id, flag, flag_mask, 0);
+ object_id, flag, flag_mask, 0);
EXPECT_EQ(ret, 1);
}
diff --git a/test/maat_json.json b/test/maat_json.json
index 311b42c..adc147a 100644
--- a/test/maat_json.json
+++ b/test/maat_json.json
@@ -1,11 +1,11 @@
{
"rule_table": "RULE_DEFAULT",
- "group2rule_table": "GROUP2RULE_DEFAULT",
- "group2group_table": "GROUP2GROUP",
- "groups": [
+ "object2rule_table": "OBJECT2RULE_DEFAULT",
+ "object2object_table": "OBJECT2OBJECT",
+ "objects": [
{
- "group_name": "ASN1234",
- "group_id": 1,
+ "object_name": "ASN1234",
+ "object_id": 1,
"regions": [
{
"table_name": "AS_NUMBER",
@@ -18,8 +18,8 @@
]
},
{
- "group_name": "ASN2345",
- "group_id": 2,
+ "object_name": "ASN2345",
+ "object_id": 2,
"regions": [
{
"table_name": "AS_NUMBER",
@@ -32,8 +32,8 @@
]
},
{
- "group_name": "ASN6789",
- "group_id": 3,
+ "object_name": "ASN6789",
+ "object_id": 3,
"regions": [
{
"table_name": "AS_NUMBER",
@@ -46,8 +46,8 @@
]
},
{
- "group_name": "ASN9001",
- "group_id": 4,
+ "object_name": "ASN9001",
+ "object_id": 4,
"regions": [
{
"table_name": "AS_NUMBER",
@@ -60,8 +60,8 @@
]
},
{
- "group_name": "ASN9002",
- "group_id": 5,
+ "object_name": "ASN9002",
+ "object_id": 5,
"regions": [
{
"table_name": "AS_NUMBER",
@@ -74,8 +74,8 @@
]
},
{
- "group_name": "ASN9003",
- "group_id": 6,
+ "object_name": "ASN9003",
+ "object_id": 6,
"regions": [
{
"table_name": "AS_NUMBER",
@@ -88,8 +88,8 @@
]
},
{
- "group_name": "IPv4-composition-source-only",
- "group_id": 7,
+ "object_name": "IPv4-composition-source-only",
+ "object_id": 7,
"regions": [
{
"table_type":"ip",
@@ -101,8 +101,8 @@
]
},
{
- "group_name": "FQDN_OBJ1",
- "group_id": 8,
+ "object_name": "FQDN_OBJ1",
+ "object_id": 8,
"regions": [
{
"table_name": "KEYWORDS_TABLE",
@@ -115,8 +115,8 @@
]
},
{
- "group_name": "FQDN_CAT1",
- "group_id": 9,
+ "object_name": "FQDN_CAT1",
+ "object_id": 9,
"regions": [
{
"table_name": "INTERGER_PLUS",
@@ -129,8 +129,8 @@
]
},
{
- "group_name": "IPv4-composition-NOT-client-ip",
- "group_id": 10,
+ "object_name": "IPv4-composition-NOT-client-ip",
+ "object_id": 10,
"regions": [
{
"table_type":"ip",
@@ -142,8 +142,8 @@
]
},
{
- "group_name": "IPv4-composition-NOT-server-ip",
- "group_id": 11,
+ "object_name": "IPv4-composition-NOT-server-ip",
+ "object_id": 11,
"regions": [
{
"table_type":"ip",
@@ -155,8 +155,8 @@
]
},
{
- "group_name": "financial-department-ip",
- "group_id": 12,
+ "object_name": "financial-department-ip",
+ "object_id": 12,
"regions": [
{
"table_name": "IP_CONFIG",
@@ -168,8 +168,8 @@
]
},
{
- "group_name": "security-department-ip",
- "group_id": 13,
+ "object_name": "security-department-ip",
+ "object_id": 13,
"regions": [
{
"table_name": "IP_PLUS_CONFIG",
@@ -181,8 +181,8 @@
]
},
{
- "group_name": "develop-department-ip",
- "group_id": 14,
+ "object_name": "develop-department-ip",
+ "object_id": 14,
"regions": [
{
"table_name": "IP_PLUS_CONFIG",
@@ -194,8 +194,8 @@
]
},
{
- "group_name": "Country-Sparta-IP",
- "group_id": 15,
+ "object_name": "Country-Sparta-IP",
+ "object_id": 15,
"regions": [
{
"table_name": "GeoLocation",
@@ -217,11 +217,11 @@
"do_log": 1,
"user_region": "escaped\\bdata:have\\ba\\bspace\\band\\ba\\b\\&\\bsymbol.",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "IP_CONFIG",
- "group_name": "123_IP_group",
- "group_id": 100,
+ "object_name": "123_IP_object",
+ "object_id": 100,
"regions": [
{
"table_name": "IP_CONFIG",
@@ -241,8 +241,8 @@
},
{
"attribute": "HTTP_URL",
- "group_name": "123_url_group",
- "group_id": 101,
+ "object_name": "123_url_object",
+ "object_id": 101,
"regions": [
{
"table_name": "HTTP_URL",
@@ -264,15 +264,15 @@
"do_log": 1,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute":"IP_CONFIG",
- "group_name": "123_IP_group"
+ "object_name": "123_IP_object"
},
{
"attribute": "CONTENT_SIZE",
- "group_name": "124_interval_group",
- "group_id": 102,
+ "object_name": "124_interval_object",
+ "object_id": 102,
"regions": [
{
"table_name": "CONTENT_SIZE",
@@ -293,11 +293,11 @@
"do_log": 1,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute":"HTTP_URL",
- "group_name": "125_url_group",
- "group_id": 103,
+ "object_name": "125_url_object",
+ "object_id": 103,
"regions": [
{
"table_name": "HTTP_URL",
@@ -319,11 +319,11 @@
"do_log": 1,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "126_url_group",
- "group_id": 105,
+ "object_name": "126_url_object",
+ "object_id": 105,
"regions": [
{
"table_name": "HTTP_URL",
@@ -337,8 +337,8 @@
},
{
"attribute": "CONTENT_SIZE",
- "group_name": "126_interval_group",
- "group_id": 106,
+ "object_name": "126_interval_object",
+ "object_id": 106,
"regions": [
{
"table_name": "CONTENT_SIZE",
@@ -359,11 +359,11 @@
"do_log": 1,
"user_region": "StringScan.ExprPlus",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_SIGNATURE",
- "group_name": "128_expr_plus_group",
- "group_id": 107,
+ "object_name": "128_expr_plus_object",
+ "object_id": 107,
"regions": [
{
"table_name": "HTTP_SIGNATURE",
@@ -386,11 +386,11 @@
"do_log": 1,
"user_region": "utf8_中文",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "129_url_group",
- "group_id": 108,
+ "object_name": "129_url_object",
+ "object_id": 108,
"regions": [
{
"table_name": "HTTP_URL",
@@ -412,11 +412,11 @@
"do_log": 1,
"user_region": "utf8_维语",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "130_keywords_group",
- "group_id": 109,
+ "object_name": "130_keywords_object",
+ "object_id": 109,
"regions": [
{
"table_name": "KEYWORDS_TABLE",
@@ -438,11 +438,11 @@
"do_log": 1,
"user_region": "utf8_维语2",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "131_keywords_group",
- "group_id": 110,
+ "object_name": "131_keywords_object",
+ "object_id": 110,
"regions": [
{
"table_name": "KEYWORDS_TABLE",
@@ -464,11 +464,11 @@
"do_log": 1,
"user_region": "string\\bunescape",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "TakeMeHome",
- "group_id": 111,
+ "object_name": "TakeMeHome",
+ "object_id": 111,
"regions": [
{
"table_name": "KEYWORDS_TABLE",
@@ -490,11 +490,11 @@
"do_log": 1,
"user_region": "13018_table_conjunction_test_part1\bnow_its_very_very_long0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz0123456789abcdefghijklmnopkrstuvwxyz",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_HOST",
- "group_name": "133_host_group",
- "group_id": 112,
+ "object_name": "133_host_object",
+ "object_id": 112,
"regions": [
{
"table_name": "HTTP_HOST",
@@ -516,11 +516,11 @@
"do_log": 1,
"user_region": "table_conjunction_test_part2",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "134_url_group",
- "group_id": 113,
+ "object_name": "134_url_object",
+ "object_id": 113,
"regions": [
{
"table_name": "HTTP_URL",
@@ -542,11 +542,11 @@
"do_log": 1,
"user_region": "offset_string",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "IMAGE_FP",
- "group_name": "136_expr_group",
- "group_id": 114,
+ "object_name": "136_expr_object",
+ "object_id": 114,
"regions": [
{
"table_name": "IMAGE_FP",
@@ -568,11 +568,11 @@
"do_log": 1,
"user_region": "offset_string",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "IMAGE_FP",
- "group_name": "137_expr_group",
- "group_id": 115,
+ "object_name": "137_expr_object",
+ "object_id": 115,
"regions": [
{
"table_name": "IMAGE_FP",
@@ -596,11 +596,11 @@
"tags": "{\"tag_sets\":[[{\"tag\":\"location\",\"value\":[\"北京/朝阳/华严北里\",\"上海/浦东/陆家嘴\"]},{\"tag\":\"isp\",\"value\":[\"电信\",\"联通\"]}],[{\"tag\":\"location\",\"value\":[\"北京\"]},{\"tag\":\"isp\",\"value\":[\"联通\"]}]]}",
"user_region": "Not\\baccepted\\btags",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "138_url_group",
- "group_id": 116,
+ "object_name": "138_url_object",
+ "object_id": 116,
"regions": [
{
"table_name": "HTTP_URL",
@@ -624,11 +624,11 @@
"tags": "{\"tag_sets\":[[{\"tag\":\"location\",\"value\":[\"北京/朝阳/华严北里\"]},{\"tag\":\"isp\",\"value\":[\"电信\",\"移动\"]}]]}",
"user_region": "Accepted\\btags",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "139_url_group",
- "group_id": 117,
+ "object_name": "139_url_object",
+ "object_id": 117,
"regions": [
{
"table_name": "HTTP_URL",
@@ -650,11 +650,11 @@
"do_log": 1,
"user_region": "file_streams",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "140_keywords_group",
- "group_id": 118,
+ "object_name": "140_keywords_object",
+ "object_id": 118,
"regions": [
{
"table_name": "KEYWORDS_TABLE",
@@ -677,12 +677,12 @@
"user_region": "Something:I\\bhave\\ba\\bname,7799",
"rule_table_name": "RULE_ALIAS",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
- "g2c_table_name": "GROUP2RULE_ALIAS",
+ "g2c_table_name": "OBJECT2RULE_ALIAS",
"attribute": "HTTP_URL",
- "group_name": "141_url_group",
- "group_id": 119,
+ "object_name": "141_url_object",
+ "object_id": 119,
"regions": [
{
"table_name": "HTTP_URL",
@@ -704,11 +704,11 @@
"do_log": 1,
"user_region": "StringScan.UTF8EncodedURL",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "142_url_group",
- "group_id": 120,
+ "object_name": "142_url_object",
+ "object_id": 120,
"regions": [
{
"table_name": "HTTP_URL",
@@ -730,11 +730,11 @@
"do_log": 1,
"user_region": "NOTLogic.OneRegion",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL_FILTER",
- "group_name": "143_url_group1",
- "group_id": 121,
+ "object_name": "143_url_object1",
+ "object_id": 121,
"negate_option": 0,
"regions": [
{
@@ -749,8 +749,8 @@
},
{
"attribute": "HTTP_URL_FILTER",
- "group_name": "143_url_group2",
- "group_id": 122,
+ "object_name": "143_url_object2",
+ "object_id": 122,
"negate_option": 1,
"regions": [
{
@@ -773,11 +773,11 @@
"do_log": 1,
"user_region": "NOTLogic.ScanNotAtLast",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL_FILTER",
- "group_name": "144_url_group",
- "group_id": 123,
+ "object_name": "144_url_object",
+ "object_id": 123,
"negate_option": 0,
"regions": [
{
@@ -792,8 +792,8 @@
},
{
"attribute": "HTTP_RESPONSE_KEYWORDS",
- "group_name": "144_keywords_group",
- "group_id": 124,
+ "object_name": "144_keywords_object",
+ "object_id": 124,
"negate_option": 1,
"regions": [
{
@@ -816,11 +816,11 @@
"do_log": 1,
"user_region": "NOTLogic.ScanNotIP",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "145_url_group",
- "group_id": 125,
+ "object_name": "145_url_object",
+ "object_id": 125,
"negate_option": 0,
"regions": [
{
@@ -835,7 +835,7 @@
},
{
"attribute": "ATTRIBUTE_IP_CONFIG",
- "group_name": "123_IP_group",
+ "object_name": "123_IP_object",
"negate_option": 1
}
]
@@ -848,11 +848,11 @@
"do_log": 1,
"user_region": "NOTLogic.NotExprConditionAndNotIPCondition",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL_FILTER",
- "group_name": "146_url_group",
- "group_id": 126,
+ "object_name": "146_url_object",
+ "object_id": 126,
"negate_option": 0,
"condition_index": 0,
"regions": [
@@ -868,8 +868,8 @@
},
{
"attribute": "HTTP_RESPONSE_KEYWORDS",
- "group_name": "146_keywords_group",
- "group_id": 127,
+ "object_name": "146_keywords_object",
+ "object_id": 127,
"negate_option": 1,
"condition_index": 1,
"regions": [
@@ -885,7 +885,7 @@
},
{
"attribute": "ATTRIBUTE_IP_CONFIG",
- "group_name": "123_IP_group",
+ "object_name": "123_IP_object",
"negate_option": 1,
"condition_index": 2
}
@@ -899,11 +899,11 @@
"do_log": 1,
"user_region": "NOTLogic.8NotCondition",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_RESPONSE_KEYWORDS_1",
- "group_name": "147_keywords_group1",
- "group_id": 128,
+ "object_name": "147_keywords_object1",
+ "object_id": 128,
"negate_option": 1,
"condition_index": 0,
"regions": [
@@ -919,8 +919,8 @@
},
{
"attribute": "HTTP_RESPONSE_KEYWORDS_2",
- "group_name": "147_keywords_group2",
- "group_id": 129,
+ "object_name": "147_keywords_object2",
+ "object_id": 129,
"negate_option": 1,
"condition_index": 1,
"regions": [
@@ -936,8 +936,8 @@
},
{
"attribute": "HTTP_RESPONSE_KEYWORDS_3",
- "group_name": "147_keywords_group3",
- "group_id": 130,
+ "object_name": "147_keywords_object3",
+ "object_id": 130,
"negate_option": 1,
"condition_index": 2,
"regions": [
@@ -953,8 +953,8 @@
},
{
"attribute": "HTTP_RESPONSE_KEYWORDS_4",
- "group_name": "147_keywords_group4",
- "group_id": 131,
+ "object_name": "147_keywords_object4",
+ "object_id": 131,
"negate_option": 1,
"condition_index": 3,
"regions": [
@@ -970,8 +970,8 @@
},
{
"attribute": "HTTP_RESPONSE_KEYWORDS_5",
- "group_name": "147_keywords_group5",
- "group_id": 132,
+ "object_name": "147_keywords_object5",
+ "object_id": 132,
"negate_option": 1,
"condition_index": 4,
"regions": [
@@ -987,8 +987,8 @@
},
{
"attribute": "HTTP_RESPONSE_KEYWORDS_6",
- "group_name": "147_keywords_group6",
- "group_id": 133,
+ "object_name": "147_keywords_object6",
+ "object_id": 133,
"negate_option": 1,
"condition_index": 5,
"regions": [
@@ -1004,8 +1004,8 @@
},
{
"attribute": "HTTP_RESPONSE_KEYWORDS_7",
- "group_name": "147_keywords_group7",
- "group_id": 134,
+ "object_name": "147_keywords_object7",
+ "object_id": 134,
"negate_option": 1,
"condition_index": 6,
"regions": [
@@ -1021,8 +1021,8 @@
},
{
"attribute": "HTTP_RESPONSE_KEYWORDS_8",
- "group_name": "147_keywords_group8",
- "group_id": 135,
+ "object_name": "147_keywords_object8",
+ "object_id": 135,
"negate_option": 1,
"condition_index": 7,
"regions": [
@@ -1046,11 +1046,11 @@
"do_log": 1,
"user_region": "StringScan.Regex",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "148_url_group",
- "group_id": 136,
+ "object_name": "148_url_object",
+ "object_id": 136,
"regions": [
{
"table_name": "HTTP_URL",
@@ -1072,11 +1072,11 @@
"do_log": 0,
"user_region": "StringScan.ExprPlusWithOffset",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "APP_PAYLOAD",
- "group_name": "149_app_group",
- "group_id": 137,
+ "object_name": "149_app_object",
+ "object_id": 137,
"regions": [
{
"table_name": "APP_PAYLOAD",
@@ -1099,11 +1099,11 @@
"do_log": 0,
"user_region": "StringScan.BugReport20190325",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "TROJAN_PAYLOAD",
- "group_name": "billgates_regist1",
- "group_id": 138,
+ "object_name": "billgates_regist1",
+ "object_id": 138,
"regions": [
{
"table_type": "expr",
@@ -1117,8 +1117,8 @@
},
{
"attribute": "TROJAN_PAYLOAD",
- "group_name": "billgates_regist2",
- "group_id": 139,
+ "object_name": "billgates_regist2",
+ "object_id": 139,
"regions": [
{
"table_type": "expr",
@@ -1140,11 +1140,11 @@
"do_log": 0,
"user_region": "StringScan.PrefixAndSuffix",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "MAIL_ADDR",
- "group_name": "151_expr_group",
- "group_id": 140,
+ "object_name": "151_expr_object",
+ "object_id": 140,
"regions": [
{
"table_type": "expr",
@@ -1166,11 +1166,11 @@
"do_log": 0,
"user_region": "StringScan.PrefixAndSuffix",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "MAIL_ADDR",
- "group_name": "152_mail_addr",
- "group_id": 141,
+ "object_name": "152_mail_addr",
+ "object_id": 141,
"regions": [
{
"table_type": "expr",
@@ -1192,11 +1192,11 @@
},
{
"attribute": "CONTENT_SIZE",
- "group_name": "interval_group_refered",
- "group_id": 142,
- "sub_groups": [
+ "object_name": "interval_object_refered",
+ "object_id": 142,
+ "sub_objects": [
{
- "group_name": "126_interval_group"
+ "object_name": "126_interval_object"
}
]
}
@@ -1208,13 +1208,13 @@
"action": 0,
"do_blacklist": 0,
"do_log": 0,
- "user_region": "Policy.SubGroup",
+ "user_region": "Policy.SubObject",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "MAIL_ADDR",
- "group_name": "153_expr_group",
- "group_id": 143,
+ "object_name": "153_expr_object",
+ "object_id": 143,
"negate_option": 0,
"regions": [
{
@@ -1226,20 +1226,20 @@
}
}
],
- "sub_groups": [
+ "sub_objects": [
{
"attribute": "MAIL_ADDR",
- "group_name": "152_mail_addr"
+ "object_name": "152_mail_addr"
}
]
},
{
"attribute": "IP_CONFIG",
- "group_name": "IP_group_refered",
- "group_id": 144,
- "sub_groups": [
+ "object_name": "IP_object_refered",
+ "object_id": 144,
+ "sub_objects": [
{
- "group_name": "123_IP_group"
+ "object_name": "123_IP_object"
}
]
}
@@ -1253,11 +1253,11 @@
"do_log": 0,
"user_region": "ipv4_plus",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "154_IP_group",
- "group_id": 145,
+ "object_name": "154_IP_object",
+ "object_id": 145,
"negate_option": 0,
"regions": [
{
@@ -1279,11 +1279,11 @@
"do_log": 0,
"user_region": "ipv6_plus",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "155_IP_group",
- "group_id": 146,
+ "object_name": "155_IP_object",
+ "object_id": 146,
"negate_option": 0,
"regions": [
{
@@ -1305,11 +1305,11 @@
"do_log": 1,
"user_region": "ExprPlusWithHex",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_SIGNATURE",
- "group_name": "156_expr_group",
- "group_id": 147,
+ "object_name": "156_expr_object",
+ "object_id": 147,
"regions": [
{
"table_name": "HTTP_SIGNATURE",
@@ -1332,11 +1332,11 @@
"do_log": 0,
"user_region": "StringScan.StreamScanUTF8",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "TROJAN_PAYLOAD",
- "group_name": "157_expr_group",
- "group_id": 148,
+ "object_name": "157_expr_object",
+ "object_id": 148,
"regions": [
{
"table_type": "expr",
@@ -1358,11 +1358,11 @@
"do_log": 0,
"user_region": "IPScan.IPv4_CIDR",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "158_IP_group",
- "group_id": 149,
+ "object_name": "158_IP_object",
+ "object_id": 149,
"regions": [
{
"table_type":"ip",
@@ -1383,11 +1383,11 @@
"do_log": 0,
"user_region": "IPScan.IPv6_CIDR",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "159_IP_group",
- "group_id": 150,
+ "object_name": "159_IP_object",
+ "object_id": 150,
"regions": [
{
"table_type":"ip",
@@ -1408,16 +1408,16 @@
"do_log": 0,
"user_region": "AttributeWithOnePhysical",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_RESPONSE_KEYWORDS",
- "group_name": "TakeMeHome",
+ "object_name": "TakeMeHome",
"negate_option": 0
},
{
"attribute": "HTTP_URL",
- "group_name": "160_url_group",
- "group_id": 151,
+ "object_name": "160_url_object",
+ "object_id": 151,
"negate_option": 0,
"regions": [
{
@@ -1440,11 +1440,11 @@
"do_log": 0,
"user_region": "attribute_test_temp",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_SIGNATURE",
- "group_name": "vt_grp_http_sig1",
- "group_id": 152,
+ "object_name": "vt_grp_http_sig1",
+ "object_id": 152,
"negate_option": 0,
"regions": [
{
@@ -1460,8 +1460,8 @@
},
{
"attribute": "HTTP_SIGNATURE",
- "group_name": "vt_grp_http_sig2",
- "group_id": 153,
+ "object_name": "vt_grp_http_sig2",
+ "object_id": 153,
"negate_option": 0,
"regions": [
{
@@ -1494,15 +1494,15 @@
"do_log": 0,
"user_region": "AttributeWithAttribute",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_REQUEST_HEADER",
- "group_name": "vt_grp_http_sig1",
+ "object_name": "vt_grp_http_sig1",
"negate_option": 0
},
{
"attribute": "HTTP_RESPONSE_HEADER",
- "group_name": "vt_grp_http_sig2",
+ "object_name": "vt_grp_http_sig2",
"negate_option": 0
}
]
@@ -1513,17 +1513,17 @@
"action": 0,
"do_blacklist": 0,
"do_log": 0,
- "user_region": "OneGroupInTwoAttribute",
+ "user_region": "OneObjectInTwoAttribute",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_REQUEST_HEADER",
- "group_name": "vt_grp_http_sig2",
+ "object_name": "vt_grp_http_sig2",
"negate_option": 0
},
{
"attribute": "HTTP_RESPONSE_HEADER",
- "group_name": "vt_grp_http_sig2",
+ "object_name": "vt_grp_http_sig2",
"negate_option": 0
}
]
@@ -1536,11 +1536,11 @@
"do_log": 1,
"user_region": "CharsetWindows1251",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "164_keywords_group",
- "group_id": 154,
+ "object_name": "164_keywords_object",
+ "object_id": 154,
"regions": [
{
"table_name": "KEYWORDS_TABLE",
@@ -1563,11 +1563,11 @@
"user_region": "EvaluationOrder",
"is_valid": "yes",
"evaluation_order": "2.111",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "165_url_group",
- "group_id": 155,
+ "object_name": "165_url_object",
+ "object_id": 155,
"regions": [
{
"table_name": "HTTP_URL",
@@ -1581,8 +1581,8 @@
},
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "165_IP_group",
- "group_id": 156,
+ "object_name": "165_IP_object",
+ "object_id": 156,
"negate_option": 0,
"regions": [
{
@@ -1605,11 +1605,11 @@
"user_region": "EvaluationOrder",
"is_valid": "yes",
"evaluation_order": "100.233",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "166_url_group",
- "group_id": 157,
+ "object_name": "166_url_object",
+ "object_id": 157,
"regions": [
{
"table_name": "HTTP_URL",
@@ -1632,11 +1632,11 @@
"user_region": "EvaluationOrder",
"is_valid": "yes",
"evaluation_order": "300.999",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "167_url_group",
- "group_id": 158,
+ "object_name": "167_url_object",
+ "object_id": 158,
"condition_index": 1,
"regions": [
{
@@ -1651,8 +1651,8 @@
},
{
"attribute": "HTTP_URL",
- "group_name": "167_url_group",
- "group_id": 158,
+ "object_name": "167_url_object",
+ "object_id": 158,
"condition_index": 3
}
]
@@ -1666,17 +1666,17 @@
"user_region": "EvaluationOrder",
"is_valid": "yes",
"evaluation_order": "0",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "167_url_group",
- "group_id": 158,
+ "object_name": "167_url_object",
+ "object_id": 158,
"condition_index": 2
},
{
"attribute": "HTTP_URL",
- "group_name": "167_url_group",
- "group_id": 158,
+ "object_name": "167_url_object",
+ "object_id": 158,
"condition_index": 6
}
]
@@ -1689,11 +1689,11 @@
"do_log": 0,
"user_region": "IPScan.IPv4_Any",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "169_IP_group",
- "group_id": 160,
+ "object_name": "169_IP_object",
+ "object_id": 160,
"condition_index": 0,
"negate_option" : 0,
"regions": [
@@ -1716,11 +1716,11 @@
"do_log": 0,
"user_region": "IPScan.IPv4_attribute.source",
"is_valid": "no",
- "groups": [
+ "objects": [
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "ipv4_attribute.source",
- "group_id": 161,
+ "object_name": "ipv4_attribute.source",
+ "object_id": 161,
"negate_option": 0,
"regions": [
{
@@ -1742,11 +1742,11 @@
"do_log": 0,
"user_region": "IPScan.IPv4_attribute.destination",
"is_valid": "no",
- "groups": [
+ "objects": [
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "ipv4_attribute.destination",
- "group_id": 162,
+ "object_name": "ipv4_attribute.destination",
+ "object_id": 162,
"negate_option": 0,
"regions": [
{
@@ -1766,18 +1766,18 @@
"action": 1,
"do_blacklist": 1,
"do_log": 1,
- "user_region": "NOTLogic.MultiGroupsInOneNotCondition",
+ "user_region": "NOTLogic.MultiObjectsInOneNotCondition",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "ASN_NOT_LOGIC",
- "group_name": ["ASN1234", "ASN6789", "ASN9001"],
+ "object_name": ["ASN1234", "ASN6789", "ASN9001"],
"negate_option": 1,
"condition_index": 0
},
{
"attribute": "DESTINATION_IP_ASN",
- "group_name": "ASN2345",
+ "object_name": "ASN2345",
"negate_option": 0,
"condition_index": 1
}
@@ -1789,18 +1789,18 @@
"action": 1,
"do_blacklist": 1,
"do_log": 1,
- "user_region": "Hierarchy.MultiGroupInOneCondition",
+ "user_region": "Hierarchy.MultiObjectInOneCondition",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "SOURCE_IP_ASN",
- "group_name": ["ASN1234", "ASN6789", "ASN9001"],
+ "object_name": ["ASN1234", "ASN6789", "ASN9001"],
"negate_option": 0,
"condition_index": 0
},
{
"attribute": "DESTINATION_IP_ASN",
- "group_name": "ASN2345",
+ "object_name": "ASN2345",
"negate_option": 0,
"condition_index": 1
}
@@ -1814,11 +1814,11 @@
"do_log": 1,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "INTERGER_PLUS",
- "group_name": "179_interval_group",
- "group_id": 166,
+ "object_name": "179_interval_object",
+ "object_id": 166,
"regions": [
{
"table_name": "INTERGER_PLUS",
@@ -1838,24 +1838,24 @@
"action": 1,
"do_blacklist": 1,
"do_log": 1,
- "user_region": "Hierarchy.MultiGroupInOneCondition",
+ "user_region": "Hierarchy.MultiObjectInOneCondition",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "SOURCE_IP_ASN",
- "group_name": ["ASN1234", "ASN6789", "ASN9001"],
+ "object_name": ["ASN1234", "ASN6789", "ASN9001"],
"negate_option": 0,
"condition_index": 0
},
{
"attribute": "SOURCE_IP_GEO",
- "group_name": "Country-Sparta-IP",
+ "object_name": "Country-Sparta-IP",
"negate_option": 0,
"condition_index": 0
},
{
"attribute": "IP_CONFIG",
- "group_name": "financial-department-ip",
+ "object_name": "financial-department-ip",
"negate_option": 0,
"condition_index": 1
}
@@ -1869,22 +1869,22 @@
"do_log": 1,
"user_region": "NOTLogic.MultiLiteralsInOneNotCondition",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "SOURCE_IP_ASN",
- "group_name": ["ASN1234", "ASN6789", "ASN9001"],
+ "object_name": ["ASN1234", "ASN6789", "ASN9001"],
"negate_option": 1,
"condition_index": 0
},
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "develop-department-ip",
+ "object_name": "develop-department-ip",
"negate_option": 1,
"condition_index": 0
},
{
"attribute": "SOURCE_IP_GEO",
- "group_name": "Country-Sparta-IP",
+ "object_name": "Country-Sparta-IP",
"negate_option": 0,
"condition_index": 1
}
@@ -1898,11 +1898,11 @@
"do_log": 1,
"user_region": "8-expr",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "182_keywords_group",
- "group_id": 167,
+ "object_name": "182_keywords_object",
+ "object_id": 167,
"regions": [
{
"table_name": "KEYWORDS_TABLE",
@@ -1925,11 +1925,11 @@
"do_log": 0,
"action": 0,
"service": 0,
- "groups": [
+ "objects": [
{
"attribute": "IP_CONFIG",
- "group_name": "184_IP_group",
- "group_id": 169,
+ "object_name": "184_IP_object",
+ "object_id": 169,
"regions": [
{
"table_name": "IP_CONFIG",
@@ -1950,34 +1950,34 @@
"do_log": 1,
"user_region": "NOTLogic.SameAttributeInMultiCondition",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "DESTINATION_IP_ASN",
- "group_name": ["ASN1234", "ASN6789", "ASN9001"],
+ "object_name": ["ASN1234", "ASN6789", "ASN9001"],
"negate_option": 1,
"condition_index": 0
},
{
"attribute": "SOURCE_IP_GEO",
- "group_name": "Country-Sparta-IP",
+ "object_name": "Country-Sparta-IP",
"negate_option": 1,
"condition_index": 0
},
{
"attribute": "DESTINATION_IP_ASN",
- "group_name": "ASN9002",
+ "object_name": "ASN9002",
"negate_option": 1,
"condition_index": 1
},
{
"attribute": "DESTINATION_IP_ASN",
- "group_name": "ASN9003",
+ "object_name": "ASN9003",
"negate_option": 0,
"condition_index": 2
},
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "security-department-ip",
+ "object_name": "security-department-ip",
"negate_option": 0,
"condition_index": 3
}
@@ -1991,11 +1991,11 @@
"do_log": 1,
"user_region": "NOTLogic.ScanHitAtLast",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL_FILTER",
- "group_name": "186_expr_group",
- "group_id": 170,
+ "object_name": "186_expr_object",
+ "object_id": 170,
"negate_option": 1,
"regions": [
{
@@ -2010,8 +2010,8 @@
},
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "186_IP_group",
- "group_id": 171,
+ "object_name": "186_IP_object",
+ "object_id": 171,
"negate_option": 0,
"regions": [
{
@@ -2033,11 +2033,11 @@
"do_log": 1,
"user_region": "NOTLogic.ScanHitAtLast",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL_FILTER",
- "group_name": "187_url_group",
- "group_id": 172,
+ "object_name": "187_url_object",
+ "object_id": 172,
"negate_option": 1,
"regions": [
{
@@ -2052,8 +2052,8 @@
},
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "187_IP_group",
- "group_id": 173,
+ "object_name": "187_IP_object",
+ "object_id": 173,
"negate_option": 0,
"regions": [
{
@@ -2075,11 +2075,11 @@
"do_log": 1,
"user_region": "NOTLogic.ScanHitAtLast",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL_FILTER",
- "group_name": "188_url_group",
- "group_id": 174,
+ "object_name": "188_url_object",
+ "object_id": 174,
"negate_option": 1,
"regions": [
{
@@ -2094,8 +2094,8 @@
},
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "188_IP_group",
- "group_id": 175,
+ "object_name": "188_IP_object",
+ "object_id": 175,
"negate_option": 0,
"regions": [
{
@@ -2117,11 +2117,11 @@
"service": 0,
"do_blacklist": 0,
"user_region": "StringScan.ShouldNotHitExprPlus",
- "groups": [
+ "objects": [
{
"attribute": "APP_PAYLOAD",
- "group_name": "189_app_group",
- "group_id": 176,
+ "object_name": "189_app_object",
+ "object_id": 176,
"regions": [
{
"table_name": "APP_PAYLOAD",
@@ -2144,11 +2144,11 @@
"do_log": 1,
"user_region": "StringScan.ExprPlus",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_SIGNATURE",
- "group_name": "190_expr_group",
- "group_id": 177,
+ "object_name": "190_expr_object",
+ "object_id": 177,
"regions": [
{
"table_name": "HTTP_SIGNATURE",
@@ -2171,11 +2171,11 @@
"do_log": 0,
"user_region": "StringScan.HexBinCaseSensitive",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "191_keywords_group",
- "group_id": 178,
+ "object_name": "191_keywords_object",
+ "object_id": 178,
"regions": [
{
"table_type": "expr",
@@ -2197,11 +2197,11 @@
"do_log": 0,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "FLAG_CONFIG",
- "group_name": "192_flag_group",
- "group_id": 179,
+ "object_name": "192_flag_object",
+ "object_id": 179,
"regions": [
{
"table_type": "flag",
@@ -2223,11 +2223,11 @@
"do_log": 0,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "FLAG_CONFIG",
- "group_name": "193_flag_group",
- "group_id": 180,
+ "object_name": "193_flag_object",
+ "object_id": 180,
"regions": [
{
"table_type": "flag",
@@ -2241,8 +2241,8 @@
},
{
"attribute": "HTTP_URL",
- "group_name": "193_url_group",
- "group_id": 181,
+ "object_name": "193_url_object",
+ "object_id": 181,
"regions": [
{
"table_name": "HTTP_URL",
@@ -2264,11 +2264,11 @@
"do_log": 0,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "FLAG_CONFIG",
- "group_name": "194_flag_group",
- "group_id": 182,
+ "object_name": "194_flag_object",
+ "object_id": 182,
"regions": [
{
"table_type": "flag",
@@ -2290,11 +2290,11 @@
"do_log": 0,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_SIGNATURE",
- "group_name": "195_signature_group",
- "group_id": 183,
+ "object_name": "195_signature_object",
+ "object_id": 183,
"regions": [
{
"table_name": "HTTP_SIGNATURE",
@@ -2309,8 +2309,8 @@
},
{
"attribute": "HTTP_URL",
- "group_name": "195_url_group",
- "group_id": 184,
+ "object_name": "195_url_object",
+ "object_id": 184,
"regions": [
{
"table_name": "HTTP_URL",
@@ -2332,11 +2332,11 @@
"do_log": 0,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "FLAG_PLUS_CONFIG",
- "group_name": "196_flag_group",
- "group_id": 185,
+ "object_name": "196_flag_object",
+ "object_id": 185,
"regions": [
{
"table_type": "flag_plus",
@@ -2359,11 +2359,11 @@
"do_log": 1,
"user_region": "Something:I\\bhave\\ba\\bname,8866",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "197_url_group",
- "group_id": 186,
+ "object_name": "197_url_object",
+ "object_id": 186,
"regions": [
{
"table_name": "HTTP_URL",
@@ -2386,12 +2386,12 @@
"user_region": "Something:I have a name,7799",
"rule_table_name": "RULE_FIREWALL_DEFAULT",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
- "g2c_table_name": "GROUP2RULE_FIREWALL",
+ "g2c_table_name": "OBJECT2RULE_FIREWALL",
"attribute": "HTTP_URL",
- "group_name": "198_url_group",
- "group_id": 187,
+ "object_name": "198_url_object",
+ "object_id": 187,
"regions": [
{
"table_name": "HTTP_URL",
@@ -2413,15 +2413,15 @@
"do_log": 1,
"user_region": "ExcludeLogic.ScanNotAtLast",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "ExcludeLogicGroup199",
- "group_id": 188,
- "sub_groups":[
+ "object_name": "ExcludeLogicObject199",
+ "object_id": 188,
+ "sub_objects":[
{
- "group_name": "ExcludeLogicGroup199_1",
- "group_id": 189,
+ "object_name": "ExcludeLogicObject199_1",
+ "object_id": 189,
"is_exclude": 0,
"condition_index": 0,
"regions": [
@@ -2436,8 +2436,8 @@
]
},
{
- "group_name": "ExcludeLogicGroup199_2",
- "group_id": 190,
+ "object_name": "ExcludeLogicObject199_2",
+ "object_id": 190,
"is_exclude": 1,
"condition_index": 0,
"regions": [
@@ -2463,16 +2463,16 @@
"do_log": 1,
"user_region": "ExcludeLogic.OneRegion",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "ExcludeLogicGroup200",
- "group_id": 191,
- "sub_groups":[
+ "object_name": "ExcludeLogicObject200",
+ "object_id": 191,
+ "sub_objects":[
{
"attribute": "HTTP_URL",
- "group_name": "ExcludeLogicGroup200_1",
- "group_id": 192,
+ "object_name": "ExcludeLogicObject200_1",
+ "object_id": 192,
"is_exclude": 0,
"condition_index": 0,
"regions": [
@@ -2488,8 +2488,8 @@
},
{
"attribute": "HTTP_URL",
- "group_name": "ExcludeLogicGroup200_2",
- "group_id": 193,
+ "object_name": "ExcludeLogicObject200_2",
+ "object_id": 193,
"is_exclude": 1,
"condition_index": 0,
"regions": [
@@ -2515,16 +2515,16 @@
"do_log": 1,
"user_region": "null",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "ATTRIBUTE_IP_PLUS_TABLE",
- "group_name": "ExcludeLogicGroup202",
- "group_id": 194,
+ "object_name": "ExcludeLogicObject202",
+ "object_id": 194,
"condition_index": 0,
- "sub_groups":[
+ "sub_objects":[
{
- "group_name": "ExcludeLogicGroup202_1",
- "group_id": 195,
+ "object_name": "ExcludeLogicObject202_1",
+ "object_id": 195,
"is_exclude": 0,
"regions": [
{
@@ -2537,8 +2537,8 @@
]
},
{
- "group_name": "ExcludeLogicGroup202_2",
- "group_id": 196,
+ "object_name": "ExcludeLogicObject202_2",
+ "object_id": 196,
"is_exclude": 1,
"regions": [
{
@@ -2551,8 +2551,8 @@
]
},
{
- "group_name": "ExcludeLogicGroup202_3",
- "group_id": 197,
+ "object_name": "ExcludeLogicObject202_3",
+ "object_id": 197,
"is_exclude": 1,
"regions": [
{
@@ -2576,11 +2576,11 @@
"do_log": 1,
"user_region": "null",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "ATTRIBUTE_IP_PLUS_SOURCE",
- "group_name": "ExcludeLogicGroup203_1",
- "group_id": 198,
+ "object_name": "ExcludeLogicObject203_1",
+ "object_id": 198,
"condition_index": 0,
"regions": [
{
@@ -2595,8 +2595,8 @@
},
{
"attribute": "ATTRIBUTE_IP_PLUS_DESTINATION",
- "group_name": "ExcludeLogicGroup203_2",
- "group_id": 199,
+ "object_name": "ExcludeLogicObject203_2",
+ "object_id": 199,
"condition_index": 1,
"regions": [
{
@@ -2610,13 +2610,13 @@
},
{
"attribute": "HTTP_RESPONSE_KEYWORDS",
- "group_name": "ExcludeLogicGroup203_3",
- "group_id": 200,
+ "object_name": "ExcludeLogicObject203_3",
+ "object_id": 200,
"condition_index": 2,
- "sub_groups": [
+ "sub_objects": [
{
- "group_name": "ExcludeLogicGroup203_3_1",
- "group_id": 201,
+ "object_name": "ExcludeLogicObject203_3_1",
+ "object_id": 201,
"is_exclude": 0,
"regions": [
{
@@ -2630,8 +2630,8 @@
]
},
{
- "group_name": "ExcludeLogicGroup203_3_2",
- "group_id": 202,
+ "object_name": "ExcludeLogicObject203_3_2",
+ "object_id": 202,
"is_exclude": 1,
"regions": [
{
@@ -2656,11 +2656,11 @@
"do_log": 1,
"user_region": "null",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "ATTRIBUTE_IP_PLUS_SOURCE",
- "group_name": "ExcludeLogicGroup204_1",
- "group_id": 203,
+ "object_name": "ExcludeLogicObject204_1",
+ "object_id": 203,
"condition_index": 0,
"regions": [
{
@@ -2675,8 +2675,8 @@
},
{
"attribute": "ATTRIBUTE_IP_PLUS_DESTINATION",
- "group_name": "ExcludeLogicGroup204_2",
- "group_id":204,
+ "object_name": "ExcludeLogicObject204_2",
+ "object_id":204,
"condition_index": 1,
"regions": [
{
@@ -2690,18 +2690,18 @@
},
{
"attribute": "HTTP_RESPONSE_KEYWORDS",
- "group_name": "ExcludeLogicGroup204_3",
- "group_id": 205,
+ "object_name": "ExcludeLogicObject204_3",
+ "object_id": 205,
"condition_index": 2,
- "sub_groups": [
+ "sub_objects": [
{
- "group_name": "ExcludeLogicGroup204_3_1",
- "group_id": 206,
+ "object_name": "ExcludeLogicObject204_3_1",
+ "object_id": 206,
"is_exclude": 0,
- "sub_groups" : [
+ "sub_objects" : [
{
- "group_name": "ExcludeLogicGroup204_3_1_1",
- "group_id": 207,
+ "object_name": "ExcludeLogicObject204_3_1_1",
+ "object_id": 207,
"is_exclude": 0,
"regions": [
{
@@ -2715,8 +2715,8 @@
]
},
{
- "group_name": "ExcludeLogicGroup204_3_1_2",
- "group_id": 208,
+ "object_name": "ExcludeLogicObject204_3_1_2",
+ "object_id": 208,
"is_exclude": 1,
"regions": [
{
@@ -2732,8 +2732,8 @@
]
},
{
- "group_name": "ExcludeLogicGroup204_3_2",
- "group_id": 209,
+ "object_name": "ExcludeLogicObject204_3_2",
+ "object_id": 209,
"is_exclude": 1,
"regions": [
{
@@ -2758,11 +2758,11 @@
"do_log": 0,
"user_region": "StringScan.RegexExpressionIllegal",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "205_keywords_group",
- "group_id": 210,
+ "object_name": "205_keywords_object",
+ "object_id": 210,
"regions": [
{
"table_type": "expr",
@@ -2784,11 +2784,11 @@
"do_log": 0,
"user_region": "duplicateRuleFor191",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "206_keywords_group",
- "group_id": 211,
+ "object_name": "206_keywords_object",
+ "object_id": 211,
"regions": [
{
"table_type": "expr",
@@ -2810,11 +2810,11 @@
"do_log": 0,
"user_region": "duplicateRuleFor192",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "FLAG_CONFIG",
- "group_name": "207_flag_group",
- "group_id": 212,
+ "object_name": "207_flag_object",
+ "object_id": 212,
"regions": [
{
"table_type": "flag",
@@ -2836,11 +2836,11 @@
"do_log": 0,
"user_region": "duplicateRuleFor154",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "208_IP_group",
- "group_id": 213,
+ "object_name": "208_IP_object",
+ "object_id": 213,
"negate_option": 0,
"regions": [
{
@@ -2862,11 +2862,11 @@
"do_log": 1,
"user_region": "duplicateRuleFor179",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "INTERGER_PLUS",
- "group_name": "209_interval_group",
- "group_id": 214,
+ "object_name": "209_interval_object",
+ "object_id": 214,
"regions": [
{
"table_name": "INTERGER_PLUS",
@@ -2888,11 +2888,11 @@
"do_log": 0,
"user_region": "ipv6_::",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "210_IP_group",
- "group_id": 215,
+ "object_name": "210_IP_object",
+ "object_id": 215,
"regions": [
{
"table_type":"ip",
@@ -2913,11 +2913,11 @@
"do_log": 0,
"user_region": "ip_perf_test",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "IP_PERF_CONFIG",
- "group_name": "211_IP_group",
- "group_id": 216,
+ "object_name": "211_IP_object",
+ "object_id": 216,
"negate_option": 0,
"regions": [
{
@@ -2939,11 +2939,11 @@
"do_log": 1,
"user_region": "integer_perf_test",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "INTEGER_PERF_CONFIG",
- "group_name": "212_interval_group",
- "group_id": 217,
+ "object_name": "212_interval_object",
+ "object_id": 217,
"regions": [
{
"table_name": "INTEGER_PERF_CONFIG",
@@ -2964,11 +2964,11 @@
"do_log": 1,
"user_region": "expr_perf_test",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "EXPR_LITERAL_PERF_CONFIG",
- "group_name": "213_expr_group",
- "group_id": 218,
+ "object_name": "213_expr_object",
+ "object_id": 218,
"regions": [
{
"table_name": "EXPR_LITERAL_PERF_CONFIG",
@@ -2990,11 +2990,11 @@
"do_log": 0,
"user_region": "flag_perf_test",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "FLAG_PERF_CONFIG",
- "group_name": "214_flag_group",
- "group_id": 219,
+ "object_name": "214_flag_object",
+ "object_id": 219,
"regions": [
{
"table_type": "flag",
@@ -3016,11 +3016,11 @@
"do_log": 1,
"user_region": "expr_perf_test",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "EXPR_REGEX_PERF_CONFIG",
- "group_name": "215_expr_group",
- "group_id": 220,
+ "object_name": "215_expr_object",
+ "object_id": 220,
"regions": [
{
"table_name": "EXPR_REGEX_PERF_CONFIG",
@@ -3040,19 +3040,19 @@
"action": 0,
"do_blacklist": 0,
"do_log": 0,
- "user_region": "NOTCondition&ExcludeGroup",
+ "user_region": "NOTCondition&ExcludeObject",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL_FILTER",
- "group_name": "ExcludeLogicGroup200",
+ "object_name": "ExcludeLogicObject200",
"negate_option": 0,
"condition_index": 0
},
{
"attribute": "HTTP_RESPONSE_KEYWORDS",
- "group_name": "NOTConditionAndExcludeGroup216",
- "group_id": 221,
+ "object_name": "NOTConditionAndExcludeObject216",
+ "object_id": 221,
"negate_option": 1,
"condition_index": 1,
"regions": [
@@ -3074,19 +3074,19 @@
"action": 0,
"do_blacklist": 0,
"do_log": 0,
- "user_region": "NOTCondition&ExcludeGroup",
+ "user_region": "NOTCondition&ExcludeObject",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL_FILTER",
- "group_name": "NOTConditionAndExcludeGroup217_1",
- "group_id": 222,
+ "object_name": "NOTConditionAndExcludeObject217_1",
+ "object_id": 222,
"negate_option": 1,
"condition_index": 0,
- "sub_groups": [
+ "sub_objects": [
{
- "group_name": "ExcludeLogicGroup217_1_1",
- "group_id": 223,
+ "object_name": "ExcludeLogicObject217_1_1",
+ "object_id": 223,
"is_exclude": 0,
"regions": [
{
@@ -3100,8 +3100,8 @@
]
},
{
- "group_name": "ExcludeLogicGroup217_1_2",
- "group_id": 224,
+ "object_name": "ExcludeLogicObject217_1_2",
+ "object_id": 224,
"is_exclude": 1,
"regions": [
{
@@ -3118,8 +3118,8 @@
},
{
"attribute": "HTTP_RESPONSE_KEYWORDS",
- "group_name": "NOTConditionAndExcludeGroup217_2",
- "group_id": 225,
+ "object_name": "NOTConditionAndExcludeObject217_2",
+ "object_id": 225,
"negate_option": 0,
"condition_index": 1,
"regions": [
@@ -3143,11 +3143,11 @@
"do_log": 1,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "CONTENT_SIZE",
- "group_name": "218_interval_group",
- "group_id": 226,
+ "object_name": "218_interval_object",
+ "object_id": 226,
"regions": [
{
"table_name": "CONTENT_SIZE",
@@ -3168,11 +3168,11 @@
"do_log": 1,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_DUMMY",
- "group_name": "NOTConditionAndExcludeGroup219_1",
- "group_id": 227,
+ "object_name": "NOTConditionAndExcludeObject219_1",
+ "object_id": 227,
"negate_option": 0,
"condition_index": 0,
"regions": [
@@ -3188,8 +3188,8 @@
},
{
"attribute": "HTTP_DUMMY",
- "group_name": "NOTConditionAndExcludeGroup219_2",
- "group_id": 228,
+ "object_name": "NOTConditionAndExcludeObject219_2",
+ "object_id": 228,
"negate_option": 1,
"condition_index": 1,
"regions": [
@@ -3205,8 +3205,8 @@
},
{
"attribute": "HTTP_DUMMY",
- "group_name": "NOTConditionAndExcludeGroup219_3",
- "group_id": 229,
+ "object_name": "NOTConditionAndExcludeObject219_3",
+ "object_id": 229,
"negate_option": 1,
"condition_index": 2,
"regions": [
@@ -3222,8 +3222,8 @@
},
{
"attribute": "HTTP_DUMMY",
- "group_name": "NOTConditionAndExcludeGroup219_4",
- "group_id": 230,
+ "object_name": "NOTConditionAndExcludeObject219_4",
+ "object_id": 230,
"negate_option": 1,
"condition_index": 3,
"regions": [
@@ -3239,8 +3239,8 @@
},
{
"attribute": "HTTP_DUMMY",
- "group_name": "NOTConditionAndExcludeGroup219_5",
- "group_id": 231,
+ "object_name": "NOTConditionAndExcludeObject219_5",
+ "object_id": 231,
"negate_option": 1,
"condition_index": 4,
"regions": [
@@ -3256,8 +3256,8 @@
},
{
"attribute": "HTTP_DUMMY",
- "group_name": "NOTConditionAndExcludeGroup219_6",
- "group_id": 232,
+ "object_name": "NOTConditionAndExcludeObject219_6",
+ "object_id": 232,
"negate_option": 1,
"condition_index": 5,
"regions": [
@@ -3273,8 +3273,8 @@
},
{
"attribute": "HTTP_DUMMY",
- "group_name": "NOTConditionAndExcludeGroup219_7",
- "group_id": 233,
+ "object_name": "NOTConditionAndExcludeObject219_7",
+ "object_id": 233,
"negate_option": 1,
"condition_index": 6,
"regions": [
@@ -3290,8 +3290,8 @@
},
{
"attribute": "HTTP_DUMMY",
- "group_name": "NOTConditionAndExcludeGroup219_8",
- "group_id": 234,
+ "object_name": "NOTConditionAndExcludeObject219_8",
+ "object_id": 234,
"negate_option": 1,
"condition_index": 7,
"regions": [
@@ -3315,11 +3315,11 @@
"do_log": 1,
"user_region": "anything",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_DUMMY",
- "group_name": "NOTConditionAndExcludeGroup220_1",
- "group_id": 235,
+ "object_name": "NOTConditionAndExcludeObject220_1",
+ "object_id": 235,
"negate_option": 0,
"condition_index": 0,
"regions": [
@@ -3335,8 +3335,8 @@
},
{
"attribute": "HTTP_DUMMY",
- "group_name": "NOTConditionAndExcludeGroup220_2",
- "group_id": 236,
+ "object_name": "NOTConditionAndExcludeObject220_2",
+ "object_id": 236,
"negate_option": 1,
"condition_index": 1,
"regions": [
@@ -3352,8 +3352,8 @@
},
{
"attribute": "HTTP_DUMMY",
- "group_name": "NOTConditionAndExcludeGroup220_3",
- "group_id": 237,
+ "object_name": "NOTConditionAndExcludeObject220_3",
+ "object_id": 237,
"negate_option": 1,
"condition_index": 2,
"regions": [
@@ -3377,11 +3377,11 @@
"do_log": 0,
"user_region": "NOTLogic.ScanWithDistrict",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_REQUEST_HEADER",
- "group_name": "NOTLogicGroup_221_1",
- "group_id": 238,
+ "object_name": "NOTLogicObject_221_1",
+ "object_id": 238,
"negate_option": 1,
"regions": [
{
@@ -3397,8 +3397,8 @@
},
{
"attribute": "HTTP_URL",
- "group_name": "NOTLogicGroup_221_2",
- "group_id": 239,
+ "object_name": "NOTLogicObject_221_2",
+ "object_id": 239,
"negate_option": 0,
"regions": [
{
@@ -3421,11 +3421,11 @@
"do_log": 0,
"user_region": "NOTLogic.SingleNotCondition",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_NOT_LOGIC_1",
- "group_name": "NOTLogicGroup_222",
- "group_id": 240,
+ "object_name": "NOTLogicObject_222",
+ "object_id": 240,
"negate_option": 1,
"condition_index": 0,
"regions": [
@@ -3449,11 +3449,11 @@
"do_log": 0,
"user_region": "NOTLogic.MultiNotCondition",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_NOT_LOGIC",
- "group_name": "NOTLogicGroup_223_1",
- "group_id": 241,
+ "object_name": "NOTLogicObject_223_1",
+ "object_id": 241,
"negate_option": 1,
"condition_index": 0,
"regions": [
@@ -3469,8 +3469,8 @@
},
{
"attribute": "HTTP_NOT_LOGIC",
- "group_name": "NOTLogicGroup_223_2",
- "group_id": 242,
+ "object_name": "NOTLogicObject_223_2",
+ "object_id": 242,
"negate_option": 1,
"condition_index": 1,
"regions": [
@@ -3486,8 +3486,8 @@
},
{
"attribute": "HTTP_NOT_LOGIC",
- "group_name": "NOTLogicGroup_223_1",
- "group_id": 243,
+ "object_name": "NOTLogicObject_223_1",
+ "object_id": 243,
"negate_option": 1,
"condition_index": 2,
"regions": [
@@ -3511,11 +3511,11 @@
"do_log": 0,
"user_region": "NOTLogic.NotPhysicalTable",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "NOTLogicGroup_224_1",
- "group_id": 244,
+ "object_name": "NOTLogicObject_224_1",
+ "object_id": 244,
"negate_option": 1,
"condition_index": 0,
"regions": [
@@ -3531,8 +3531,8 @@
},
{
"attribute": "HTTP_RESPONSE_KEYWORDS",
- "group_name": "NOTLogicGroup_224_2",
- "group_id": 245,
+ "object_name": "NOTLogicObject_224_2",
+ "object_id": 245,
"negate_option": 0,
"condition_index": 1,
"regions": [
@@ -3556,11 +3556,11 @@
"do_log": 0,
"user_region": "Payload escape",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "EscapeGroup_225_1",
- "group_id": 246,
+ "object_name": "EscapeObject_225_1",
+ "object_id": 246,
"negate_option": 0,
"condition_index": 0,
"regions": [
@@ -3582,13 +3582,13 @@
"action": 1,
"do_blacklist": 1,
"do_log": 1,
- "user_region": "maat_scan_group",
+ "user_region": "maat_scan_object",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "226_url_group",
- "group_id":247
+ "object_name": "226_url_object",
+ "object_id":247
}
]
},
@@ -3598,15 +3598,15 @@
"action": 1,
"do_blacklist": 1,
"do_log": 1,
- "user_region": "maat_scan_group",
+ "user_region": "maat_scan_object",
"rule_table_name": "RULE_FIREWALL_DEFAULT",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "227_url_group",
- "group_id": 248,
- "g2c_table_name": "GROUP2RULE_FIREWALL"
+ "object_name": "227_url_object",
+ "object_id": 248,
+ "g2c_table_name": "OBJECT2RULE_FIREWALL"
}
]
},
@@ -3618,11 +3618,11 @@
"do_log": 1,
"user_region": "NotConditionHitPath",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "228_url_group",
- "group_id": 249,
+ "object_name": "228_url_object",
+ "object_id": 249,
"negate_option": 0,
"condition_index": 1,
"regions": [
@@ -3638,8 +3638,8 @@
},
{
"attribute": "ATTRIBUTE_IP_CONFIG",
- "group_name": "228_IP_group",
- "group_id": 250,
+ "object_name": "228_IP_object",
+ "object_id": 250,
"negate_option": 1,
"condition_index": 2,
"regions": [
@@ -3662,11 +3662,11 @@
"do_log": 1,
"user_region": "StringScan.Regex",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_URL",
- "group_name": "229_url_group",
- "group_id": 251,
+ "object_name": "229_url_object",
+ "object_id": 251,
"regions": [
{
"table_name": "HTTP_URL",
@@ -3688,11 +3688,11 @@
"do_log": 0,
"user_region": "ipv6_::",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "230_IP_group",
- "group_id": 256,
+ "object_name": "230_IP_object",
+ "object_id": 256,
"regions": [
{
"table_type":"ip",
@@ -3714,11 +3714,11 @@
"do_log": 0,
"user_region": "should_not_hit",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "231_IP_group",
- "group_id": 257,
+ "object_name": "231_IP_object",
+ "object_id": 257,
"regions": [
{
"table_type":"ip",
@@ -3740,11 +3740,11 @@
"do_log": 0,
"user_region": "should_not_hit",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "IP_PLUS_CONFIG",
- "group_name": "232_IP_group",
- "group_id": 258,
+ "object_name": "232_IP_object",
+ "object_id": 258,
"regions": [
{
"table_type":"ip",
@@ -3764,13 +3764,13 @@
"action": 1,
"do_blacklist": 1,
"do_log": 1,
- "user_region": "maat_scan_group",
+ "user_region": "maat_scan_object",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "HTTP_RESPONSE_KEYWORDS",
- "group_name": "233_url_group",
- "group_id": 259
+ "object_name": "233_url_object",
+ "object_id": 259
}
]
},
@@ -3782,11 +3782,11 @@
"do_log": 0,
"user_region": "Payload escape",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "EscapeGroup_234_1",
- "group_id": 260,
+ "object_name": "EscapeObject_234_1",
+ "object_id": 260,
"negate_option": 0,
"condition_index": 0,
"regions": [
@@ -3810,11 +3810,11 @@
"do_log": 0,
"user_region": "Payload escape",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "EscapeGroup_235_1",
- "group_id": 261,
+ "object_name": "EscapeObject_235_1",
+ "object_id": 261,
"negate_option": 0,
"condition_index": 0,
"regions": [
@@ -3838,11 +3838,11 @@
"do_log": 0,
"user_region": "StringScan.HexBinCombineString",
"is_valid": "yes",
- "groups": [
+ "objects": [
{
"attribute": "KEYWORDS_TABLE",
- "group_name": "236_keywords_group",
- "group_id": 262,
+ "object_name": "236_keywords_object",
+ "object_id": 262,
"regions": [
{
"table_type": "expr",
diff --git a/test/ntcrule/full/2018-10-09/APP_GROUP.0000050997 b/test/ntcrule/full/2018-10-09/APP_OBJECT.0000050997
index 815f37d..815f37d 100644
--- a/test/ntcrule/full/2018-10-09/APP_GROUP.0000050997
+++ b/test/ntcrule/full/2018-10-09/APP_OBJECT.0000050997
diff --git a/test/ntcrule/full/2018-10-09/MM_GROUP.0000050997 b/test/ntcrule/full/2018-10-09/MM_OBJECT.0000050997
index 3dbb1ce..3dbb1ce 100644
--- a/test/ntcrule/full/2018-10-09/MM_GROUP.0000050997
+++ b/test/ntcrule/full/2018-10-09/MM_OBJECT.0000050997
diff --git a/test/ntcrule/full/2018-10-09/NTC_GROUP2RULE.0000050997 b/test/ntcrule/full/2018-10-09/NTC_OBJECT2RULE.0000050997
index 633cea4..633cea4 100644
--- a/test/ntcrule/full/2018-10-09/NTC_GROUP2RULE.0000050997
+++ b/test/ntcrule/full/2018-10-09/NTC_OBJECT2RULE.0000050997
diff --git a/test/ntcrule/full/2018-10-09/WHITE_LIST_GROUP.0000050997 b/test/ntcrule/full/2018-10-09/WHITE_LIST_OBJECT.0000050997
index 6131c1e..6131c1e 100644
--- a/test/ntcrule/full/2018-10-09/WHITE_LIST_GROUP.0000050997
+++ b/test/ntcrule/full/2018-10-09/WHITE_LIST_OBJECT.0000050997
diff --git a/test/ntcrule/full/index/full_config_index.0000050997 b/test/ntcrule/full/index/full_config_index.0000050997
index 921880d..e6de54e 100644
--- a/test/ntcrule/full/index/full_config_index.0000050997
+++ b/test/ntcrule/full/index/full_config_index.0000050997
@@ -1,11 +1,11 @@
APP_RULE 21 ./ntcrule/full/2018-10-09/APP_RULE.0000050997
-APP_GROUP 37 ./ntcrule/full/2018-10-09/APP_GROUP.0000050997
+APP_OBJECT 37 ./ntcrule/full/2018-10-09/APP_OBJECT.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_RULE 1 ./ntcrule/full/2018-10-09/MM_RULE.0000050997
-MM_GROUP 1 ./ntcrule/full/2018-10-09/MM_GROUP.0000050997
+MM_OBJECT 1 ./ntcrule/full/2018-10-09/MM_OBJECT.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_RULE 78 ./ntcrule/full/2018-10-09/NTC_RULE.0000050997
@@ -13,7 +13,7 @@ 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_GROUP2RULE 103 ./ntcrule/full/2018-10-09/NTC_GROUP2RULE.0000050997
+NTC_OBJECT2RULE 103 ./ntcrule/full/2018-10-09/NTC_OBJECT2RULE.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
@@ -22,5 +22,5 @@ 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_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_OBJECT 1 ./ntcrule/full/2018-10-09/WHITE_LIST_OBJECT.0000050997
WHITE_LIST_IP 1 ./ntcrule/full/2018-10-09/WHITE_LIST_IP.0000050997
diff --git a/test/object_nesting/CMakeLists.txt b/test/object_nesting/CMakeLists.txt
new file mode 100644
index 0000000..f94766c
--- /dev/null
+++ b/test/object_nesting/CMakeLists.txt
@@ -0,0 +1,4 @@
+include_directories(${PROJECT_SOURCE_DIR}/src/inc_internal)
+
+add_executable(object_nesting_gtest object_nesting_gtest.cpp)
+target_link_libraries(object_nesting_gtest maat_frame_static gtest_static) \ No newline at end of file
diff --git a/test/object_nesting/object_nesting_L3.conf b/test/object_nesting/object_nesting_L3.conf
new file mode 100644
index 0000000..2ba9f26
--- /dev/null
+++ b/test/object_nesting/object_nesting_L3.conf
@@ -0,0 +1,51 @@
+{
+ "add_items": [
+ {
+ "object_id": 5,
+ "included_sub_object_ids": "8",
+ "excluded_sub_object_ids": "9"
+ },
+ {
+ "object_id": 1,
+ "included_sub_object_ids": "6,9",
+ "excluded_sub_object_ids": "5"
+ },
+ {
+ "object_id": 6,
+ "included_sub_object_ids": "10,11",
+ "excluded_sub_object_ids": "7"
+ },
+ {
+ "object_id": 7,
+ "included_sub_object_ids": "11,12",
+ "excluded_sub_object_ids": "10"
+ },
+ {
+ "object_id": 2,
+ "included_sub_object_ids": "7",
+ "excluded_sub_object_ids": "6"
+ },
+ {
+ "object_id": 4,
+ "included_sub_object_ids": "7",
+ "excluded_sub_object_ids": "13"
+ },
+ {
+ "object_id": 3,
+ "included_sub_object_ids": "13",
+ "excluded_sub_object_ids": "6"
+ }
+ ],
+ "del_items": [
+ {
+ "object_id": 6,
+ "included_sub_object_ids": "null",
+ "excluded_sub_object_ids": "7"
+ },
+ {
+ "object_id": 4,
+ "included_sub_object_ids": "null",
+ "excluded_sub_object_ids": "13"
+ }
+ ]
+} \ No newline at end of file
diff --git a/test/group_nesting/group_nesting_L3.png b/test/object_nesting/object_nesting_L3.png
index e9077d4..e9077d4 100644
--- a/test/group_nesting/group_nesting_L3.png
+++ b/test/object_nesting/object_nesting_L3.png
Binary files differ
diff --git a/test/object_nesting/object_nesting_L4.conf b/test/object_nesting/object_nesting_L4.conf
new file mode 100644
index 0000000..ca502ed
--- /dev/null
+++ b/test/object_nesting/object_nesting_L4.conf
@@ -0,0 +1,76 @@
+{
+ "add_items": [
+ {
+ "object_id": 8,
+ "included_sub_object_ids": "14",
+ "excluded_sub_object_ids": "15"
+ },
+ {
+ "object_id": 9,
+ "included_sub_object_ids": "14,16",
+ "excluded_sub_object_ids": "null"
+ },
+ {
+ "object_id": 5,
+ "included_sub_object_ids": "8",
+ "excluded_sub_object_ids": "9"
+ },
+ {
+ "object_id": 1,
+ "included_sub_object_ids": "6,9",
+ "excluded_sub_object_ids": "5"
+ },
+ {
+ "object_id": 10,
+ "included_sub_object_ids": "16",
+ "excluded_sub_object_ids": "null"
+ },
+ {
+ "object_id": 7,
+ "included_sub_object_ids": "10,12",
+ "excluded_sub_object_ids": "null"
+ },
+ {
+ "object_id": 6,
+ "included_sub_object_ids": "7,11",
+ "excluded_sub_object_ids": "10"
+ },
+ {
+ "object_id": 11,
+ "included_sub_object_ids": "17",
+ "excluded_sub_object_ids": "null"
+ },
+ {
+ "object_id": 12,
+ "included_sub_object_ids": "17",
+ "excluded_sub_object_ids": "null"
+ },
+ {
+ "object_id":13,
+ "included_sub_object_ids": "17",
+ "excluded_sub_object_ids": "18"
+ },
+ {
+ "object_id": 2,
+ "included_sub_object_ids": "7",
+ "excluded_sub_object_ids": "6"
+ },
+ {
+ "object_id": 4,
+ "included_sub_object_ids": "7",
+ "excluded_sub_object_ids": "13"
+ },
+ {
+ "object_id": 3,
+ "included_sub_object_ids": "13",
+ "excluded_sub_object_ids": "6"
+ }
+ ],
+ "del_items": [
+ {
+ "object_id": 6,
+ "included_sub_object_ids": "null",
+ "excluded_sub_object_ids": "10"
+ }
+ ]
+} \ No newline at end of file
diff --git a/test/group_nesting/group_nesting_L4.png b/test/object_nesting/object_nesting_L4.png
index 25830f2..25830f2 100644
--- a/test/group_nesting/group_nesting_L4.png
+++ b/test/object_nesting/object_nesting_L4.png
Binary files differ
diff --git a/test/object_nesting/object_nesting_exceed.conf b/test/object_nesting/object_nesting_exceed.conf
new file mode 100644
index 0000000..440f5d5
--- /dev/null
+++ b/test/object_nesting/object_nesting_exceed.conf
@@ -0,0 +1,56 @@
+{
+ "add_items": [
+ {
+ "object_id": 3,
+ "included_sub_object_ids": "6",
+ "excluded_sub_object_ids": "7"
+ },
+ {
+ "object_id": 1,
+ "included_sub_object_ids": "3,7",
+ "excluded_sub_object_ids": "4"
+ },
+ {
+ "object_id": 10,
+ "included_sub_object_ids": "13",
+ "excluded_sub_object_ids": "null"
+ },
+ {
+ "object_id": 11,
+ "included_sub_object_ids": "10",
+ "excluded_sub_object_ids": "null"
+ },
+ {
+ "object_id": 8,
+ "included_sub_object_ids": "11",
+ "excluded_sub_object_ids": "null"
+ },
+ {
+ "object_id": 5,
+ "included_sub_object_ids": "8",
+ "excluded_sub_object_ids": "null"
+ },
+ {
+ "object_id": 4,
+ "included_sub_object_ids": "5",
+ "excluded_sub_object_ids": "null"
+ },
+ {
+ "object_id": 12,
+ "included_sub_object_ids": "5",
+ "excluded_sub_object_ids": "2"
+ },
+ {
+ "object_id": 2,
+ "included_sub_object_ids": "4",
+ "excluded_sub_object_ids": "null"
+ }
+ ],
+ "del_items": [
+ {
+ "object_id": 10,
+ "included_sub_object_ids": "13",
+ "excluded_sub_object_ids": "null"
+ }
+ ]
+} \ No newline at end of file
diff --git a/test/group_nesting/group_nesting_exceed.png b/test/object_nesting/object_nesting_exceed.png
index a70239c..a70239c 100644
--- a/test/group_nesting/group_nesting_exceed.png
+++ b/test/object_nesting/object_nesting_exceed.png
Binary files differ
diff --git a/test/object_nesting/object_nesting_gtest.cpp b/test/object_nesting/object_nesting_gtest.cpp
new file mode 100644
index 0000000..1038106
--- /dev/null
+++ b/test/object_nesting/object_nesting_gtest.cpp
@@ -0,0 +1,492 @@
+#include "maat.h"
+#include "log/log.h"
+#include "cJSON/cJSON.h"
+#include "maat_core.h"
+#include "uthash/utarray.h"
+#include "maat_utils.h"
+#include "maat_command.h"
+#include "maat_object.h"
+#include <gtest/gtest.h>
+
+#define MODULE_OBJECT_NESTING_GTEST module_name_str("maat.object_nesting_gtest")
+
+#define MAX_IDS_STR_LEN 64
+#define MAX_ITEM_NUM 64
+#define WAIT_FOR_EFFECTIVE_S 2
+#define MAX_G2G_SCAN_TIMES (1000 * 1000)
+
+const char *g_table_info_path = "./object_exclude_table_info.conf";
+const char *log_file = "./object_exclude_gtest.log";
+
+struct object_item {
+ long long object_id;
+ char incl_sub_ids_str[MAX_IDS_STR_LEN];
+ char excl_sub_ids_str[MAX_IDS_STR_LEN];
+};
+
+struct object2object_rule {
+ size_t n_add_item;
+ size_t n_del_item;
+ struct object_item add_items[MAX_ITEM_NUM];
+ struct object_item del_items[MAX_ITEM_NUM];
+};
+
+UT_icd ut_ex_object_id_icd = {sizeof(long long), NULL, NULL, NULL};
+
+static int
+parse_config_file(const char *filename, struct object2object_rule *rules)
+{
+ unsigned char *json_buff = NULL;
+ size_t json_buff_size = 0;
+
+ int ret = load_file_to_memory(filename, &json_buff, &json_buff_size);
+ if (ret < 0) {
+ printf("load file:%s to memory failed.\n", filename);
+ return -1;
+ }
+
+ size_t rule_cnt = 0;
+ cJSON *items_array = NULL;
+ cJSON *root = cJSON_Parse((const char *)json_buff);
+ if (NULL == root) {
+ printf("Error before: %-200.200s\n", cJSON_GetErrorPtr());
+ ret = -1;
+ goto next;
+ }
+
+ items_array = cJSON_GetObjectItem(root, "add_items");
+ if (NULL == items_array) {
+ printf("Error before: %-200.200s\n", cJSON_GetErrorPtr());
+ ret = -1;
+ goto next;
+ }
+
+ rule_cnt = cJSON_GetArraySize(items_array);
+ for (size_t i = 0; i < rule_cnt; i++) {
+ cJSON *item_obj = cJSON_GetArrayItem(items_array, i);
+ cJSON *tmp_item = cJSON_GetObjectItem(item_obj, "object_id");
+ if (tmp_item != NULL && tmp_item->type == cJSON_Number) {
+ rules->add_items[i].object_id = tmp_item->valueint;
+ }
+
+ tmp_item = cJSON_GetObjectItem(item_obj, "included_sub_object_ids");
+ if (tmp_item != NULL && tmp_item->type == cJSON_String) {
+ memcpy(rules->add_items[i].incl_sub_ids_str, tmp_item->valuestring,
+ strlen(tmp_item->valuestring));
+ }
+
+ tmp_item = cJSON_GetObjectItem(item_obj, "excluded_sub_object_ids");
+ if (tmp_item != NULL && tmp_item->type == cJSON_String) {
+ memcpy(rules->add_items[i].excl_sub_ids_str, tmp_item->valuestring,
+ strlen(tmp_item->valuestring));
+ }
+ }
+ rules->n_add_item = rule_cnt;
+
+ items_array = cJSON_GetObjectItem(root, "del_items");
+ if (NULL == items_array) {
+ printf("Error before: %-200.200s\n", cJSON_GetErrorPtr());
+ ret = -1;
+ goto next;
+ }
+
+ rule_cnt = cJSON_GetArraySize(items_array);
+ for (size_t i = 0; i < rule_cnt; i++) {
+ cJSON *item_obj = cJSON_GetArrayItem(items_array, i);
+ cJSON *tmp_item = cJSON_GetObjectItem(item_obj, "object_id");
+ if (tmp_item != NULL && tmp_item->type == cJSON_Number) {
+ rules->del_items[i].object_id = tmp_item->valueint;
+ }
+
+ tmp_item = cJSON_GetObjectItem(item_obj, "included_sub_object_ids");
+ if (tmp_item != NULL && tmp_item->type == cJSON_String) {
+ memcpy(rules->del_items[i].incl_sub_ids_str, tmp_item->valuestring,
+ strlen(tmp_item->valuestring));
+ }
+
+ tmp_item = cJSON_GetObjectItem(item_obj, "excluded_sub_object_ids");
+ if (tmp_item != NULL && tmp_item->type == cJSON_String) {
+ memcpy(rules->del_items[i].excl_sub_ids_str, tmp_item->valuestring,
+ strlen(tmp_item->valuestring));
+ }
+ }
+ rules->n_del_item = rule_cnt;
+
+next:
+ cJSON_Delete(root);
+ FREE(json_buff);
+ return ret;
+}
+
+class MaatObjectExclude : public testing::Test
+{
+protected:
+ static void SetUpTestCase() {
+ unsigned char *json_buff = NULL;
+ size_t json_buff_size = 0;
+
+ logger = log_handle_create(log_file, 0);
+ garbage_bin = maat_garbage_bin_new(60);
+
+ int ret = load_file_to_memory(g_table_info_path, &json_buff, &json_buff_size);
+ if (ret < 0) {
+ log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "load_file_to_memory failed.");
+ assert(0);
+ }
+
+ cJSON *root = cJSON_Parse((const char *)json_buff);
+ if (!root) {
+ log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "cJSON_Parse failed.");
+ assert(0);
+ }
+
+ g2g_schema = object2object_schema_new(root, NULL, "EXCLUDE_OBJECT2OBJECT", logger);
+ FREE(json_buff);
+ cJSON_Delete(root);
+
+ if (NULL == g2g_schema) {
+ log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_schema_new failed.");
+ assert(0);
+ }
+ }
+
+ static void TearDownTestCase() {
+ log_handle_destroy(logger);
+ maat_garbage_bin_free(garbage_bin);
+ object2object_schema_free(g2g_schema);
+ }
+
+ static void *g2g_schema;
+ static struct log_handle *logger;
+ static struct maat_garbage_bin *garbage_bin;
+};
+
+void *MaatObjectExclude::g2g_schema;
+struct log_handle *MaatObjectExclude::logger;
+struct maat_garbage_bin *MaatObjectExclude::garbage_bin;
+
+TEST_F(MaatObjectExclude, level_3_function) {
+ char table_line[1024];
+ struct object2object_rule rules;
+ const char *table_name = "EXCLUDE_OBJECT2OBJECT";
+
+ void *g2g_runtime = object2object_runtime_new(g2g_schema, 1, garbage_bin, logger);
+ if (NULL == g2g_runtime) {
+ log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_runtime_new failed.");
+ assert(0);
+ }
+
+ memset(&rules, 0, sizeof(rules));
+ int ret = parse_config_file("object_nesting_L3.conf", &rules);
+ EXPECT_EQ(ret, 0);
+
+ for (size_t i = 0; i < rules.n_add_item; i++) {
+ memset(table_line, 0, sizeof(table_line));
+
+ sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].object_id,
+ rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
+ object2object_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
+ }
+
+ object2object_runtime_commit(g2g_runtime, table_name, 1);
+
+ long long hit_object_ids[2] = {11, 13};
+ long long super_object_ids[MAX_ITEM_NUM];
+ size_t super_object_cnt = object2object_runtime_get_super_objects(g2g_runtime, hit_object_ids, 2,
+ super_object_ids, MAX_ITEM_NUM);
+ EXPECT_EQ(super_object_cnt, 2);
+ EXPECT_EQ(super_object_ids[0], 2);
+ EXPECT_EQ(super_object_ids[1], 7);
+
+ //delete object_id = 7, super_object_id = 6, is_exclude = 1
+ memset(table_line, 0, sizeof(table_line));
+ sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].object_id,
+ rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
+ object2object_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
+ object2object_runtime_commit(g2g_runtime, table_name, 2);
+
+ super_object_cnt = object2object_runtime_get_super_objects(g2g_runtime, hit_object_ids, 2,
+ super_object_ids, MAX_ITEM_NUM);
+ EXPECT_EQ(super_object_cnt, 3);
+ EXPECT_EQ(super_object_ids[0], 1);
+ EXPECT_EQ(super_object_ids[1], 6);
+ EXPECT_EQ(super_object_ids[2], 7);
+
+ //delete object_id = 13, super_object_id = 4, is_exclude = 1
+ memset(table_line, 0, sizeof(table_line));
+ sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[1].object_id,
+ rules.del_items[1].incl_sub_ids_str, rules.del_items[1].excl_sub_ids_str, 0);
+ object2object_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
+ object2object_runtime_commit(g2g_runtime, table_name, 3);
+
+ super_object_cnt = object2object_runtime_get_super_objects(g2g_runtime, hit_object_ids, 2,
+ super_object_ids, MAX_ITEM_NUM);
+ EXPECT_EQ(super_object_cnt, 4);
+ EXPECT_EQ(super_object_ids[0], 1);
+ EXPECT_EQ(super_object_ids[1], 4);
+ EXPECT_EQ(super_object_ids[2], 6);
+ EXPECT_EQ(super_object_ids[3], 7);
+
+ object2object_runtime_free(g2g_runtime);
+}
+
+TEST_F(MaatObjectExclude, level_3_perf) {
+ char table_line[1024];
+ struct object2object_rule rules;
+ const char *table_name = "EXCLUDE_OBJECT2OBJECT";
+
+ void *g2g_runtime = object2object_runtime_new(g2g_schema, 1, garbage_bin, logger);
+ if (NULL == g2g_runtime) {
+ log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_runtime_new failed.");
+ assert(0);
+ }
+
+ memset(&rules, 0, sizeof(rules));
+ int ret = parse_config_file("object_nesting_L3.conf", &rules);
+ EXPECT_EQ(ret, 0);
+
+ for (size_t i = 0; i < rules.n_add_item; i++) {
+ memset(table_line, 0, sizeof(table_line));
+
+ sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].object_id,
+ rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
+ object2object_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
+ }
+
+ object2object_runtime_commit(g2g_runtime, table_name, 4);
+
+ long long hit_object_ids[2] = {11, 13};
+ long long super_object_ids[MAX_ITEM_NUM];
+ struct timespec start, end;
+ struct log_handle *logger = MaatObjectExclude::logger;
+
+ clock_gettime(CLOCK_MONOTONIC, &start);
+ for (int i = 0; i < MAX_G2G_SCAN_TIMES; i++) {
+ object2object_runtime_get_super_objects(g2g_runtime, hit_object_ids, 2,
+ super_object_ids, MAX_ITEM_NUM);
+ }
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ long long time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
+ log_info(logger, MODULE_OBJECT_NESTING_GTEST, "level_3_basic hit 2 super_objects scan consume time %lldms",
+ time_elapse_ms);
+
+ //delete object_id = 7, super_object_id = 6, is_exclude = 1
+ memset(table_line, 0, sizeof(table_line));
+ sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].object_id,
+ rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
+ object2object_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
+ object2object_runtime_commit(g2g_runtime, table_name, 5);
+
+ clock_gettime(CLOCK_MONOTONIC, &start);
+ for (int i = 0; i < MAX_G2G_SCAN_TIMES; i++) {
+ object2object_runtime_get_super_objects(g2g_runtime, hit_object_ids, 2,
+ super_object_ids, MAX_ITEM_NUM);
+ }
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
+ log_info(logger, MODULE_OBJECT_NESTING_GTEST, "level_3_basic hit 3 super_objects scan consume time %lldms",
+ time_elapse_ms);
+
+ //delete object_id = 13, super_object_id = 4, is_exclude = 1
+ memset(table_line, 0, sizeof(table_line));
+ sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[1].object_id,
+ rules.del_items[1].incl_sub_ids_str, rules.del_items[1].excl_sub_ids_str, 0);
+ object2object_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
+ object2object_runtime_commit(g2g_runtime, table_name, 6);
+
+ clock_gettime(CLOCK_MONOTONIC, &start);
+ for (int i = 0; i < MAX_G2G_SCAN_TIMES; i++) {
+ object2object_runtime_get_super_objects(g2g_runtime, hit_object_ids, 2,
+ super_object_ids, MAX_ITEM_NUM);
+ }
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
+ log_info(logger, MODULE_OBJECT_NESTING_GTEST, "level_3_basic hit 4 super_objects scan consume time %lldms",
+ time_elapse_ms);
+
+ object2object_runtime_free(g2g_runtime);
+}
+
+TEST_F(MaatObjectExclude, level_4_function) {
+ char table_line[1024];
+ struct object2object_rule rules;
+ const char *table_name = "EXCLUDE_OBJECT2OBJECT";
+
+ void *g2g_runtime = object2object_runtime_new(g2g_schema, 1, garbage_bin, logger);
+ if (NULL == g2g_runtime) {
+ log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_runtime_new failed.");
+ assert(0);
+ }
+
+ memset(&rules, 0, sizeof(rules));
+ int ret = parse_config_file("object_nesting_L4.conf", &rules);
+ EXPECT_EQ(ret, 0);
+
+ for (size_t i = 0; i < rules.n_add_item; i++) {
+ memset(table_line, 0, sizeof(table_line));
+
+ sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].object_id,
+ rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
+ object2object_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
+ }
+
+ object2object_runtime_commit(g2g_runtime, table_name, 7);
+
+ long long hit_object_ids[2] = {14, 16};
+ long long super_object_ids[MAX_ITEM_NUM];
+ size_t super_object_cnt = object2object_runtime_get_super_objects(g2g_runtime, hit_object_ids, 2,
+ super_object_ids, MAX_ITEM_NUM);
+ EXPECT_EQ(super_object_cnt, 5);
+ EXPECT_EQ(super_object_ids[0], 4);
+ EXPECT_EQ(super_object_ids[1], 7);
+ EXPECT_EQ(super_object_ids[2], 8);
+ EXPECT_EQ(super_object_ids[3], 9);
+ EXPECT_EQ(super_object_ids[4], 10);
+
+ //delete object_id = 10, super_object_id = 6, is_exclude = 1
+ memset(table_line, 0, sizeof(table_line));
+ sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].object_id,
+ rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
+ object2object_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
+ object2object_runtime_commit(g2g_runtime, table_name, 8);
+
+ super_object_cnt = object2object_runtime_get_super_objects(g2g_runtime, hit_object_ids, 2,
+ super_object_ids, MAX_ITEM_NUM);
+ EXPECT_EQ(super_object_cnt, 7);
+ EXPECT_EQ(super_object_ids[0], 1);
+ EXPECT_EQ(super_object_ids[1], 4);
+ EXPECT_EQ(super_object_ids[2], 6);
+ EXPECT_EQ(super_object_ids[3], 7);
+ EXPECT_EQ(super_object_ids[4], 8);
+ EXPECT_EQ(super_object_ids[5], 9);
+ EXPECT_EQ(super_object_ids[6], 10);
+
+ object2object_runtime_free(g2g_runtime);
+}
+
+TEST_F(MaatObjectExclude, level_4_perf) {
+ char table_line[1024];
+ struct object2object_rule rules;
+ const char *table_name = "EXCLUDE_OBJECT2OBJECT";
+
+ void *g2g_runtime = object2object_runtime_new(g2g_schema, 1, garbage_bin, logger);
+ if (NULL == g2g_runtime) {
+ log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_runtime_new failed.");
+ assert(0);
+ }
+
+ memset(&rules, 0, sizeof(rules));
+ int ret = parse_config_file("object_nesting_L4.conf", &rules);
+ EXPECT_EQ(ret, 0);
+
+ for (size_t i = 0; i < rules.n_add_item; i++) {
+ memset(table_line, 0, sizeof(table_line));
+
+ sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].object_id,
+ rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
+ object2object_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
+ }
+
+ object2object_runtime_commit(g2g_runtime, table_name, 7);
+
+ long long hit_object_ids[2] = {14, 16};
+ long long super_object_ids[MAX_ITEM_NUM];
+ struct timespec start, end;
+ struct log_handle *logger = MaatObjectExclude::logger;
+
+ clock_gettime(CLOCK_MONOTONIC, &start);
+ for (int i = 0; i < MAX_G2G_SCAN_TIMES; i++) {
+ object2object_runtime_get_super_objects(g2g_runtime, hit_object_ids, 2,
+ super_object_ids, MAX_ITEM_NUM);
+ }
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ long long time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
+ log_info(logger, MODULE_OBJECT_NESTING_GTEST, "level_4_basic hit 5 super_objects scan consume time %lldms",
+ time_elapse_ms);
+
+ //delete object_id = 10, super_object_id = 6, is_exclude = 1
+ memset(table_line, 0, sizeof(table_line));
+ sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].object_id,
+ rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
+ object2object_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
+ object2object_runtime_commit(g2g_runtime, table_name, 8);
+
+ clock_gettime(CLOCK_MONOTONIC, &start);
+ for (int i = 0; i < MAX_G2G_SCAN_TIMES; i++) {
+ object2object_runtime_get_super_objects(g2g_runtime, hit_object_ids, 2,
+ super_object_ids, MAX_ITEM_NUM);
+ }
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
+ log_info(logger, MODULE_OBJECT_NESTING_GTEST, "level_4_basic hit 7 super_objects scan consume time %lldms",
+ time_elapse_ms);
+
+ object2object_runtime_free(g2g_runtime);
+}
+
+TEST_F(MaatObjectExclude, level_exceed_function) {
+ char table_line[1024];
+ struct object2object_rule rules;
+ const char *table_name = "EXCLUDE_OBJECT2OBJECT";
+
+ void *g2g_runtime = object2object_runtime_new(g2g_schema, 1, garbage_bin, logger);
+ if (NULL == g2g_runtime) {
+ log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_runtime_new failed.");
+ assert(0);
+ }
+
+ memset(&rules, 0, sizeof(rules));
+ int ret = parse_config_file("object_nesting_exceed.conf", &rules);
+ EXPECT_EQ(ret, 0);
+
+ for (size_t i = 0; i < rules.n_add_item; i++) {
+ memset(table_line, 0, sizeof(table_line));
+
+ sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].object_id,
+ rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
+ object2object_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
+ }
+
+ object2object_runtime_commit(g2g_runtime, table_name, 8);
+
+ long long hit_object_ids[2] = {7, 13};
+ long long super_object_ids[MAX_ITEM_NUM];
+ size_t super_object_cnt = object2object_runtime_get_super_objects(g2g_runtime, hit_object_ids, 2,
+ super_object_ids, MAX_ITEM_NUM);
+ EXPECT_EQ(super_object_cnt, 6);
+ EXPECT_EQ(super_object_ids[0], 4);
+ EXPECT_EQ(super_object_ids[1], 5);
+ EXPECT_EQ(super_object_ids[2], 8);
+ EXPECT_EQ(super_object_ids[3], 10);
+ EXPECT_EQ(super_object_ids[4], 11);
+ EXPECT_EQ(super_object_ids[5], 12);
+
+ //delete object_id = 13, super_object_id = 10, is_exclude = 0
+ memset(table_line, 0, sizeof(table_line));
+ sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].object_id,
+ rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
+ object2object_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
+ object2object_runtime_commit(g2g_runtime, table_name, 9);
+
+ hit_object_ids[0] = 7;
+ hit_object_ids[1] = 10;
+ super_object_cnt = object2object_runtime_get_super_objects(g2g_runtime, hit_object_ids, 2,
+ super_object_ids, MAX_ITEM_NUM);
+ EXPECT_EQ(super_object_cnt, 5);
+ EXPECT_EQ(super_object_ids[0], 2);
+ EXPECT_EQ(super_object_ids[1], 4);
+ EXPECT_EQ(super_object_ids[2], 5);
+ EXPECT_EQ(super_object_ids[3], 8);
+ EXPECT_EQ(super_object_ids[4], 11);
+
+ object2object_runtime_free(g2g_runtime);
+}
+
+int main(int argc, char ** argv)
+{
+ int ret = 0;
+ ::testing::InitGoogleTest(&argc, argv);
+ ret = RUN_ALL_TESTS();
+
+ return ret;
+} \ No newline at end of file
diff --git a/test/object_nesting/object_nesting_table_info.conf b/test/object_nesting/object_nesting_table_info.conf
new file mode 100644
index 0000000..2b2068b
--- /dev/null
+++ b/test/object_nesting/object_nesting_table_info.conf
@@ -0,0 +1,11 @@
+{
+ "table_id":1,
+ "table_name":"EXCLUDE_OBJECT2OBJECT",
+ "table_type":"object2object",
+ "valid_column":4,
+ "custom": {
+ "object_id":1,
+ "included_sub_object_ids":2,
+ "excluded_sub_object_ids":3
+ }
+} \ No newline at end of file
diff --git a/test/table_info.conf b/test/table_info.conf
index 28cee86..c57eaed 100644
--- a/test/table_info.conf
+++ b/test/table_info.conf
@@ -38,14 +38,14 @@
},
{
"table_id":3,
- "table_name":"GROUP2RULE",
- "db_tables":["GROUP2RULE_DEFAULT", "GROUP2RULE_ALIAS"],
- "table_type":"group2rule",
+ "table_name":"OBJECT2RULE",
+ "db_tables":["OBJECT2RULE_DEFAULT", "OBJECT2RULE_ALIAS"],
+ "table_type":"object2rule",
"associated_rule_table_id":2,
"valid_column":6,
- "schema_tag": "{\"group2rule\": \"group2rule\"}",
+ "schema_tag": "{\"object2rule\": \"object2rule\"}",
"custom": {
- "group_id":1,
+ "object_id":1,
"rule_id":2,
"negate_option":3,
"attribute_name":4,
@@ -77,12 +77,12 @@
},
{
"table_id":6,
- "table_name":"GROUP2RULE_FIREWALL",
- "table_type":"group2rule",
+ "table_name":"OBJECT2RULE_FIREWALL",
+ "table_type":"object2rule",
"associated_rule_table_id":5,
"valid_column":6,
"custom": {
- "group_id":1,
+ "object_id":1,
"rule_id":2,
"negate_option":3,
"attribute_name":4,
@@ -91,13 +91,13 @@
},
{
"table_id":7,
- "table_name":"GROUP2GROUP",
- "table_type":"group2group",
+ "table_name":"OBJECT2OBJECT",
+ "table_type":"object2object",
"valid_column":4,
"custom": {
- "group_id":1,
- "included_sub_group_ids":2,
- "excluded_sub_group_ids":3
+ "object_id":1,
+ "included_sub_object_ids":2,
+ "excluded_sub_object_ids":3
}
},
{
@@ -137,7 +137,7 @@
"schema_tag": "{\"http_region\": \"expr\"}",
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"expr_type":3,
"keywords":4
}
@@ -149,7 +149,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"expr_type":3,
"keywords":4
}
@@ -161,7 +161,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"ip":3,
"port":4
}
@@ -173,7 +173,7 @@
"valid_column":4,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"interval":3
}
},
@@ -196,7 +196,7 @@
"valid_column":6,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"district":3,
"expr_type":4,
"keywords":5
@@ -209,7 +209,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"expr_type":3,
"keywords":4
}
@@ -271,7 +271,7 @@
"valid_column":6,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"district":3,
"expr_type":4,
"keywords":5
@@ -284,7 +284,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"expr_type":3,
"keywords":4
}
@@ -296,7 +296,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"expr_type":3,
"keywords":4
}
@@ -308,7 +308,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"ip":3,
"port":4
}
@@ -358,7 +358,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"expr_type":3,
"keywords":4
}
@@ -382,7 +382,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"expr_type":3,
"keywords":4
}
@@ -400,7 +400,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"district":3,
"interval":4
}
@@ -423,7 +423,7 @@
"valid_column":4,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"interval":3
}
},
@@ -434,7 +434,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"expr_type":3,
"keywords":4
}
@@ -446,7 +446,7 @@
"valid_column":4,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"interval":3
}
},
@@ -468,7 +468,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"flag":3,
"flag_mask":4
}
@@ -480,7 +480,7 @@
"valid_column":6,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"district":3,
"flag":4,
"flag_mask":5
@@ -537,7 +537,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"ip":3,
"port":4
}
@@ -549,7 +549,7 @@
"valid_column":4,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"interval":3
}
},
@@ -560,7 +560,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"expr_type":3,
"keywords":4
}
@@ -572,7 +572,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"expr_type":3,
"keywords":4
}
@@ -584,7 +584,7 @@
"valid_column":5,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"flag":3,
"flag_mask":4
}
diff --git a/test/test_utils.cpp b/test/test_utils.cpp
index d44bd12..cdb862e 100644
--- a/test/test_utils.cpp
+++ b/test/test_utils.cpp
@@ -165,21 +165,21 @@ int rule_table_set_line(struct maat *maat_inst, const char *table_name,
return maat_cmd_set_line(maat_inst, &line_rule);
}
-#define TO_GROUP2X_KEY(group_id, parent_id, condition_index) \
- (((unsigned long)group_id<<32|parent_id) + condition_index)
+#define TO_OBJECT2X_KEY(object_id, parent_id, condition_index) \
+ (((unsigned long)object_id<<32|parent_id) + condition_index)
-int group2rule_table_set_line(struct maat *maat_inst, const char *table_name,
- enum maat_operation op, long long group_id,
+int object2rule_table_set_line(struct maat *maat_inst, const char *table_name,
+ enum maat_operation op, long long object_id,
long long rule_id, int negate_option,
const char *attribute_name, int condition_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, rule_id, negate_option, attribute_name, condition_index, op);
+ object_id, rule_id, negate_option, attribute_name, condition_index, op);
struct maat_cmd_line line_rule;
- line_rule.rule_id = TO_GROUP2X_KEY(group_id, rule_id, condition_index);
+ line_rule.rule_id = TO_OBJECT2X_KEY(object_id, rule_id, condition_index);
line_rule.table_line = table_line;
line_rule.table_name = table_name;
line_rule.expire_after = expire_after;
@@ -187,16 +187,16 @@ int group2rule_table_set_line(struct maat *maat_inst, const char *table_name,
return maat_cmd_set_line(maat_inst, &line_rule);
}
-int group2group_table_set_line(struct maat *maat_inst, const char *table_name,
- enum maat_operation op, long long group_id,
- long long sub_group_id, int expire_after)
+int object2object_table_set_line(struct maat *maat_inst, const char *table_name,
+ enum maat_operation op, long long object_id,
+ long long sub_object_id, int expire_after)
{
char table_line[128] = {0};
- sprintf(table_line, "%lld\t%lld\t%s\t%d", group_id, sub_group_id,
+ sprintf(table_line, "%lld\t%lld\t%s\t%d", object_id, sub_object_id,
"null", op);
struct maat_cmd_line line_rule;
- line_rule.rule_id = TO_GROUP2X_KEY(group_id, sub_group_id, 0);
+ line_rule.rule_id = TO_OBJECT2X_KEY(object_id, sub_object_id, 0);
line_rule.table_line = table_line;
line_rule.table_name = table_name;
line_rule.expire_after = expire_after;
@@ -206,7 +206,7 @@ int group2group_table_set_line(struct maat *maat_inst, const char *table_name,
int expr_table_set_line(struct maat *maat_inst, const char *table_name,
enum maat_operation op, long long item_id,
- long long group_id, const char *keywords,
+ long long object_id, const char *keywords,
const char *district, int expr_type, int expire_after)
{
char table_line[1024] = {0};
@@ -222,10 +222,10 @@ int expr_table_set_line(struct maat *maat_inst, const char *table_name,
if (table_type == TABLE_TYPE_EXPR_PLUS) {
sprintf(table_line, "%lld\t%lld\t%s\t%d\t%s\t%d",
- item_id, group_id, district, expr_type, keywords, op);
+ item_id, object_id, district, expr_type, keywords, op);
} else {
sprintf(table_line, "%lld\t%lld\t%d\t%s\t%d",
- item_id, group_id, expr_type, keywords, op);
+ item_id, object_id, expr_type, keywords, op);
}
struct maat_cmd_line line_rule;
@@ -238,7 +238,7 @@ int expr_table_set_line(struct maat *maat_inst, const char *table_name,
}
int interval_table_set_line(struct maat *maat_inst, const char *table_name,
- enum maat_operation op, long long item_id, long long group_id,
+ enum maat_operation op, long long item_id, long long object_id,
const char *port_str, const char *district, int expire_after)
{
char table_line[1024] = {0};
@@ -254,10 +254,10 @@ int interval_table_set_line(struct maat *maat_inst, const char *table_name,
if (table_type == TABLE_TYPE_INTERVAL_PLUS) {
sprintf(table_line, "%lld\t%lld\t%s\t%s\t%d",
- item_id, group_id, district, port_str, op);
+ item_id, object_id, district, port_str, op);
} else {
sprintf(table_line, "%lld\t%lld\t%s\t%d",
- item_id, group_id, port_str, op);
+ item_id, object_id, port_str, op);
}
struct maat_cmd_line line_rule;
@@ -271,7 +271,7 @@ int interval_table_set_line(struct maat *maat_inst, const char *table_name,
int ip_table_set_line(struct maat *maat_inst, const char *table_name,
enum maat_operation op, long long item_id,
- long long group_id, const char *ip, int expire_after)
+ long long object_id, const char *ip, int expire_after)
{
char table_line[1024] = {0};
int table_id = maat_get_table_id(maat_inst, table_name);
@@ -280,7 +280,7 @@ int ip_table_set_line(struct maat *maat_inst, const char *table_name,
}
sprintf(table_line, "%lld\t%lld\t%s\t0-65535\t%d",
- item_id, group_id, ip, op);
+ item_id, object_id, ip, op);
struct maat_cmd_line line_rule;
line_rule.rule_id = item_id;
@@ -292,7 +292,7 @@ int ip_table_set_line(struct maat *maat_inst, const char *table_name,
}
int flag_table_set_line(struct maat *maat_inst, const char *table_name,
enum maat_operation op, long long item_id,
- long long group_id, long long flag,
+ long long object_id, long long flag,
long long flag_mask, int expire_after)
{
char table_line[1024] = {0};
@@ -302,7 +302,7 @@ int flag_table_set_line(struct maat *maat_inst, const char *table_name,
}
sprintf(table_line, "%lld\t%lld\t%lld\t%lld\t%d",
- item_id, group_id, flag, flag_mask, op);
+ item_id, object_id, flag, flag_mask, op);
struct maat_cmd_line line_rule;
line_rule.rule_id = item_id;
diff --git a/test/test_utils.h b/test/test_utils.h
index cbe674f..76f8191 100644
--- a/test/test_utils.h
+++ b/test/test_utils.h
@@ -18,33 +18,33 @@ int rule_table_set_line(struct maat *maat_inst, const char *table_name,
const char *user_region, int condition_num,
int expire_after);
-int group2rule_table_set_line(struct maat *maat_inst, const char *table_name,
- enum maat_operation op, long long group_id,
+int object2rule_table_set_line(struct maat *maat_inst, const char *table_name,
+ enum maat_operation op, long long object_id,
long long rule_id, int negate_option,
const char *attribute_name, int condition_index,
int expire_after);
-int group2group_table_set_line(struct maat *maat_inst, const char *table_name,
- enum maat_operation op, long long group_id,
- long long sub_group_id, int expire_after);
+int object2object_table_set_line(struct maat *maat_inst, const char *table_name,
+ enum maat_operation op, long long object_id,
+ long long sub_object_id, int expire_after);
int expr_table_set_line(struct maat *maat_inst, const char *table_name,
enum maat_operation op, long long item_id,
- long long group_id, const char *keywords,
+ long long object_id, const char *keywords,
const char *district, int expr_type, int expire_after);
int interval_table_set_line(struct maat *maat_inst, const char *table_name,
enum maat_operation op, long long item_id,
- long long group_id, const char *port_str,
+ long long object_id, const char *port_str,
const char *district, int expire_after);
int ip_table_set_line(struct maat *maat_inst, const char *table_name,
enum maat_operation op, long long item_id,
- long long group_id, const char *ip, int expire_after);
+ long long object_id, const char *ip, int expire_after);
int flag_table_set_line(struct maat *maat_inst, const char *table_name,
enum maat_operation op, long long item_id,
- long long group_id, long long flag,
+ long long object_id, long long flag,
long long flag_mask, int expire_after);
void random_keyword_generate(char *keyword_buf, size_t sz); \ No newline at end of file
diff --git a/test/tsg_table_info.conf b/test/tsg_table_info.conf
index 3afbdde..f89fd9c 100644
--- a/test/tsg_table_info.conf
+++ b/test/tsg_table_info.conf
@@ -16,7 +16,7 @@
"valid_column":7,
"custom": {
"item_id":1,
- "group_id":2,
+ "object_id":2,
"keywords":3,
"expr_type":4,
"match_method":5,