From cad29a43aaa4b32c617b6ee75218a41ff0d7cab5 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Fri, 15 Dec 2023 16:37:21 -0800 Subject: [PATCH] Add SQL test cases for prepended comments --- .../sql_obfuscation/sql_obfuscation.json | 30 +++++++++++++++++++ .../cross_agent_tests/sql_parsing.json | 3 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/test/fixtures/cross_agent_tests/sql_obfuscation/sql_obfuscation.json b/test/fixtures/cross_agent_tests/sql_obfuscation/sql_obfuscation.json index 1d32e1c1fef..f8d644cfb23 100644 --- a/test/fixtures/cross_agent_tests/sql_obfuscation/sql_obfuscation.json +++ b/test/fixtures/cross_agent_tests/sql_obfuscation/sql_obfuscation.json @@ -674,5 +674,35 @@ "cassandra", "mssql" ] + }, + { + "name": "prepended_comments_with_quotes.postgres", + "sql": "/*application:Demo,controller:posts,action:update*/ UPDATE \"posts\" SET \"updated_at\" = '2023-11-01 19:02:34.795909' WHERE \"posts\".\"id\" = 3", + "obfuscated": [ + "? UPDATE \"posts\" SET \"updated_at\" = ? WHERE \"posts\".\"id\" = ?" + ], + "dialects": [ + "postgres" + ] + }, + { + "name": "prepended_comments_with_quotes.mysql", + "sql": "/*action='show',application='TrilogyTest',controller='users'*/ SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1", + "obfuscated": [ + "? SELECT `users`.* FROM `users` WHERE `users`.`id` = ? LIMIT ?" + ], + "dialects": [ + "mysql" + ] + }, + { + "name": "prepended_multiline_comments_with_quotes.mysql", + "sql": "/*action='show',\napplication='TrilogyTest',controller='users'*/\nSELECT `users`.*\nFROM `users`\nWHERE `users`.`id` = 1 LIMIT 1", + "obfuscated": [ + "?\nSELECT `users`.*\nFROM `users`\nWHERE `users`.`id` = ? LIMIT ?" + ], + "dialects": [ + "mysql" + ] } ] diff --git a/test/fixtures/cross_agent_tests/sql_parsing.json b/test/fixtures/cross_agent_tests/sql_parsing.json index 5590f2f93c2..90311b13a72 100644 --- a/test/fixtures/cross_agent_tests/sql_parsing.json +++ b/test/fixtures/cross_agent_tests/sql_parsing.json @@ -57,7 +57,8 @@ {"input":"SELECT * /* a */ FROM alpha", "operation":"select", "table":"alpha"}, {"input":"SELECT * FROM /* a */ alpha", "operation":"select", "table":"alpha"}, {"input":"/* X */ SELECT /* Y */ foo/**/ FROM /**/alpha/**/", "operation":"select", "table":"alpha"}, - + {"input":"/* insert */ SELECT * FROM alpha", "operation":"select", "table":"alpha"}, + {"input":"mystoredprocedure'123'", "operation":"other", "table":null}, {"input":"mystoredprocedure\t'123'", "operation":"other", "table":null}, {"input":"mystoredprocedure\r'123'", "operation":"other", "table":null},