vulnerablecode icon indicating copy to clipboard operation
vulnerablecode copied to clipboard

Affected-by-advisories v2 page returns 500 for a purl with no matching package

Open sanchit955 opened this issue 2 weeks ago • 0 comments

Visiting the affected-by-advisories v2 page for a package that is not in the database returns a 500 instead of an empty result list.

Steps to reproduce

  1. Open /affected-by-advisories/v2/pkg:pypi/[email protected] (after the Altcha challenge).
  2. The page returns HTTP 500.

What happens

AffectedByAdvisoriesListView.get_context_data looks the purl up with PackageV2.objects.for_purl(purl).first(), which returns None when there is no matching package, and passes it straight to get_fixed_package_details(). That helper dereferences package.affected_in_impacts, so it raises:

AttributeError: 'NoneType' object has no attribute 'affected_in_impacts'

(vulnerabilities/views.py:441)

Expected behaviour

The page should render with zero results, the same as any other purl with no affecting advisories. A mistyped or not-yet-imported package link should not 500.

Notes

  • The same helper is also used by PackageV2Details, but there self.object is never None (the detail view 404s first), so only this list view is affected.
  • The fix is a None guard in get_fixed_package_details() returning an empty mapping, which the template already handles through the get_item filter.

sanchit955 avatar Nov 16 '26 09:11 sanchit955