Fix unhandled StopIteration/AttributeError crashes and unclosed <a> tags in Advisory Curation views

Aperta
#2,478 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Anurag-S1ngh ci sta già lavorando.

Dal 24/10/2026.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
django, python
Ambito
backend, frontend

Direzione di ricerca

Start with vulnerabilities/views.py and vulnerabilities/templates/advisory_todos.html, following the named AdvisoryMitigationCurationView and curation data accesses. Check the affected curation views for empty summaries, missing advisories, and missing curation_items, then inspect the conditional links for the three listed curation types. Done means those cases render without uncaught exceptions and each generated link has a matching closing tag.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

While reviewing the advisory curation workflow in vulnerabilities/views.py and advisory_todos.html, I identified two bugs:

  1. In vulnerabilities/views.py, AdvisoryMitigationCurationView extracts summaries and the primary AVID using:

    context["advisory_summaries"] = {
        adv.avid: adv.summary for adv in todo.advisories.all() if adv.summary.strip()
    }
    context["avid"] = next(iter(context["advisory_summaries"]))
    context["curation_items"] = [
        a.base_purl
        for a in todo.advisories.first().impacted_packages.filter(
            fixed_by_packages__isnull=True
        )
    ]
    
    • If advisories have empty summaries, context["advisory_summaries"] is empty and next(iter({})) raises an uncaught StopIteration (HTTP 500).
    • If a todo has no linked advisories, todo.advisories.first() returns None, raising AttributeError.
    • Directly accessing todo.issue_detail["curation_items"] in other curation views also raises KeyError/TypeError when the key is missing.
  2. In vulnerabilities/templates/advisory_todos.html, opening <a> tags are generated for CONFLICTING_SEVERITY_SCORES, CONFLICTING_WEAKNESSES, and MISSING_FIXED_BY_PACKAGE, but the closing </a> tag is only rendered for supported_curation.split. This leaves anchor tags unclosed and breaks table row formatting.

Steps to Reproduce
  1. Open /advisories/todos/ and inspect table rows for CONFLICTING_SEVERITY_SCORES, CONFLICTING_WEAKNESSES, or MISSING_FIXED_BY_PACKAGE: observe that opening <a> tags lack matching closing </a> tags in the rendered HTML output.
  2. Create or identify an AdvisoryToDo item of type MISSING_FIXED_BY_PACKAGE where linked advisories have empty summary fields (or where no advisories are linked).
  3. Navigate to /advisories/todos/<todo_id>/mitigation/curate/ for that To-Do item.
  4. Observe Django raising an unhandled StopIteration or AttributeError, resulting in an HTTP 500 response.
Current Behavior
  • AdvisoryMitigationCurationView crashes with an HTTP 500 error instead of handling empty summaries or missing advisories gracefully.
  • advisory_todos.html produces mismatched anchor tags, corrupting the table DOM structure and causing layout issues in the browser.
Expected Behavior
  • The curation views should handle empty summaries, missing advisories, and missing curation data gracefully without raising unhandled exceptions, returning a valid page instead of HTTP 500.
  • The generated HTML should be valid, with correctly matched opening and closing <a> tags for all supported curation types.
Additional Context

I would like to work on this issue myself if assigned.

Lingua principale
Python
Stelle
716
Fork
347
Merge medio
13h 47m
PR unite (30g)
8

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di aboutcode-org/vulnerablecode

Tutte le issue di aboutcode-org/vulnerablecode

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.