From 0067103b53f3a115703618976843e97af8621f93 Mon Sep 17 00:00:00 2001 From: Anil Mahtani <929854+Anilm3@users.noreply.github.com> Date: Thu, 27 Jul 2023 14:26:21 +0100 Subject: [PATCH] Fix format --- tests/integration/transformers/test.cpp | 142 +++++++++++------------- 1 file changed, 62 insertions(+), 80 deletions(-) diff --git a/tests/integration/transformers/test.cpp b/tests/integration/transformers/test.cpp index b9ec0790f..75b1a5e68 100644 --- a/tests/integration/transformers/test.cpp +++ b/tests/integration/transformers/test.cpp @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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);