Skip to content

Commit

Permalink
replace secret placeholder with mask for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
emmyoop committed Apr 22, 2024
1 parent 528b95c commit e8bc017
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/dbt/context/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,20 @@ def log(msg: str, info: bool = False) -> str:
{{ log("Running some_macro: " ~ arg1 ~ ", " ~ arg2) }}
{% endmacro %}"
"""
# Now, detect instances of the placeholder value ($$$DBT_SECRET_START...DBT_SECRET_END$$$)
# and replace them with the standard mask '*****'
if "DBT_SECRET_START" in str(msg):
search_group = f"({SECRET_ENV_PREFIX}(.*))"
from dbt.context.secret import SECRET_PLACEHOLDER

pattern = SECRET_PLACEHOLDER.format(search_group).replace("$", r"\$")
m = re.search(
pattern,
msg,
)
if m:
msg = re.sub(pattern, "*****", msg)

if info:
fire_event(JinjaLogInfo(msg=msg, node_info=get_node_info()))
else:
Expand Down

0 comments on commit e8bc017

Please sign in to comment.