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

Đang mở Phù hợp với người mới
#2,501 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@sanchit955 đang làm issue này rồi.

Từ ngày 16/11/2026.

  • #2502 của @sanchit955 — đang mở

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
88/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
django, python
Lĩnh vực
backend, security

Hướng nghiên cứu

Bắt đầu tại vulnerabilities/views.py, ở AffectedByAdvisoriesListView.get_context_data, rồi lần theo lời gọi đến get_fixed_package_details(). Kiểm tra cách template xử lý một mapping rỗng thông qua bộ lọc get_item, sau đó chạy các bài kiểm thử view liên quan. Hoàn thành khi một purl không có package khớp được render thành công với không kết quả nào thay vì trả về HTTP 500.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Python
Star
717
Fork
353
Merge trung bình
11 giờ 59 phút
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của aboutcode-org/vulnerablecode

Tất cả issue của aboutcode-org/vulnerablecode

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.