Skip to content

Commit f751349

Browse files
authored
Import/Reimport Stats: Change name of left untouched (#12193)
* Import/Reimport Stats: Change name of left untouched * Update migrations * Failed spell check * Update migration again * Migrate from `left_untouched` to `untouched`
1 parent 5e97c09 commit f751349

File tree

4 files changed

+82
-5
lines changed

4 files changed

+82
-5
lines changed

docs/content/en/open_source/upgrading/2.46.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,41 @@
22
title: 'Upgrading to DefectDojo Version 2.46.x'
33
toc_hide: true
44
weight: -20250407
5-
description: No special instructions.
5+
description: Import Payload Changes
66
---
7-
There are no special instructions for upgrading to 2.46.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.46.0) for the contents of the release.
7+
8+
### Import / Reimport Statistics Delta
9+
10+
Following a successful import or reimport, a JSON blob for `statistics` is generated to provide the differential of finding activity.
11+
There was a section in the `delta` JSON blob that referred to a key labeled `left untouched`. This value does not comply with REST
12+
norms, and has been renamed to `untouched`. Here is a before and after to make it clear:
13+
14+
Before:
15+
16+
"statistics": {
17+
"before": {},
18+
"delta": {
19+
"created": {},
20+
"closed": {},
21+
"reactivated": {},
22+
"left untouched": {}
23+
},
24+
"after": {}
25+
}
26+
27+
After:
28+
29+
"statistics": {
30+
"before": {},
31+
"delta": {
32+
"created": {},
33+
"closed": {},
34+
"reactivated": {},
35+
"untouched": {}
36+
},
37+
"after": {}
38+
}
39+
40+
---
41+
42+
Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.46.0) for the contents of the release.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Generated by Django 5.0.8 on 2024-09-12 18:22
2+
3+
from django.db import migrations, models
4+
5+
6+
original_untouched_value = "left untouched"
7+
updated_untouched_value = "untouched"
8+
9+
10+
def convert_space_to_underscore(apps, schema_editor):
11+
test_import_finding_action = apps.get_model("dojo", "Test_Import_Finding_Action")
12+
for test_import_action in test_import_finding_action.objects.filter(
13+
action=original_untouched_value
14+
):
15+
test_import_action.action = updated_untouched_value
16+
test_import_action.save()
17+
18+
19+
def convert_underscore_to_space(apps, schema_editor):
20+
test_import_finding_action = apps.get_model("dojo", "Test_Import_Finding_Action")
21+
for test_import_action in test_import_finding_action.objects.filter(
22+
action=updated_untouched_value
23+
):
24+
test_import_action.action = original_untouched_value
25+
test_import_action.save()
26+
27+
28+
class Migration(migrations.Migration):
29+
dependencies = [
30+
("dojo", "0225_alter_product_revenue"),
31+
]
32+
33+
operations = [
34+
migrations.AlterField(
35+
model_name='test_import_finding_action',
36+
name='action',
37+
field=models.CharField(blank=True, choices=[('N', 'created'), ('C', 'closed'), ('R', 'reactivated'), ('U', 'untouched')], max_length=100, null=True),
38+
),
39+
migrations.RunPython(
40+
convert_space_to_underscore, reverse_code=convert_underscore_to_space
41+
),
42+
]

dojo/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
(IMPORT_CREATED_FINDING, "created"),
6868
(IMPORT_CLOSED_FINDING, "closed"),
6969
(IMPORT_REACTIVATED_FINDING, "reactivated"),
70-
(IMPORT_UNTOUCHED_FINDING, "left untouched"),
70+
(IMPORT_UNTOUCHED_FINDING, "untouched"),
7171
]
7272

7373

unittests/test_import_reimport.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,7 @@ def test_import_0_reimport_1_active_verified_reimport_0_active_verified_statisti
15541554
"low": {"active": 1, "duplicate": 0, "false_p": 0, "is_mitigated": 0, "out_of_scope": 0, "risk_accepted": 0, "total": 1, "verified": 0},
15551555
"medium": {"active": 0, "duplicate": 0, "false_p": 0, "is_mitigated": 0, "out_of_scope": 0, "risk_accepted": 0, "total": 0, "verified": 0},
15561556
"total": {"active": 1, "duplicate": 0, "false_p": 0, "is_mitigated": 0, "out_of_scope": 0, "risk_accepted": 0, "total": 1, "verified": 0}},
1557-
"left untouched": {
1557+
"untouched": {
15581558
"critical": {"active": 0, "duplicate": 0, "false_p": 0, "is_mitigated": 0, "out_of_scope": 0, "risk_accepted": 0, "total": 0, "verified": 0},
15591559
"high": {"active": 0, "duplicate": 0, "false_p": 0, "is_mitigated": 0, "out_of_scope": 0, "risk_accepted": 0, "total": 0, "verified": 0},
15601560
"info": {"active": 0, "duplicate": 0, "false_p": 0, "is_mitigated": 0, "out_of_scope": 0, "risk_accepted": 0, "total": 0, "verified": 0},
@@ -1604,7 +1604,7 @@ def test_import_0_reimport_1_active_verified_reimport_0_active_verified_statisti
16041604
"low": {"active": 0, "duplicate": 0, "false_p": 0, "is_mitigated": 0, "out_of_scope": 0, "risk_accepted": 0, "total": 0, "verified": 0},
16051605
"medium": {"active": 0, "duplicate": 0, "false_p": 0, "is_mitigated": 0, "out_of_scope": 0, "risk_accepted": 0, "total": 0, "verified": 0},
16061606
"total": {"active": 0, "duplicate": 0, "false_p": 0, "is_mitigated": 0, "out_of_scope": 0, "risk_accepted": 0, "total": 0, "verified": 0}},
1607-
"left untouched": {
1607+
"untouched": {
16081608
"critical": {"active": 0, "duplicate": 0, "false_p": 0, "is_mitigated": 0, "out_of_scope": 0, "risk_accepted": 0, "total": 0, "verified": 0},
16091609
"high": {"active": 0, "duplicate": 0, "false_p": 0, "is_mitigated": 0, "out_of_scope": 0, "risk_accepted": 0, "total": 0, "verified": 0},
16101610
"info": {"active": 0, "duplicate": 0, "false_p": 0, "is_mitigated": 0, "out_of_scope": 0, "risk_accepted": 0, "total": 0, "verified": 0},

0 commit comments

Comments
 (0)