Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dojo/importers/base_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ def update_import_history(
import_settings["close_old_findings"] = self.close_old_findings_toggle
import_settings["push_to_jira"] = self.push_to_jira
import_settings["tags"] = self.tags
import_settings["scan_date"] = self.scan_date.isoformat() if self.scan_date_override else None
if settings.V3_FEATURE_LOCATIONS:
# Add the list of locations that were added exclusively at import time
if len(self.endpoints_to_add) > 0:
Expand Down
28 changes: 28 additions & 0 deletions unittests/test_update_import_history.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import json
import logging
from datetime import UTC, datetime
from unittest.mock import patch

from django.contrib.auth.models import User as DjangoUser
Expand Down Expand Up @@ -149,3 +151,29 @@ def test_precheck_filters_out_deleted_findings_allows_successful_bulk(self):
expected = (len(new_findings) - 1) + (len(closed_findings) - 1)
created = Test_Import_Finding_Action.objects.filter(test_import=test_import).count()
self.assertEqual(created, expected)

def test_import_settings_scan_date_when_user_supplies_scan_date(self):
"""When the user supplies a scan_date, import_settings should contain the ISO-formatted date."""
user_scan_date = datetime(2025, 6, 15, 12, 0, 0, tzinfo=UTC)
self.importer.scan_date = user_scan_date
self.importer.scan_date_override = True

new_findings = self._create_findings(1)
test_import = self.importer.update_import_history(new_findings=new_findings)

settings = test_import.import_settings
# Verify import_settings is JSON-serializable (the original bug)
json.dumps(settings)
self.assertEqual(settings["scan_date"], user_scan_date.isoformat())

def test_import_settings_scan_date_when_no_scan_date_supplied(self):
"""When no scan_date override is provided, import_settings should have scan_date as None."""
self.importer.scan_date_override = False

new_findings = self._create_findings(1)
test_import = self.importer.update_import_history(new_findings=new_findings)

settings = test_import.import_settings
# Verify import_settings is JSON-serializable
json.dumps(settings)
self.assertIsNone(settings["scan_date"])
Loading