-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use consistent secret scrubbing (#10006)
* replace secret placeholder with mask for consistency * add test * changelog * move SECRET_PLACEHOLDER to avoid circular deps * cleanup test
- Loading branch information
Showing
6 changed files
with
55 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Use consistent secret scrubbing with the log function. | ||
time: 2024-04-22T14:58:11.990326-05:00 | ||
custom: | ||
Author: emmyoop | ||
Issue: "9987" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
import pytest | ||
|
||
from dbt.tests.util import run_dbt_and_capture | ||
from dbt_common.constants import SECRET_ENV_PREFIX | ||
|
||
|
||
class TestSecretInPackage: | ||
@pytest.fixture(scope="class", autouse=True) | ||
def setUp(self): | ||
os.environ[SECRET_ENV_PREFIX + "_FOR_LOGGING"] = "super secret" | ||
yield | ||
del os.environ[SECRET_ENV_PREFIX + "_FOR_LOGGING"] | ||
|
||
@pytest.fixture(scope="class") | ||
def packages(self): | ||
return { | ||
"packages": [ | ||
{ | ||
"package": "dbt-labs/dbt_utils{{ log(env_var('DBT_ENV_SECRET_FOR_LOGGING'), info = true) }}", | ||
"version": "1.0.0", | ||
} | ||
] | ||
} | ||
|
||
def test_mask_secrets(self, project): | ||
_, log_output = run_dbt_and_capture(["deps"]) | ||
# this will not be written to logs | ||
assert not ("super secret" in log_output) | ||
assert "*****" in log_output | ||
assert not ("DBT_ENV_SECRET_FOR_LOGGING" in log_output) |