Skip to content

Commit

Permalink
[cpp] Fix container logs stdout scrubber (#3070)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeauchesne committed Sep 19, 2024
1 parent 9eff48d commit 17b99b6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions utils/_context/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,12 @@ def collect_logs(self):
keys = [
bytearray(os.environ["DD_API_KEY"], "utf-8"),
]
if "DD_APP_KEY" in os.environ:

if os.environ.get("DD_APP_KEY"):
keys.append(bytearray(os.environ["DD_APP_KEY"], "utf-8"))
if "AWS_ACCESS_KEY_ID" in os.environ:
if os.environ.get("AWS_ACCESS_KEY_ID"):
keys.append(bytearray(os.environ["AWS_ACCESS_KEY_ID"], "utf-8"))
if "AWS_SECRET_ACCESS_KEY" in os.environ:
if os.environ.get("AWS_SECRET_ACCESS_KEY"):
keys.append(bytearray(os.environ["AWS_SECRET_ACCESS_KEY"], "utf-8"))

data = (
Expand All @@ -348,7 +349,7 @@ def collect_logs(self):
filename = f"{self.log_folder_path}/{output_name}.log"

for key in keys:
output = output.replace(key, b"***")
output = output.replace(key, b"<redacted>")

with open(filename, "wb") as f:
f.write(output)
Expand Down

0 comments on commit 17b99b6

Please sign in to comment.