Skip to content

Trivy Scan import results in parser crash #15653

Description

@richardj-bsquare

Bug description
There is a path in the parser code where resource_name variable can be appended to before it has been initialised.

Steps to reproduce
Import of trivy vulnerabilities where a resource_name was not presented on a namespace first.
My trivy findings have exactly that.

Expected behavior
Import should not crash.

Deployment method (select with an X)

  • [ X] Docker Compose
  • Kubernetes
  • GoDojo

Environment information

  • Ubuntu 24.04
  • Docker Compose
  • 3.2.100

Logs

2026-08-12T16:27:54.252789837Z :error: @stderr /ecs-cicd-defect-dojo-23-uwsgi-8eaacdd2f7e9e5a65700  File "/app/dojo/importers/base_importer.py", line 259, in parse_findings_static_test_type2026-08-12T16:27:54.252797607Z :error: @stderr /ecs-cicd-defect-dojo-23-uwsgi-8eaacdd2f7e9e5a65700    return parser.get_findings(scan, self.test)
2026-08-12T16:27:54.252859489Z :error: @stderr /ecs-cicd-defect-dojo-23-uwsgi-8eaacdd2f7e9e5a65700  File "/app/dojo/tools/trivy/parser.py", line 224, in get_findings
2026-08-12T16:27:54.25286388Z :error: @stderr /ecs-cicd-defect-dojo-23-uwsgi-8eaacdd2f7e9e5a65700    resource_name += f"{kind} / "
2026-08-12T16:27:54.252963813Z :error: @stderr /ecs-cicd-defect-dojo-23-uwsgi-8eaacdd2f7e9e5a65700UnboundLocalError: cannot access local variable 'resource_name' where it is not associated with a value
2026-08-12T16:27:54.498748299Z :error: @stderr /ecs-cicd-defect-dojo-23-uwsgi-8eaacdd2f7e9e5a65700[12/Aug/2026 16:27:54] ERROR [django.request:253] Internal Server Error: /api/v2/reimport-scan/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions