Remove invalid single-backslash redirect test - #7774
Conversation
Greptile SummaryThis PR removes
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| tests/test_authentication.py | Removes test_backslash_redirect_rejected, which incorrectly expected \evil.com to be rejected; the remaining test_slash_backslash_redirect_rejected covers the genuinely dangerous /\evil.com case. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["next= URL from login request"] --> B["_is_safe_next_url(url)"]
B --> C["Check both url and url.replace('\\\\', '/')"]
C --> D{Starts with '///\n or has scheme without netloc?}
D -- Yes --> E["Return False → fallback to ./"]
D -- No --> F{Has netloc?}
F -- Yes --> E
F -- No --> G{Scheme not http/https?}
G -- Yes --> E
G -- No --> H["Return True → allow redirect"]
subgraph "Test coverage"
T1["test_slash_backslash_redirect_rejected\n/\\evil.com → ./\n(REMAINS)"]
T2["test_backslash_redirect_rejected\n\\evil.com → ./\n(REMOVED — was incorrect)"]
end
style T2 fill:#ffcccc,stroke:#cc0000
style T1 fill:#ccffcc,stroke:#009900
Reviews (3): Last reviewed commit: "Merge branch 'master' into codex/fix-bac..." | Re-trigger Greptile
There was a problem hiding this comment.
I can approve it as It just looks good.
I just have some questions.
-
Is the test failed before the PR ?
(Normally, the commit causing test failure is not merged. I guess the commit causing the test failure is directly committed to the master branch. Is it right ?) -
Why is the commit (2723d87) reverted, as the commit looks more conservative.
( I guess the commit caused another test failure ??)
|
Actually, I see that the this issue causes CI error on the latest commit like this. https://github.com/getredash/redash/actions/runs/31325105873/job/93274155470?pr=7750#step:7:123 |
Summary
Remove the login-redirect test that treats a single leading backslash as an external redirect.
Rationale
A single
\evil.comresolves to the same-origin path/evil.comfor special-scheme URLs. The existing mixed slash/backslash case (/\evil.com) remains covered because it resolves to an external host and must be rejected.Validation
python3 -m py_compile redash/authentication/__init__.pygit diff --check