Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
Anilm3 committed Jul 27, 2023
1 parent bf7b71b commit 0067103
Showing 1 changed file with 62 additions and 80 deletions.
142 changes: 62 additions & 80 deletions tests/integration/transformers/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,19 @@ TEST(TestTransformers, Base64Decode)
ddwaf_result out;
ASSERT_EQ(ddwaf_run(context, &map, &out, 2000), DDWAF_MATCH);
EXPECT_FALSE(out.timeout);
EXPECT_EVENTS(out,{
.id = "1",
.name = "rule1",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{
.op = "is_sqli",
.address = "value1",
.value = "'OR 1=1/*",
.highlight = "s&1c"}}});
EXPECT_EVENTS(out, {.id = "1",
.name = "rule1",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{.op = "is_sqli",
.address = "value1",
.value = "'OR 1=1/*",
.highlight = "s&1c"}}});

ddwaf_result_free(&out);
ddwaf_context_destroy(context);
ddwaf_destroy(handle);
}


TEST(TestTransformers, Base64DecodeAlias)
{
auto rule = readFile("base64_decode.yaml", base_dir);
Expand All @@ -66,15 +63,13 @@ TEST(TestTransformers, Base64DecodeAlias)
ddwaf_result out;
ASSERT_EQ(ddwaf_run(context, &map, &out, 2000), DDWAF_MATCH);
EXPECT_FALSE(out.timeout);
EXPECT_EVENTS(out,{
.id = "2",
.name = "rule2",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{
.op = "is_sqli",
.address = "value2",
.value = "'OR 1=1/*",
.highlight = "s&1c"}}});
EXPECT_EVENTS(out, {.id = "2",
.name = "rule2",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{.op = "is_sqli",
.address = "value2",
.value = "'OR 1=1/*",
.highlight = "s&1c"}}});

ddwaf_result_free(&out);
ddwaf_context_destroy(context);
Expand All @@ -100,16 +95,14 @@ TEST(TestTransformers, Base64Encode)
ddwaf_result out;
ASSERT_EQ(ddwaf_run(context, &map, &out, 2000), DDWAF_MATCH);
EXPECT_FALSE(out.timeout);
EXPECT_EVENTS(out,{
.id = "1",
.name = "rule1",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{
.op = "match_regex",
.op_value = "J09SIDE9MS8q",
.address = "value1",
.value = "J09SIDE9MS8q",
.highlight = "J09SIDE9MS8q"}}});
EXPECT_EVENTS(out, {.id = "1",
.name = "rule1",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{.op = "match_regex",
.op_value = "J09SIDE9MS8q",
.address = "value1",
.value = "J09SIDE9MS8q",
.highlight = "J09SIDE9MS8q"}}});

ddwaf_result_free(&out);
ddwaf_context_destroy(context);
Expand All @@ -135,16 +128,14 @@ TEST(TestTransformers, Base64EncodeAlias)
ddwaf_result out;
ASSERT_EQ(ddwaf_run(context, &map, &out, 2000), DDWAF_MATCH);
EXPECT_FALSE(out.timeout);
EXPECT_EVENTS(out,{
.id = "2",
.name = "rule2",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{
.op = "match_regex",
.op_value = "J09SIDE9MS8q",
.address = "value2",
.value = "J09SIDE9MS8q",
.highlight = "J09SIDE9MS8q"}}});
EXPECT_EVENTS(out, {.id = "2",
.name = "rule2",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{.op = "match_regex",
.op_value = "J09SIDE9MS8q",
.address = "value2",
.value = "J09SIDE9MS8q",
.highlight = "J09SIDE9MS8q"}}});

ddwaf_result_free(&out);
ddwaf_context_destroy(context);
Expand All @@ -170,16 +161,14 @@ TEST(TestTransformers, CompressWhitespace)
ddwaf_result out;
ASSERT_EQ(ddwaf_run(context, &map, &out, 2000), DDWAF_MATCH);
EXPECT_FALSE(out.timeout);
EXPECT_EVENTS(out,{
.id = "1",
.name = "rule1",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{
.op = "match_regex",
.op_value = "attack value",
.address = "value1",
.value = "attack value",
.highlight = "attack value"}}});
EXPECT_EVENTS(out, {.id = "1",
.name = "rule1",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{.op = "match_regex",
.op_value = "attack value",
.address = "value1",
.value = "attack value",
.highlight = "attack value"}}});

ddwaf_result_free(&out);
ddwaf_context_destroy(context);
Expand All @@ -205,16 +194,14 @@ TEST(TestTransformers, CompressWhitespaceAlias)
ddwaf_result out;
ASSERT_EQ(ddwaf_run(context, &map, &out, 2000), DDWAF_MATCH);
EXPECT_FALSE(out.timeout);
EXPECT_EVENTS(out,{
.id = "2",
.name = "rule2",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{
.op = "match_regex",
.op_value = "attack value",
.address = "value2",
.value = "attack value",
.highlight = "attack value"}}});
EXPECT_EVENTS(out, {.id = "2",
.name = "rule2",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{.op = "match_regex",
.op_value = "attack value",
.address = "value2",
.value = "attack value",
.highlight = "attack value"}}});

ddwaf_result_free(&out);
ddwaf_context_destroy(context);
Expand All @@ -240,23 +227,20 @@ TEST(TestTransformers, CssDecode)
ddwaf_result out;
ASSERT_EQ(ddwaf_run(context, &map, &out, 2000), DDWAF_MATCH);
EXPECT_FALSE(out.timeout);
EXPECT_EVENTS(out,{
.id = "1",
.name = "rule1",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{
.op = "match_regex",
.op_value = "CSS transformations",
.address = "value1",
.value = "CSS transformations",
.highlight = "CSS transformations"}}});
EXPECT_EVENTS(out, {.id = "1",
.name = "rule1",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{.op = "match_regex",
.op_value = "CSS transformations",
.address = "value1",
.value = "CSS transformations",
.highlight = "CSS transformations"}}});

ddwaf_result_free(&out);
ddwaf_context_destroy(context);
ddwaf_destroy(handle);
}


TEST(TestTransformers, CssDecodeAlias)
{
auto rule = readFile("css_decode.yaml", base_dir);
Expand All @@ -276,16 +260,14 @@ TEST(TestTransformers, CssDecodeAlias)
ddwaf_result out;
ASSERT_EQ(ddwaf_run(context, &map, &out, 2000), DDWAF_MATCH);
EXPECT_FALSE(out.timeout);
EXPECT_EVENTS(out,{
.id = "2",
.name = "rule2",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{
.op = "match_regex",
.op_value = "CSS transformations",
.address = "value2",
.value = "CSS transformations",
.highlight = "CSS transformations"}}});
EXPECT_EVENTS(out, {.id = "2",
.name = "rule2",
.tags = {{"type", "flow1"}, {"category", "category1"}},
.matches = {{.op = "match_regex",
.op_value = "CSS transformations",
.address = "value2",
.value = "CSS transformations",
.highlight = "CSS transformations"}}});

ddwaf_result_free(&out);
ddwaf_context_destroy(context);
Expand Down

0 comments on commit 0067103

Please sign in to comment.