Skip to content

Commit 2f17b67

Browse files
authored
SNOW-1247646: Mask truncated password less than 8 characters (#1906)
1 parent 4edec25 commit 2f17b67

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

DESCRIPTION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
2626
- Updated `write_pandas` to skip TABLE IF NOT EXISTS in truncate mode.
2727
- Improved cleanup logic for connection to rely on interpreter shutdown instead of the `__del__` method.
2828
- Updated the logging level from INFO to DEBUG when logging the executed query using `SnowflakeCursor.execute`.
29+
- Fixed a bug that the truncated password in log is not masked.
2930

3031
- v3.7.1(February 21, 2024)
3132

src/snowflake/connector/secret_detector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class SecretDetector(logging.Formatter):
4848
r"(password"
4949
r"|pwd)"
5050
r"([\'\"\s:=]+)"
51-
r"([a-z0-9!\"#\$%&\\\'\(\)\*\+\,-\./:;<=>\?\@\[\]\^_`\{\|\}~]{8,})",
51+
r"([a-z0-9!\"#\$%&\\\'\(\)\*\+\,-\./:;<=>\?\@\[\]\^_`\{\|\}~]{1,})",
5252
flags=re.IGNORECASE,
5353
)
5454

test/unit/test_log_secret_detector.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ def test_password():
171171
assert err_str is None
172172
assert masked_str == "pwd:****"
173173

174+
random_password_truncated = "password=Afs..."
175+
masked, masked_str, err_str = SecretDetector.mask_secrets(random_password_truncated)
176+
assert masked
177+
assert err_str is None
178+
assert masked_str == "password=****"
179+
174180

175181
def test_token_password():
176182
long_token = (

0 commit comments

Comments
 (0)