Skip to content

Commit 87ce53b

Browse files
Backport #95325 to 25.3: Mask password in logs and system tables for the redis table function
1 parent 0a922cf commit 87ce53b

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/Parsers/FunctionSecretArgumentsFinder.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ class FunctionSecretArgumentsFinder
138138
{
139139
findURLSecretArguments();
140140
}
141+
else if (function->name() == "redis")
142+
{
143+
findRedisFunctionSecretArguments();
144+
}
141145
}
142146

143147
void findMySQLFunctionSecretArguments()
@@ -188,7 +192,7 @@ class FunctionSecretArgumentsFinder
188192
result.replacement = std::move(uri);
189193
}
190194

191-
void findRedisSecretArguments()
195+
void findRedisTableEngineSecretArguments()
192196
{
193197
/// Redis does not have URL/address argument,
194198
/// only 'host:port' and separate "password" argument.
@@ -522,7 +526,7 @@ class FunctionSecretArgumentsFinder
522526
}
523527
else if (engine_name == "Redis")
524528
{
525-
findRedisSecretArguments();
529+
findRedisTableEngineSecretArguments();
526530
}
527531
}
528532

@@ -612,6 +616,12 @@ class FunctionSecretArgumentsFinder
612616
markSecretArgument(url_arg_idx + 4);
613617
}
614618

619+
void findRedisFunctionSecretArguments()
620+
{
621+
// redis(host:port, key, structure, db_index, password, pool_size)
622+
markSecretArgument(4);
623+
}
624+
615625
void findDatabaseEngineSecretArguments()
616626
{
617627
const String & engine_name = function->name();

tests/integration/test_mask_sensitive_info/test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def test_create_table():
291291
),
292292
f"Kafka() SETTINGS kafka_broker_list = '127.0.0.1', kafka_topic_list = 'topic', kafka_group_name = 'group', kafka_format = 'JSONEachRow', format_avro_schema_registry_url = 'http://schema_user:{password}@'",
293293
f"Kafka() SETTINGS kafka_broker_list = '127.0.0.1', kafka_topic_list = 'topic', kafka_group_name = 'group', kafka_format = 'JSONEachRow', format_avro_schema_registry_url = 'http://schema_user:{password}@domain.com'",
294-
294+
f"Redis('localhost', 0, '{password}') PRIMARY KEY x;",
295295
]
296296

297297
def make_test_case(i):
@@ -370,6 +370,7 @@ def make_test_case(i):
370370
f"CREATE TABLE table32 (`x` int) ENGINE = AzureBlobStorage('{masked_sas_conn_string}', 'exampledatasets', 'example.csv')",
371371
"CREATE TABLE table33 (`x` int) ENGINE = Kafka SETTINGS kafka_broker_list = '127.0.0.1', kafka_topic_list = 'topic', kafka_group_name = 'group', kafka_format = 'JSONEachRow', format_avro_schema_registry_url = 'http://schema_user:[HIDDEN]@'",
372372
"CREATE TABLE table34 (`x` int) ENGINE = Kafka SETTINGS kafka_broker_list = '127.0.0.1', kafka_topic_list = 'topic', kafka_group_name = 'group', kafka_format = 'JSONEachRow', format_avro_schema_registry_url = 'http://schema_user:[HIDDEN]@domain.com'",
373+
"CREATE TABLE table35 (`x` int) ENGINE = Redis('localhost', 0, '[HIDDEN]') PRIMARY KEY x",
373374
],
374375
must_not_contain=[password],
375376
)
@@ -487,6 +488,7 @@ def test_table_functions():
487488
f"gcs('http://minio1:9001/root/data/test11.csv.gz', 'minio', '{password}')",
488489
f"icebergS3('http://minio1:9001/root/data/test11.csv.gz', 'minio', '{password}')",
489490
f"icebergAzure('{azure_storage_account_url}', 'cont', 'test_simple_6.csv', '{azure_account_name}', '{azure_account_key}', 'CSV', 'none', 'auto')",
491+
f"redis('localhost', 'key', 'key Int64', 0, '{password}')",
490492
]
491493

492494
def make_test_case(i):
@@ -570,6 +572,7 @@ def make_test_case(i):
570572
"CREATE TABLE tablefunc40 (`x` int) AS gcs('http://minio1:9001/root/data/test11.csv.gz', 'minio', '[HIDDEN]')",
571573
"CREATE TABLE tablefunc41 (`x` int) AS icebergS3('http://minio1:9001/root/data/test11.csv.gz', 'minio', '[HIDDEN]')",
572574
f"CREATE TABLE tablefunc42 (`x` int) AS icebergAzure('{azure_storage_account_url}', 'cont', 'test_simple_6.csv', '{azure_account_name}', '[HIDDEN]', 'CSV', 'none', 'auto')",
575+
"CREATE TABLE tablefunc43 (`x` int) AS redis('localhost', 'key', 'key Int64', 0, '[HIDDEN]')",
573576
],
574577
must_not_contain=[password],
575578
)

0 commit comments

Comments
 (0)