Skip to content

Commit

Permalink
[fix](function) Hide secret key for aes_decrypt/encrypt in result hea…
Browse files Browse the repository at this point in the history
…der (#39969)

Fix the case: The secret key is being shown beside '***' in result header

```
MySQL [lambxu]> set experimental_enable_nereids_planner = false;
Query OK, 0 rows affected (0.01 sec)

MySQL [lambxu]> SELECT aes_decrypt(   from_base64("EXp7k7M9Zv1mIwPpno28Hg=="),   '17IMZrGdwWf2Piy8',   'II2HLtihr5TQpQgR'  , 'AES_128_CBC');
+------------------------------------------------------------------------------------------------------------------+
| aes_decrypt(from_base64('EXp7k7M9Zv1mIwPpno28Hg=='), '***''17IMZrGdwWf2Piy8', 'II2HLtihr5TQpQgR', 'AES_128_CBC') |
+------------------------------------------------------------------------------------------------------------------+
| 17777208882                                                                                                      |
+------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```
  • Loading branch information
xy720 authored Sep 23, 2024
1 parent ddc5592 commit ab7e77f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ private String paramsToSql() {
|| fnName.getFunction().equalsIgnoreCase("sm4_decrypt")
|| fnName.getFunction().equalsIgnoreCase("sm4_encrypt"))) {
sb.append("\'***\'");
continue;
} else if (orderByElements.size() > 0 && i == len - orderByElements.size()) {
sb.append("ORDER BY ");
}
Expand Down
6 changes: 6 additions & 0 deletions regression-test/data/view_p0/view_p0.out
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@
-- !sql2 --


-- !select_aes --
17777208882

-- !show_aes --
test_view_aes CREATE VIEW `test_view_aes` AS SELECT aes_decrypt(from_base64("EXp7k7M9Zv1mIwPpno28Hg=="), '17IMZrGdwWf2Piy8', 'II2HLtihr5TQpQgR', 'AES_128_CBC'); utf8mb4 utf8mb4_0900_bin

11 changes: 10 additions & 1 deletion regression-test/suites/view_p0/view_p0.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,16 @@ suite("view_p0") {

sql """CREATE VIEW IF NOT EXISTS `test_view_abc`(`a`) AS WITH T1 AS (SELECT 1 AS 'a'), T2 AS (SELECT 2 AS 'a') SELECT T1.a FROM T1 UNION ALL SELECT T2.a FROM T2;"""

sql "drop view if exists test_view_abc;"
sql "drop view if exists test_view_abc;"

sql "drop view if exists test_view_aes;"
sql """CREATE VIEW IF NOT EXISTS `test_view_aes`
AS
SELECT aes_decrypt(from_base64("EXp7k7M9Zv1mIwPpno28Hg=="), '17IMZrGdwWf2Piy8', 'II2HLtihr5TQpQgR', 'AES_128_CBC');
"""
qt_select_aes "SELECT * FROM test_view_aes;"
qt_show_aes "SHOW CREATE VIEW test_view_aes;"
sql "drop view if exists test_view_aes;"

sql """DROP TABLE IF EXISTS test_view_table2"""

Expand Down

0 comments on commit ab7e77f

Please sign in to comment.