Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion agent/src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import contextlib as _ctx_for_debug
import logging
import os
import re
import threading
import time as _time_for_debug
import traceback
Expand All @@ -31,12 +32,27 @@


def _redact_cached_credentials(text: str) -> str:
"""Remove cached env secrets from debug text before stdout / CloudWatch."""
"""Remove sensitive material from debug text before stdout / CloudWatch."""
out = text

# 1) Redact exact cached secret values when present.
for env_key in ("GITHUB_TOKEN", "LINEAR_API_TOKEN"):
secret = os.environ.get(env_key) or ""
if len(secret) >= 12:
out = out.replace(secret, f"<{env_key}_REDACTED>")

# 2) Redact common secret-bearing key/value patterns.
secret_patterns = (
r"(?i)\b(github_token|linear_api_token|token|secret|api[_-]?key|password)\b\s*[:=]\s*([^\s,;]+)",
r"(?i)\b(authorization)\b\s*[:=]\s*(bearer\s+)?([^\s,;]+)",
)
for pattern in secret_patterns:
out = re.sub(
pattern,
lambda m: f"{m.group(1)}=<REDACTED>",
out,
)

return out


Expand Down
Loading