Skip to content

Commit

Permalink
Add rewrite with quote cases (#34269)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingZC authored Jan 6, 2025
1 parent 3ece679 commit faae23d
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@
<input sql="DELETE t FROM encrypt.dbo.t_user as t WHERE t.user_id = 4 and t.user_name = 'test_user' and t.user_name like 'test_%' and t.password = 'admin123' and t.email = '[email protected]'" />
<output sql="DELETE t FROM dbo.t_user as t WHERE t.user_id = 4 and t.user_name_cipher = 'o07WOpLlazifLKU747nd8w==' and t.user_name_like like 'udtu_%' and t.password_cipher = 'beO6rTHBW9jmVeSPPb62QA==' and t.email_cipher = 'zclI1Wk2uaVYHyNckTRYzA=='" />
</rewrite-assertion>

<rewrite-assertion id="delete_with_quote" db-types="MySQL">
<input sql="DELETE FROM `t_account` WHERE `account_id` = ? AND `password` = ? AND `password` like ? AND `amount` = ? AND `status` = ?" parameters="1, aaa, aaa, 1000, OK" />
<output sql="DELETE FROM `t_account` WHERE `account_id` = ? AND `assisted_query_password` = ? AND `like_query_password` like ? AND `cipher_amount` = ? AND `status` = ?" parameters="1, assisted_query_aaa, like_query_aaa, encrypt_1000, OK" />
</rewrite-assertion>
</rewrite-assertions>
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,14 @@
<input sql="INSERT INTO t_account(account_id, certificate_number, password, amount, status) VALUES (?, ?, ?, ?, ?), (2, '222X', NULL, 2000, 'OK'), (?, ?, ?, ?, ?), (4, '444X', 'ddd', NULL, 'OK')" parameters="1, NULL, aaa, 1000, OK, 3, 333X, NULL, 3000, OK" />
<output sql="INSERT INTO t_account(account_id, cipher_certificate_number, assisted_query_certificate_number, like_query_certificate_number, cipher_password, assisted_query_password, like_query_password, cipher_amount, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?), (2, 'encrypt_222X', 'assisted_query_222X', 'like_query_222X', NULL, NULL, NULL, 'encrypt_2000', 'OK'), (?, ?, ?, ?, ?, ?, ?, ?, ?), (4, 'encrypt_444X', 'assisted_query_444X', 'like_query_444X', 'encrypt_ddd', 'assisted_query_ddd', 'like_query_ddd', NULL, 'OK')" parameters="1, NULL, NULL, NULL, encrypt_aaa, assisted_query_aaa, like_query_aaa, encrypt_1000, OK, 3, encrypt_333X, assisted_query_333X, like_query_333X, NULL, NULL, NULL, encrypt_3000, OK" />
</rewrite-assertion>

<rewrite-assertion id="insert_values_with_columns_and_quote" db-types="MySQL">
<input sql="INSERT INTO `t_account`(`account_id`, `certificate_number`, `password`, `amount`, `status`) VALUES (?, ?, ?, ?, ?)" parameters="1, cert1, pwd1, 1000, OK1" />
<output sql="INSERT INTO `t_account`(`account_id`, `cipher_certificate_number`, `assisted_query_certificate_number`, `like_query_certificate_number`, `cipher_password`, `assisted_query_password`, `like_query_password`, `cipher_amount`, `status`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)" parameters="1, encrypt_cert1, assisted_query_cert1, like_query_cert1, encrypt_pwd1, assisted_query_pwd1, like_query_pwd1, encrypt_1000, OK1" />
</rewrite-assertion>

<rewrite-assertion id="insert_values_without_columns_and_quote" db-types="MySQL">
<input sql="INSERT INTO `t_account_bak` VALUES (?, ?, ?, ?)" parameters="1, cert1, pwd1, 1000" />
<output sql="INSERT INTO `t_account_bak`(`account_id`, `cipher_certificate_number`, `assisted_query_certificate_number`, `like_query_certificate_number`, `cipher_password`, `assisted_query_password`, `like_query_password`, `cipher_amount`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)" parameters="1, encrypt_cert1, assisted_query_cert1, like_query_cert1, encrypt_pwd1, assisted_query_pwd1, like_query_pwd1, encrypt_1000" />
</rewrite-assertion>
</rewrite-assertions>
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,9 @@
<input sql="INSERT INTO t_account_bak(account_id, certificate_number, password, amount, status) VALUES (1, '111X', 'aaa', 1000, 'OK'), (2, '222X', 'bbb', 2000, 'OK'), (3, '333X', 'ccc', 3000, 'OK'), (4, '444X', 'ddd', 4000, 'OK') ON DUPLICATE KEY UPDATE password = 'ccc_update'" />
<output sql="INSERT INTO t_account_bak(account_id, cipher_certificate_number, assisted_query_certificate_number, like_query_certificate_number, cipher_password, assisted_query_password, like_query_password, cipher_amount, status) VALUES (1, 'encrypt_111X', 'assisted_query_111X', 'like_query_111X', 'encrypt_aaa', 'assisted_query_aaa', 'like_query_aaa', 'encrypt_1000', 'OK'), (2, 'encrypt_222X', 'assisted_query_222X', 'like_query_222X', 'encrypt_bbb', 'assisted_query_bbb', 'like_query_bbb', 'encrypt_2000', 'OK'), (3, 'encrypt_333X', 'assisted_query_333X', 'like_query_333X', 'encrypt_ccc', 'assisted_query_ccc', 'like_query_ccc', 'encrypt_3000', 'OK'), (4, 'encrypt_444X', 'assisted_query_444X', 'like_query_444X', 'encrypt_ddd', 'assisted_query_ddd', 'like_query_ddd', 'encrypt_4000', 'OK') ON DUPLICATE KEY UPDATE cipher_password = 'encrypt_ccc_update', assisted_query_password = 'assisted_query_ccc_update', like_query_password = 'like_query_ccc_update'" />
</rewrite-assertion>

<rewrite-assertion id="insert_values_with_on_duplicate_key_update_with_quote" db-types="MySQL">
<input sql="INSERT INTO `t_account_bak`(`account_id`, `certificate_number`, `password`, `amount`, `status`) VALUES (1, '111X', 'aaa', 1000, 'OK') ON DUPLICATE KEY UPDATE `password` = 'ccc_update'" />
<output sql="INSERT INTO `t_account_bak`(`account_id`, `cipher_certificate_number`, `assisted_query_certificate_number`, `like_query_certificate_number`, `cipher_password`, `assisted_query_password`, `like_query_password`, `cipher_amount`, `status`) VALUES (1, 'encrypt_111X', 'assisted_query_111X', 'like_query_111X', 'encrypt_aaa', 'assisted_query_aaa', 'like_query_aaa', 'encrypt_1000', 'OK') ON DUPLICATE KEY UPDATE `cipher_password` = 'encrypt_ccc_update', `assisted_query_password` = 'assisted_query_ccc_update', `like_query_password` = 'like_query_ccc_update'" />
</rewrite-assertion>
</rewrite-assertions>
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@
<input sql="SELECT account_id, password, amount AS a, status AS s FROM t_account WHERE account_id = 1 AND password = 'aaa' AND password like 'aaa' AND amount = 1000 AND status = 'OK' group by amount desc" />
<output sql="SELECT account_id, cipher_password AS password, cipher_amount AS a, status AS s FROM t_account WHERE account_id = 1 AND assisted_query_password = 'assisted_query_aaa' AND like_query_password like 'like_query_aaa' AND cipher_amount = 'encrypt_1000' AND status = 'OK' group by cipher_amount desc" />
</rewrite-assertion>

<rewrite-assertion id="select_with_groupby_quote" db-types="MySQL">
<input sql="SELECT `account_id`, `password`, `amount` AS `a`, `status` AS `s` FROM `t_account` WHERE `account_id` = 1 AND `password` = 'aaa' AND `password` like 'aaa' AND `amount` = 1000 AND `status` = 'OK' group by `amount` desc" />
<output sql="SELECT `account_id`, `cipher_password` AS `password`, `cipher_amount` AS `a`, `status` AS `s` FROM `t_account` WHERE `account_id` = 1 AND `assisted_query_password` = 'assisted_query_aaa' AND `like_query_password` like 'like_query_aaa' AND `cipher_amount` = 'encrypt_1000' AND `status` = 'OK' group by `cipher_amount` desc" />
</rewrite-assertion>
</rewrite-assertions>
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,9 @@
<input sql="SELECT t_account.amount, t_account_bak.amount FROM t_account LEFT JOIN t_account_bak ON t_account.account_id = t_account_bak.account_id WHERE t_account.password = 1 OR t_account_bak.amount = 2 AND t_account.certificate_number like 3" />
<output sql="SELECT t_account.cipher_amount AS amount, t_account_bak.cipher_amount AS amount FROM t_account LEFT JOIN t_account_bak ON t_account.account_id = t_account_bak.account_id WHERE t_account.assisted_query_password = 'assisted_query_1' OR t_account_bak.cipher_amount = 'encrypt_2' AND t_account.like_query_certificate_number like 'like_query_3'" />
</rewrite-assertion>

<rewrite-assertion id="select_with_join_and_quote" db-types="MySQL">
<input sql="SELECT `t_account`.`amount`, `t_account_bak`.`amount` FROM `t_account` LEFT JOIN `t_account_bak` ON `t_account`.`account_id` = `t_account_bak`.`account_id` WHERE `t_account`.`password` = 1 OR `t_account_bak`.`amount` = 2 AND `t_account`.`certificate_number` like 3" />
<output sql="SELECT `t_account`.`cipher_amount` AS `amount`, `t_account_bak`.`cipher_amount` AS `amount` FROM `t_account` LEFT JOIN `t_account_bak` ON `t_account`.`account_id` = `t_account_bak`.`account_id` WHERE `t_account`.`assisted_query_password` = 'assisted_query_1' OR `t_account_bak`.`cipher_amount` = 'encrypt_2' AND `t_account`.`like_query_certificate_number` like 'like_query_3'" />
</rewrite-assertion>
</rewrite-assertions>
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,9 @@
<input sql="SELECT e.* FROM t_user AS e ORDER BY creation_date;"/>
<output sql="SELECT e.[user_id], e.[user_name_cipher] AS [user_name], e.[password_cipher] AS [password], e.[email_cipher] AS [email], e.[user_telephone_cipher] AS [telephone], e.[creation_date] FROM t_user AS e ORDER BY creation_date;"/>
</rewrite-assertion>

<rewrite-assertion id="select_with_quote" db-types="MySQL">
<input sql="SELECT `account_id`, `password`, `amount` AS `a`, `status` AS `s` FROM `t_account` WHERE `account_id` = ? AND `password` = ? AND `password` like ? AND amount = ? AND status = ?" parameters="1, aaa, aaa, 1000, OK" />
<output sql="SELECT `account_id`, `cipher_password` AS `password`, `cipher_amount` AS `a`, `status` AS `s` FROM `t_account` WHERE `account_id` = ? AND `assisted_query_password` = ? AND `like_query_password` like ? AND cipher_amount = ? AND status = ?" parameters="1, assisted_query_aaa, like_query_aaa, encrypt_1000, OK" />
</rewrite-assertion>
</rewrite-assertions>
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,9 @@
<input sql="UPDATE t_account_bak SET certificate_number = NULL WHERE certificate_number IS NOT NULL AND status = 'OK' AND certificate_number = '111X' AND certificate_number like '111X'" />
<output sql="UPDATE t_account_bak SET cipher_certificate_number = NULL, assisted_query_certificate_number = NULL, like_query_certificate_number = NULL WHERE assisted_query_certificate_number IS NOT NULL AND status = 'OK' AND assisted_query_certificate_number = 'assisted_query_111X' AND like_query_certificate_number like 'like_query_111X'" />
</rewrite-assertion>

<rewrite-assertion id="update_account_bak_for_parameters_and_quote" db-types="MySQL">
<input sql="UPDATE `t_account_bak` SET `account_id` = ?, `certificate_number` = ?, `password` = ?, `amount` = ?, `status` = ? WHERE `account_id` = ? AND `certificate_number` = ? AND `password` = ? AND `amount` = ? AND `status` = ?" parameters="1, cert, pwd, amt, OK, 2, cert1, pwd1, amt1, OK1" />
<output sql="UPDATE `t_account_bak` SET `account_id` = ?, `cipher_certificate_number` = ?, `assisted_query_certificate_number` = ?, `like_query_certificate_number` = ?, `cipher_password` = ?, `assisted_query_password` = ?, `like_query_password` = ?, `cipher_amount` = ?, `status` = ? WHERE `account_id` = ? AND `assisted_query_certificate_number` = ? AND `assisted_query_password` = ? AND `cipher_amount` = ? AND `status` = ?" parameters="1, encrypt_cert, assisted_query_cert, like_query_cert, encrypt_pwd, assisted_query_pwd, like_query_pwd, encrypt_amt, OK, 2, assisted_query_cert1, assisted_query_pwd1, encrypt_amt1, OK1" />
</rewrite-assertion>
</rewrite-assertions>

0 comments on commit faae23d

Please sign in to comment.