Skip to content

fix: redirect smartlink directly to CRE when only one is linked#797

Open
ghostiee-11 wants to merge 1 commit intoOWASP:mainfrom
ghostiee-11:fix/smartlink-single-cre-redirect
Open

fix: redirect smartlink directly to CRE when only one is linked#797
ghostiee-11 wants to merge 1 commit intoOWASP:mainfrom
ghostiee-11:fix/smartlink-single-cre-redirect

Conversation

@ghostiee-11
Copy link

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

  1. application/web/web_main.py — Modified the smartlink() 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.

  2. 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

  • Ran test_smartlink — all assertions pass
  • Single CRE case: redirects to /cre/{id}
  • Multiple CRE case: redirects to /node/standard/... (unchanged) ✅
  • Non-existent standard: redirects to external (e.g., Mitre) ✅
  • Unknown standard: returns 404 ✅

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.

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.
Copilot AI review requested due to automatic review settings March 9, 2026 11:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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() in web_main.py to 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make smartlink go to CRE directly

2 participants