django-DefectDojo icon indicating copy to clipboard operation
django-DefectDojo copied to clipboard

Bulk create/update/delete API endpoints for Findings

Open holdeg opened this issue 11 months ago • 6 comments

Is your feature request related to a problem? Please describe My organization's primary method for putting data in DefectDojo is to "manually" create and edit Findings, rather than using (re)import on scan reports - this allows us to have greater control over the data that ends up in DefectDojo, which in turn enables us to build tooling to optimize for our specific delivery requirements. We do this programmatically using bindings generated from the API definition; it would be great if we could add or edit Findings in bulk as opposed to needing to make separate API requests for each Finding we want to add or edit.

Describe the solution you'd like As a DevOps engineer, I would like bulk create/edit/delete methods on the Findings API to

  • improve the performance of adding or updating many findings at once
  • make updating multiple findings an atomic operation.

I haven't thoroughly gotten to grips with the DefectDojo codebase to understand exactly where this would fit, I imagine as a new view somewhere (either under dojo/finding or elsewhere).

Describe alternatives you've considered We could consider running a sidecar Django application alongside DefectDojo to achieve this function - at the very least, I'm planning to have a little play around with this.

Additional context I'm raising this issue mostly to flag our interest in function like this (and to see if anyone else is keen) - I'm going to be experimenting with a few ways we could achieve this goal with our own deployment, and it might turn out that it's easiest for us to do something that doesn't interact with the repository as it currently stands, but if it's something DefectDojo users or maintainers would like in the upstream then I'd be happy to explore working on it.

(As a personal aside, I'd just like to thank the DefectDojo maintainers and contributors for the great quality FOSS!)

holdeg avatar Dec 15 '25 11:12 holdeg

Can you Assign this to me

Anujpandey12345 avatar Jan 06 '26 10:01 Anujpandey12345

@Anujpandey12345 Can you share your approach on how you want to implement this? The way Django and the datamodel works means that there is no easy way to delete findings in bulk.

valentijnscholten avatar Jan 06 '26 17:01 valentijnscholten

Thanks for the question. Given Django ORM limitations and DefectDojo’s data model, I’d approach this as follows:

  1. Separate bulk endpoints
  2. Bulk create
  3. Bulk update
  4. Bulk delete (soft delete only)
  5. Safety & limits This approach improves performance, keeps operations atomic, and aligns with DefectDojo’s audit-heavy design without introducing risky ORM shortcuts.

Anujpandey12345 avatar Jan 06 '26 17:01 Anujpandey12345

Can you provide more info as how you are going to implement these 5 items, especially item 4 and 5.

valentijnscholten avatar Jan 06 '26 18:01 valentijnscholten

point 4 Given DefectDojo’s data model and audit requirements, bulk delete should be soft delete only, not hard deletes. Approach:

  1. Reuse existing soft-delete semantics (active=False / similar)
  2. No QuerySet.delete() to avoid cascading side effects
  3. Perform per-Finding permission checks
  4. Block deletion for Findings that are required for reports, metrics, or compliance
  5. Execute within a single transaction.atomic() block so the operation is all-or-nothing Because Findings are security-critical objects, bulk operations must be tightly controlled. Point 5 Safeguards:
  6. Hard cap on number of Findings per request (e.g. 100–500)
  7. Payload size limits and request timeouts
  8. Strict field allowlist (no arbitrary field updates)
  9. Full validation before any DB writes
  10. Required explicit confirmation flag for destructive operations
  11. Per-Finding permission checks (not just request-level)

Anujpandey12345 avatar Jan 07 '26 04:01 Anujpandey12345

Hey @holdeg @Anujpandey12345 @valentijnscholten I just created a PR which implements this bulk api endpoint for findings, feel free to review: https://github.com/DefectDojo/django-DefectDojo/pull/15240

npeham avatar Jul 14 '26 18:07 npeham