-
Notifications
You must be signed in to change notification settings - Fork 1.9k
INT-1414 - Implement credential obfuscation in SQL statements for Snowflake STAGE objects #7214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Check notice
Code scanning / CodeQL
Unread local variable Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, simply remove the declaration and assignment of the unused local variable output in the method testNullStatementHandling (line 119). Since the variable is not read or used in any way, and there are no side effects in the assignment (calling outputWriter.toString() is safe to remove), this change will not affect the functionality of the test. No other changes, imports, or definitions are required.
| @@ -116,7 +116,6 @@ | ||
| // Test that null statements don't cause exceptions | ||
| loggingExecutor.execute(new RawSqlStatement(null)); | ||
|
|
||
| String output = outputWriter.toString(); | ||
| // Should not throw exception and output should be handled gracefully | ||
| } | ||
|
|
liquibase-standard/src/main/java/liquibase/executor/LoggingExecutor.java
Outdated
Show resolved
Hide resolved
Implement credential obfuscation for AWS_KEY_ID, AWS_SECRET_KEY, AWS_TOKEN, and AZURE_SAS_TOKEN in LoggingExecutor to prevent sensitive data exposure in SQL logs. Changes: - Add unified regex pattern for all credential types with ReDoS protection - Implement context-aware obfuscation within CREDENTIALS blocks only - Preserve credentials in SQL comments for documentation purposes - Add comprehensive test coverage in LoggingExecutorCredentialsTest - Maintain backward compatibility with existing LoggingExecutorTest The implementation uses possessive quantifiers to prevent ReDoS attacks, word boundaries for precise matching, and backreferences to ensure proper quote handling.
… enhance comments
… SQL Enhancements: - Add support for obfuscating ENCRYPTION blocks alongside CREDENTIALS in LoggingExecutor. - Update regex pattern for context-aware obfuscation of both block types. - Ensure sensitive values like MASTER_KEY are masked in SQL statements. - Add unit tests in LoggingExecutorCredentialsTest to verify new functionality.
5191de3 to
b4dff38
Compare
Impact
Description
This pull request introduces a robust mechanism for obfuscating sensitive credentials in Snowflake STAGE SQL statements within the
LoggingExecutor. The main goal is to prevent accidental logging of secrets such as AWS keys, tokens, and master keys by replacing their values with asterisks in any output. In addition, a comprehensive suite of unit tests has been added to verify the correctness and security of the obfuscation logic across a wide range of scenarios.Credential Obfuscation Improvements:
LoggingExecutor:AWS_KEY_ID,AWS_SECRET_KEY,AWS_TOKEN,AZURE_SAS_TOKEN,MASTER_KEY) only withinCREDENTIALSorENCRYPTIONblocks, ensuring context-aware obfuscation. [1] [2]obfuscateCredentialsandobfuscateCredentialsInBlockmethods to scan SQL statements, find relevant blocks, and replace credential values with asterisks, preserving original formatting and quotes.Testing and Validation:
LoggingExecutorCredentialsTestwith extensive test coverage for:CREDENTIALSandENCRYPTIONblocks.