Skip to content

Commit b622876

Browse files
pr feedback
1 parent 919a753 commit b622876

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

sqlmesh/core/config/connection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,12 +509,12 @@ def get_catalog(self) -> t.Optional[str]:
509509
return None
510510

511511
def _mask_sensitive_data(self, string: str) -> str:
512-
# Mask MotherDuck tokens
512+
# Mask MotherDuck tokens with fixed number of asterisks
513513
result = MOTHERDUCK_TOKEN_REGEX.sub(
514-
lambda m: f"{m.group(1)}{m.group(2)}{'*' * len(m.group(3))}", string
514+
lambda m: f"{m.group(1)}{m.group(2)}{'*' * 8 if m.group(3) else ''}", string
515515
)
516-
# Mask PostgreSQL and MySQL passwords
517-
result = PASSWORD_REGEX.sub(lambda m: f"{m.group(1)}{'*' * len(m.group(2))}", result)
516+
# Mask PostgreSQL/MySQL passwords with fixed number of asterisks
517+
result = PASSWORD_REGEX.sub(lambda m: f"{m.group(1)}{'*' * 8}", result)
518518
return result
519519

520520

tests/core/test_connection_config.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -949,33 +949,33 @@ def test_motherduck_token_mask(make_config):
949949
assert config_1._mask_sensitive_data(config_1.database) == "whodunnit"
950950
assert (
951951
config_1._mask_sensitive_data(f"md:{config_1.database}?motherduck_token={config_1.token}")
952-
== "md:whodunnit?motherduck_token=*****"
952+
== "md:whodunnit?motherduck_token=********"
953953
)
954954
assert (
955955
config_1._mask_sensitive_data(
956956
f"md:{config_1.database}?attach_mode=single&motherduck_token={config_1.token}"
957957
)
958-
== "md:whodunnit?attach_mode=single&motherduck_token=*****"
958+
== "md:whodunnit?attach_mode=single&motherduck_token=********"
959959
)
960960
assert (
961961
config_2._mask_sensitive_data(f"md:{config_2.database}?motherduck_token={config_2.token}")
962-
== "md:whodunnit?motherduck_token=******************"
962+
== "md:whodunnit?motherduck_token=********"
963963
)
964964
assert (
965965
config_3._mask_sensitive_data(f"md:?motherduck_token={config_3.token}")
966-
== "md:?motherduck_token=**********"
966+
== "md:?motherduck_token=********"
967967
)
968968
assert (
969969
config_1._mask_sensitive_data("?motherduck_token=secret1235")
970-
== "?motherduck_token=**********"
970+
== "?motherduck_token=********"
971971
)
972972
assert (
973973
config_1._mask_sensitive_data("md:whodunnit?motherduck_token=short")
974-
== "md:whodunnit?motherduck_token=*****"
974+
== "md:whodunnit?motherduck_token=********"
975975
)
976976
assert (
977977
config_1._mask_sensitive_data("md:whodunnit?motherduck_token=longtoken123456789")
978-
== "md:whodunnit?motherduck_token=******************"
978+
== "md:whodunnit?motherduck_token=********"
979979
)
980980
assert (
981981
config_1._mask_sensitive_data("md:whodunnit?motherduck_token=")
@@ -988,25 +988,25 @@ def test_motherduck_token_mask(make_config):
988988
config_1._mask_sensitive_data(
989989
"postgres:dbname=mydb user=myuser password=secret123 host=localhost"
990990
)
991-
== "postgres:dbname=mydb user=myuser password=********* host=localhost"
991+
== "postgres:dbname=mydb user=myuser password=******** host=localhost"
992992
)
993993

994994
assert (
995995
config_1._mask_sensitive_data(
996996
"dbname=postgres user=postgres password=pg_secret host=127.0.0.1"
997997
)
998-
== "dbname=postgres user=postgres password=********* host=127.0.0.1"
998+
== "dbname=postgres user=postgres password=******** host=127.0.0.1"
999999
)
10001000
assert (
10011001
config_1._mask_sensitive_data(
10021002
"postgres:dbname=testdb password=verylongpassword123 user=admin"
10031003
)
1004-
== "postgres:dbname=testdb password=******************* user=admin"
1004+
== "postgres:dbname=testdb password=******** user=admin"
10051005
)
1006-
assert config_1._mask_sensitive_data("postgres:password=short") == "postgres:password=*****"
1006+
assert config_1._mask_sensitive_data("postgres:password=short") == "postgres:password=********"
10071007
assert (
10081008
config_1._mask_sensitive_data("postgres:host=localhost password=p@ssw0rd! dbname=db")
1009-
== "postgres:host=localhost password=********* dbname=db"
1009+
== "postgres:host=localhost password=******** dbname=db"
10101010
)
10111011

10121012
assert (
@@ -1016,7 +1016,7 @@ def test_motherduck_token_mask(make_config):
10161016

10171017
assert (
10181018
config_1._mask_sensitive_data("md:db?motherduck_token=token123 postgres:password=secret")
1019-
== "md:db?motherduck_token=******** postgres:password=******"
1019+
== "md:db?motherduck_token=******** postgres:password=********"
10201020
)
10211021

10221022
# MySQL format

0 commit comments

Comments
 (0)