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

オープン 初心者向け
#2,501 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@sanchit955 がすでに取り組んでいます。

2026年11月16日 から。

  • #2502 @sanchit955 による — オープン

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
django, python
領域
backend, security

調査の方向性

vulnerabilities/views.py の AffectedByAdvisoriesListView.get_context_data から始め、get_fixed_package_details() の呼び出しをたどってください。テンプレートが get_item フィルターを使って空のマッピングをどのように処理するか確認し、該当する view のテストを実行してください。一致する package がない purl が HTTP 500 を返さず、結果ゼロで正常に表示されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
Python
スター
717
フォーク
353
平均マージ
11時間 59分
マージ済み PR(30日)
2

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aboutcode-org/vulnerablecode のほかの issue

aboutcode-org/vulnerablecode の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。