Skip to content

feat: Add dry_run support for reimport-scan operations#13563

Draft
Siryu6 wants to merge 10000 commits intoDefectDojo:devfrom
Siryu6:feature/dry-run-reimport
Draft

feat: Add dry_run support for reimport-scan operations#13563
Siryu6 wants to merge 10000 commits intoDefectDojo:devfrom
Siryu6:feature/dry-run-reimport

Conversation

@Siryu6
Copy link
Copy Markdown

@Siryu6 Siryu6 commented Oct 29, 2025

Description

This PR implements a dry_run feature for reimport-scan operations that allows users to preview what changes would occur during a reimport without making any database modifications.

Key Features:

  • Optional dry_run boolean parameter (defaults to false) on reimport-scan API endpoints
  • Returns detailed statistics about findings that would be created, reactivated, closed, or left untouched
  • Respects all existing reimport parameters (close_old_findings, do_not_reactivate, severity filters, etc.)
  • Non-breaking: all existing functionality remains unchanged

Use Case:
This feature is particularly useful for CI/CD pipelines where teams want to validate scan results and preview changes before merging to production environments.

API Response Example:

{
  "test_id": 123,
  "dry_run": true,
  "changes_preview": {
    "would_create": 5,
    "would_reactivate": 2,
    "would_close": 3,
    "would_leave_untouched": 10,
    "total_changes": 10
  },
  "findings_details": {
    "new_findings": [...],
    "reactivated_findings": [...],
    "closed_findings": [...],
    "unchanged_findings": [...]
  }
}

Documentation

API documentation is included in the serializer field descriptions (help_text).

Files Changed

  • dojo/api_v2/serializers.py - API integration for dry_run parameter
  • dojo/importers/default_reimporter.py - Core dry_run_reimport() logic
  • dojo/importers/default_importer.py - Return signature update
  • dojo/importers/options.py - dry_run parameter validation
  • dojo/fixtures/dojo_testdata.json - Fixed missing SLA_Configuration
  • dojo/engagement/views.py - View layer dry_run support
  • dojo/test/views.py - View layer dry_run support
  • unittests/dojo_test_case.py - Test helper methods
  • unittests/test_import_reimport.py - Minor test adjustments
  • unittests/test_import_reimport_dry_run.py - New comprehensive test suite

Labels to add:

  • enhancement
  • feature

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.