Skip to content

Commit d62b4e0

Browse files
Backport #95325 to 25.10: Mask password in logs and system tables for the redis table function
1 parent cef44e7 commit d62b4e0

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/Parsers/FunctionSecretArgumentsFinder.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ class FunctionSecretArgumentsFinder
144144
{
145145
findURLSecretArguments();
146146
}
147+
else if (function->name() == "redis")
148+
{
149+
findRedisFunctionSecretArguments();
150+
}
147151
else if (function->name() == "ytsaurus")
148152
{
149153
findYTsaurusStorageTableEngineSecretArguments();
@@ -202,7 +206,7 @@ class FunctionSecretArgumentsFinder
202206
result.replacement = std::move(uri);
203207
}
204208

205-
void findRedisSecretArguments()
209+
void findRedisTableEngineSecretArguments()
206210
{
207211
/// Redis does not have URL/address argument,
208212
/// only 'host:port' and separate "password" argument.
@@ -552,7 +556,7 @@ class FunctionSecretArgumentsFinder
552556
}
553557
else if (engine_name == "Redis")
554558
{
555-
findRedisSecretArguments();
559+
findRedisTableEngineSecretArguments();
556560
}
557561
else if (engine_name == "YTsaurus")
558562
{
@@ -652,6 +656,12 @@ class FunctionSecretArgumentsFinder
652656
markSecretArgument(url_arg_idx + 4);
653657
}
654658

659+
void findRedisFunctionSecretArguments()
660+
{
661+
// redis(host:port, key, structure, db_index, password, pool_size)
662+
markSecretArgument(4);
663+
}
664+
655665
void findYTsaurusStorageTableEngineSecretArguments()
656666
{
657667
// YTsaurus('base_uri', 'yt_path', 'auth_token')

tests/integration/test_mask_sensitive_info/test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ def test_create_table():
293293
f"S3('http://minio1:9001/root/data/test5.csv.gz', 'CSV', access_key_id = 'minio', secret_access_key = '{password}', compression_method = 'gzip')",
294294
f"ArrowFlight('arrowflight1:5006', 'dataset', 'arrowflight_user', '{password}')",
295295
f"ArrowFlight(named_collection_1, host = 'arrowflight1', port = 5006, dataset = 'dataset', username = 'arrowflight_user', password = '{password}')",
296+
f"Redis('localhost', 0, '{password}') PRIMARY KEY x;",
296297
]
297298

298299
def make_test_case(i):
@@ -374,6 +375,7 @@ def make_test_case(i):
374375
"CREATE TABLE table35 (`x` int) ENGINE = S3('http://minio1:9001/root/data/test5.csv.gz', 'CSV', access_key_id = 'minio', secret_access_key = '[HIDDEN]', compression_method = 'gzip')",
375376
"CREATE TABLE table36 (`x` int) ENGINE = ArrowFlight('arrowflight1:5006', 'dataset', 'arrowflight_user', '[HIDDEN]')",
376377
"CREATE TABLE table37 (`x` int) ENGINE = ArrowFlight(named_collection_1, host = 'arrowflight1', port = 5006, dataset = 'dataset', username = 'arrowflight_user', password = '[HIDDEN]')",
378+
"CREATE TABLE table38 (`x` int) ENGINE = Redis('localhost', 0, '[HIDDEN]') PRIMARY KEY x",
377379
],
378380
must_not_contain=[password],
379381
)
@@ -501,6 +503,7 @@ def test_table_functions():
501503
f"arrowFlight('arrowflight1:5006', 'dataset', 'arrowflight_user', '{password}')",
502504
f"arrowFlight(named_collection_1, host = 'arrowflight1', port = 5006, dataset = 'dataset', username = 'arrowflight_user', password = '{password}')",
503505
f"arrowflight(named_collection_1, host = 'arrowflight1', port = 5006, dataset = 'dataset', username = 'arrowflight_user', password = '{password}')",
506+
f"redis('localhost', 'key', 'key Int64', 0, '{password}')"
504507
]
505508

506509
def make_test_case(i):
@@ -592,6 +595,7 @@ def make_test_case(i):
592595
"CREATE TABLE tablefunc45 (`x` int) AS arrowFlight('arrowflight1:5006', 'dataset', 'arrowflight_user', '[HIDDEN]')",
593596
"CREATE TABLE tablefunc46 (`x` int) AS arrowFlight(named_collection_1, host = 'arrowflight1', port = 5006, dataset = 'dataset', username = 'arrowflight_user', password = '[HIDDEN]')",
594597
"CREATE TABLE tablefunc47 (`x` int) AS arrowflight(named_collection_1, host = 'arrowflight1', port = 5006, dataset = 'dataset', username = 'arrowflight_user', password = '[HIDDEN]')",
598+
"CREATE TABLE tablefunc48 (`x` int) AS redis('localhost', 'key', 'key Int64', 0, '[HIDDEN]')",
595599
],
596600
must_not_contain=[password],
597601
)

0 commit comments

Comments
 (0)