modify fqdn_plugin table
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
|
||||
struct fqdn_plugin_schema {
|
||||
int item_id_column;
|
||||
int suffix_match_method_column;
|
||||
int fqdn_column;
|
||||
int rule_tag_column;
|
||||
int gc_timeout_s;
|
||||
@@ -78,17 +77,6 @@ void *fqdn_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
||||
goto error;
|
||||
}
|
||||
|
||||
custom_item = cJSON_GetObjectItem(item, "suffix_match_method");
|
||||
if (custom_item != NULL && custom_item->type == cJSON_Number) {
|
||||
schema->suffix_match_method_column = custom_item->valueint;
|
||||
} else {
|
||||
log_fatal(logger, MODULE_FQDN_PLUGIN,
|
||||
"[%s:%d] fqdn_plugin table:<%s> schema has no "
|
||||
"suffix_match_method column", __FUNCTION__,
|
||||
__LINE__, table_name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
// rule_tag is optional
|
||||
custom_item = cJSON_GetObjectItem(item, "fqdn");
|
||||
if (custom_item != NULL && custom_item->type == cJSON_Number) {
|
||||
@@ -304,25 +292,6 @@ fqdn_plugin_rule_new(const char *line, struct fqdn_plugin_schema *schema,
|
||||
}
|
||||
fqdn_plugin_rule->id = atoi(line + column_offset);
|
||||
|
||||
ret = get_column_pos(line, schema->suffix_match_method_column,
|
||||
&column_offset, &column_len);
|
||||
if (ret < 0) {
|
||||
log_fatal(logger, MODULE_FQDN_PLUGIN,
|
||||
"[%s:%d] fqdn_plugin table:<%s> has no suffix_match_method"
|
||||
" in line:%s", __FUNCTION__, __LINE__, table_name, line);
|
||||
goto error;
|
||||
}
|
||||
|
||||
fqdn_plugin_rule->is_suffix_match = atoi(line + column_offset);
|
||||
if (fqdn_plugin_rule->is_suffix_match != 0 &&
|
||||
fqdn_plugin_rule->is_suffix_match != 1) {
|
||||
log_fatal(logger, MODULE_FQDN_PLUGIN,
|
||||
"[%s:%d] fqdn_plugin table:<%s> suffix_match_method:%d "
|
||||
"is illegal in line:%s", __FUNCTION__, __LINE__, table_name,
|
||||
fqdn_plugin_rule->is_suffix_match, line);
|
||||
goto error;
|
||||
}
|
||||
|
||||
ret = get_column_pos(line, schema->fqdn_column,
|
||||
&column_offset, &column_len);
|
||||
if (ret < 0) {
|
||||
@@ -335,6 +304,12 @@ fqdn_plugin_rule_new(const char *line, struct fqdn_plugin_schema *schema,
|
||||
fqdn = line + column_offset;
|
||||
fqdn_len = column_len;
|
||||
|
||||
if (fqdn[0] == '*') {
|
||||
fqdn_plugin_rule->is_suffix_match = 1;
|
||||
fqdn++;
|
||||
fqdn_len--;
|
||||
}
|
||||
|
||||
if (fqdn[0] == '.') {
|
||||
fqdn++;
|
||||
fqdn_len--;
|
||||
|
||||
@@ -5764,7 +5764,7 @@ void fqdn_plugin_ex_new_cb(const char *table_name, int table_id, const char *key
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
ud->rule_id = atoi(table_line + column_offset);
|
||||
ret = get_column_pos(table_line, 4, &column_offset, &column_len);
|
||||
ret = get_column_pos(table_line, 3, &column_offset, &column_len);
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
sscanf(table_line + column_offset, "catid=%d", &ud->catid);
|
||||
@@ -8660,17 +8660,17 @@ TEST_F(MaatCmd, UpdateFQDNPlugin) {
|
||||
struct maat *maat_inst = MaatCmd::_shared_maat_inst;
|
||||
int *ex_data_counter = MaatCmd::_ex_data_counter;
|
||||
const char *table_line_add[TEST_CMD_LINE_NUM]={
|
||||
"201\t0\twww.example1.com\tcatid=1\t1",
|
||||
"202\t1\t.example1.com\tcatid=1\t1",
|
||||
"203\t0\tnews.example1.com\tcatid=2\t1",
|
||||
"204\t0\tr3---sn-i3belne6.example2.com\tcatid=3\t1",
|
||||
"205\t0\tr3---sn-i3belne6.example2.com\tcatid=3\t1"};
|
||||
"201\twww.example1.com\tcatid=1\t1",
|
||||
"202\t*.example1.com\tcatid=1\t1",
|
||||
"203\tnews.example1.com\tcatid=2\t1",
|
||||
"204\tr3---sn-i3belne6.example2.com\tcatid=3\t1",
|
||||
"205\tr3---sn-i3belne6.example2.com\tcatid=3\t1"};
|
||||
const char *table_line_del[TEST_CMD_LINE_NUM]={
|
||||
"201\t0\twww.example1.com\tcatid=1\t0",
|
||||
"202\t1\t.example1.com\tcatid=1\t0",
|
||||
"203\t0\tnews.example1.com\tcatid=2\t0",
|
||||
"204\t0\tr3---sn-i3belne6.example2.com\tcatid=3\t0",
|
||||
"205\t0\tr3---sn-i3belne6.example2.com\tcatid=3\t0"};
|
||||
"201\twww.example1.com\tcatid=1\t0",
|
||||
"202\t*.example1.com\tcatid=1\t0",
|
||||
"203\tnews.example1.com\tcatid=2\t0",
|
||||
"204\tr3---sn-i3belne6.example2.com\tcatid=3\t0",
|
||||
"205\tr3---sn-i3belne6.example2.com\tcatid=3\t0"};
|
||||
|
||||
int table_id = maat_get_table_id(maat_inst, table_name);
|
||||
ASSERT_GT(table_id, 0);
|
||||
|
||||
@@ -1107,7 +1107,7 @@ void perf_fqdn_plugin_EX_new_cb(const char *table_name, int table_id,
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
ud->rule_id = atoll(table_line+column_offset);
|
||||
ret = maat_helper_read_column(table_line, 4, &column_offset, &column_len);
|
||||
ret = maat_helper_read_column(table_line, 3, &column_offset, &column_len);
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
sscanf(table_line+column_offset, "catid=%d",&ud->catid);
|
||||
|
||||
@@ -4089,11 +4089,11 @@
|
||||
{
|
||||
"table_name": "TEST_FQDN_PLUGIN_WITH_EXDATA",
|
||||
"table_content": [
|
||||
"201\t0\twww.example1.com\tcatid=1\t1",
|
||||
"202\t1\t.example1.com\tcatid=1\t1",
|
||||
"203\t0\tnews.example1.com\tcatid=2\t1",
|
||||
"204\t0\tr3---sn-i3belne6.example2.com\tcatid=3\t1",
|
||||
"205\t0\tr3---sn-i3belne6.example2.com\tcatid=3\t1"
|
||||
"201\twww.example1.com\tcatid=1\t1",
|
||||
"202\t*.example1.com\tcatid=1\t1",
|
||||
"203\tnews.example1.com\tcatid=2\t1",
|
||||
"204\tr3---sn-i3belne6.example2.com\tcatid=3\t1",
|
||||
"205\tr3---sn-i3belne6.example2.com\tcatid=3\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -428,12 +428,11 @@
|
||||
"table_id":36,
|
||||
"table_name":"TEST_FQDN_PLUGIN_WITH_EXDATA",
|
||||
"table_type":"fqdn_plugin",
|
||||
"valid_column":5,
|
||||
"valid_column":4,
|
||||
"custom": {
|
||||
"gc_timeout_s": 3,
|
||||
"item_id":1,
|
||||
"suffix_match_method":2,
|
||||
"fqdn":3
|
||||
"fqdn":2
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user