fix: redirect smartlink directly to CRE when only one is linked#797
Open
ghostiee-11 wants to merge 1 commit intoOWASP:mainfrom
Open
fix: redirect smartlink directly to CRE when only one is linked#797ghostiee-11 wants to merge 1 commit intoOWASP:mainfrom
ghostiee-11 wants to merge 1 commit intoOWASP:mainfrom
Conversation
Fixes OWASP#486 When a smartlinked standard resolves to exactly one CRE, skip the intermediate standard page and redirect directly to the CRE page. Standards with multiple CRE links retain the existing behavior.
There was a problem hiding this comment.
Pull request overview
This PR implements a UX improvement for the smartlink feature: when a standard resolves to exactly one linked CRE, the user is redirected directly to the CRE page (/cre/{id}) instead of the intermediate standard node page. When multiple CREs are linked, the existing behavior is preserved.
Changes:
- Modified
smartlink()inweb_main.pyto detect single-CRE cases and redirect directly to/cre/{id} - Updated existing test assertions for single-CRE cases (CWE/456 and ASVS/v0.1.2) to expect the new redirect target
- Added a new test case to verify that standards with multiple CRE links still redirect to the standard node page
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
application/web/web_main.py |
Adds a single-CRE redirect branch in smartlink() before the existing multi-CRE redirect logic |
application/tests/web_main_test.py |
Updates existing single-CRE test expectations and adds a new multi-CRE regression test |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #486
Problem
When a smartlinked standard (e.g.,
/smartlink/standard/CWE/611) resolves to only one connected CRE, the user is taken to an intermediate standard page that just shows the single CRE link. This adds an unnecessary click — the user has to click through to reach the CRE page they actually want.Changes
application/web/web_main.py— Modified thesmartlink()function to check the number of linked CREs. When exactly one CRE is linked, it now redirects directly to/cre/{id}instead of the intermediate/node/...page. When multiple CREs are linked, the existing behavior is preserved.application/tests/web_main_test.py— Updated existing test expectations for single-CRE cases (CWE/456 →/cre/222-222, ASVS/v0.1.2 →/cre/333-333) and added a new test case verifying that standards with multiple CRE links still redirect to the standard page.Testing
test_smartlink— all assertions pass/cre/{id}✅/node/standard/...(unchanged) ✅AI Disclosure
I used Claude AI to help plan my approach and explore the codebase structure. All implementation, testing, and debugging was done by me.