-
Notifications
You must be signed in to change notification settings - Fork 0
Fix credential redaction and bidi sanitization gaps #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -67,6 +67,29 @@ def test_redact_scrubs_authorization_header(): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert "abc123xyz" not in out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_redact_scrubs_basic_authorization_header(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Any auth scheme, not just Bearer/Token, must not leak its credential.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| out = redact("Authorization: Basic dXNlcjpwYXNz") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert "dXNlcjpwYXNz" not in out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert "Basic" not in out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_redact_scrubs_arbitrary_auth_scheme(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| out = redact("authorization = \"Digest realm=example, nonce=deadbeef\"") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert "nonce=deadbeef" not in out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert "Digest" not in out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_redact_preserves_text_before_header_and_other_lines(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| out = redact("Error 401: Authorization: Bearer abc123 rejected") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert "abc123" not in out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert "Error 401:" in out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| multiline = redact("GET /users HTTP/1.1\nAuthorization: Bearer abc123\nAccept: */*") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert "abc123" not in multiline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert "GET /users HTTP/1.1" in multiline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert "Accept: */*" in multiline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+77
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win Assert removal of the complete authorization value. The Digest test does not assert that Suggested test additions out = redact("authorization = \"Digest realm=example, nonce=deadbeef\"")
assert "nonce=deadbeef" not in out
+ assert "realm=example" not in out
assert "Digest" not in out
...
out = redact("Error 401: Authorization: Bearer abc123 rejected")
assert "abc123" not in out
+ assert "rejected" not in out📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ───────────────────────────── user fetch ─────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @responses.activate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_fetch_user_ok(user_payload): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: alptekinege/githubfetch
Length of output: 161
🏁 Script executed:
Repository: alptekinege/githubfetch
Length of output: 7643
Keep Authorization header redaction on the same physical line.
The regex allows
\s*before and after:/=, soAuthorization: \nNext: keepcan consumeNext: keepas part of the header value and redact unrelated output. Restrict delimiter spacing to horizontal whitespace, e.g.[ \t]*.🤖 Prompt for AI Agents