Skip to content
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2025-05-23 - URL Credential Leakage in Logs
**Vulnerability:** `sanitize_for_log` only redacted the API token but allowed URLs containing Basic Auth credentials (e.g. `https://user:pass@host`) to be logged in plain text.
**Learning:** Sanitization functions often focus on known secrets (like specific tokens) but miss pattern-based leaks like standard URI credentials.
**Prevention:** Always scrub user:password combinations from any URL before logging. Use regex or URL parsing libraries to identifying and redact the authority section.
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the documentation: "identifying" should be "identify" to maintain parallel structure with "Use regex or URL parsing libraries to identify..."

Suggested change
**Prevention:** Always scrub user:password combinations from any URL before logging. Use regex or URL parsing libraries to identifying and redact the authority section.
**Prevention:** Always scrub user:password combinations from any URL before logging. Use regex or URL parsing libraries to identify and redact the authority section.

Copilot uses AI. Check for mistakes.
5 changes: 5 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@
s = str(text)
if TOKEN and TOKEN in s:
s = s.replace(TOKEN, "[REDACTED]")

# Redact credentials in URLs (e.g. https://user:pass@host)
# Pattern: scheme://user:pass@host -> scheme://[REDACTED]@host
s = re.sub(r"(https?://)[^/\s@]+@([^/\s]+)", r"\1[REDACTED]@\2", s)

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Variable name "s" doesn't conform to snake_case naming style Warning

Variable name "s" doesn't conform to snake_case naming style

Check warning

Code scanning / Pylint (reported by Codacy)

Variable name "s" doesn't conform to snake_case naming style Warning

Variable name "s" doesn't conform to snake_case naming style
Comment on lines +155 to +157

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While the current regular expression effectively redacts credentials in many common URL formats, using urllib.parse (which is already imported) and urlunparse would provide a more robust and maintainable solution for handling URL components. urllib.parse is specifically designed for URL parsing and can better handle edge cases, such as complex netloc structures or future changes in URL standards, without the potential fragility of regex-based parsing. This approach would enhance the reliability of credential redaction.

Comment on lines +155 to +157
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new URL credential redaction functionality lacks test coverage. Consider adding a test to verify that URLs containing credentials (e.g., 'https://user:pass@host.com') are properly redacted to 'https://[REDACTED]@host.com' while URLs without credentials remain unchanged. This would follow the pattern established in tests/test_log_sanitization.py and tests/test_security.py.

Copilot uses AI. Check for mistakes.

# repr() safely escapes control characters (e.g., \n -> \\n, \x1b -> \\x1b)
# This prevents log injection and terminal hijacking.
safe = repr(s)
Expand Down
Loading