feat: smartlink redirects directly to CRE when only one CRE is linked#938
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Summary by CodeRabbit
Walkthrough
Changessmartlink Direct CRE Redirect
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
application/tests/web_main_test.py (1)
588-600:⚠️ Potential issue | 🟠 Major | ⚡ Quick winSwap the expected CRE IDs for CWE vs ASVS redirects.
The assertions are inverted relative to fixture setup: CWE is linked through
dcd(222-222) and ASVS throughdcb(333-333).Suggested fix
- self.assertEqual(location, "/cre/333-333") + self.assertEqual(location, "/cre/222-222") @@ - self.assertEqual(location, "/cre/222-222") + self.assertEqual(location, "/cre/333-333")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@application/tests/web_main_test.py` around lines 588 - 600, The expected CRE IDs in the redirect assertions are inverted based on the fixture setup. In the test method, swap the expected location values for the CWE and ASVS endpoint assertions: the CWE redirect (to /smartlink/standard/CWE/v0.1.2) should expect location /cre/222-222, and the ASVS redirect (to /smartlink/standard/ASVS/v0.1.2) should expect location /cre/333-333. Change the first self.assertEqual(location, "/cre/333-333") to expect /cre/222-222 and the second self.assertEqual(location, "/cre/222-222") to expect /cre/333-333.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@application/tests/web_main_test.py`:
- Around line 588-600: The expected CRE IDs in the redirect assertions are
inverted based on the fixture setup. In the test method, swap the expected
location values for the CWE and ASVS endpoint assertions: the CWE redirect (to
/smartlink/standard/CWE/v0.1.2) should expect location /cre/222-222, and the
ASVS redirect (to /smartlink/standard/ASVS/v0.1.2) should expect location
/cre/333-333. Change the first self.assertEqual(location, "/cre/333-333") to
expect /cre/222-222 and the second self.assertEqual(location, "/cre/222-222") to
expect /cre/333-333.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 3e704195-f081-455a-bede-56adb71ae701
📒 Files selected for processing (2)
application/tests/web_main_test.pyapplication/web/web_main.py
When a smartlink resolves to a standard section that has exactly one linked CRE, redirect the user directly to that CRE page instead of the intermediate standard-section node page. The CRE page already contains all the information the landing page would show. If multiple CREs are linked, behaviour is unchanged. Supersedes OWASP#906
91874dc to
1f5f29f
Compare
|
Verified locally by running python -m pytest application/tests/web_main_test.py::TestMain::test_smartlink -v. The current values (/cre/222-222 for CWE and /cre/333-333 for ASVS) are correct — swapping them back causes the test to fail with AssertionError: '/cre/222-222' != '/cre/333-333'. The static analysis here is incorrect; the actual runtime behavior confirms the current assertions are right. |
northdpole
left a comment
There was a problem hiding this comment.
LGTM — approving for merge.
Rebased onto current main. Single-CRE smartlink → /cre/{id}; multi-CRE and MITRE fallback unchanged. Closes #486.
When a smartlink resolves to a standard section that has exactly one linked CRE, redirect the user directly to that CRE page instead of the intermediate standard-section node page. The CRE page already contains all the information the landing page would show.
If multiple CREs are linked, behaviour is unchanged.
Closes #486
Supercedes #906
Addressed the review comments in #906