Skip to content

Commit c182e9c

Browse files
authored
Merge pull request DefectDojo#9775 from DefectDojo/release/2.32.2
Release: Merge release into master from: release/2.32.2
2 parents 1f450c2 + d1eebce commit c182e9c

File tree

18 files changed

+141
-35
lines changed

18 files changed

+141
-35
lines changed

.dryrunsecurity.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
sensitiveCodepaths:
3-
- 'dojo/object/*.py' # FIXME
3+
- 'dojo/object/urls.py'
4+
- 'dojo/object/views.py'
45
- 'dojo/announcement/*.py'
56
- 'dojo/api_v2/*.py'
67
- 'dojo/api_v2/**/*.py'
@@ -62,6 +63,10 @@ allowedAuthors:
6263
- cneill
6364
- Maffooch
6465
- blakeowens
66+
- kiblik
67+
- dsever
68+
- dogboat
69+
- FelixHernandez
6570
notificationList:
6671
- '@mtesauro'
6772
- '@grendel513'

.flake8

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ ignore =
1212
C901
1313
# Multiple statements on one line
1414
E704
15-
# Assign a lambda expression
16-
E731
1715
# Bare except
1816
E722
1917
# Local variable

.github/workflows/ruff.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
run: pip install -r requirements-lint.txt
3434

3535
- name: Run Ruff Linter
36-
run: ruff .
36+
run: ruff check .

components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "defectdojo",
3-
"version": "2.32.1",
3+
"version": "2.32.2",
44
"license" : "BSD-3-Clause",
55
"private": true,
66
"dependencies": {

dojo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
# Django starts so that shared_task will use this app.
55
from .celery import app as celery_app # noqa: F401
66

7-
__version__ = '2.32.1'
7+
__version__ = '2.32.2'
88
__url__ = 'https://github.com/DefectDojo/django-DefectDojo'
99
__docs__ = 'https://documentation.defectdojo.com'

dojo/api_v2/serializers.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,6 +1717,17 @@ def get_display_status(self, obj) -> str:
17171717

17181718
# Overriding this to push add Push to JIRA functionality
17191719
def update(self, instance, validated_data):
1720+
# cvssv3 handling cvssv3 vector takes precedence,
1721+
# then cvssv3_score and finally severity
1722+
if validated_data.get("cvssv3"):
1723+
validated_data["cvssv3_score"] = None
1724+
validated_data["severity"] = ""
1725+
elif validated_data.get("cvssv3_score"):
1726+
validated_data["severity"] = ""
1727+
elif validated_data.get("severity"):
1728+
validated_data["cvssv3"] = None
1729+
validated_data["cvssv3_score"] = None
1730+
17201731
# remove tags from validated data and store them seperately
17211732
to_be_tagged, validated_data = self._pop_tags(validated_data)
17221733

@@ -2162,6 +2173,10 @@ class ImportScanSerializer(serializers.Serializer):
21622173
help_text="If set to True, the tags will be applied to the findings",
21632174
required=False,
21642175
)
2176+
apply_tags_to_endpoints = serializers.BooleanField(
2177+
help_text="If set to True, the tags will be applied to the endpoints",
2178+
required=False,
2179+
)
21652180

21662181
def save(self, push_to_jira=False):
21672182
data = self.validated_data
@@ -2181,6 +2196,7 @@ def save(self, push_to_jira=False):
21812196
api_scan_configuration = data.get("api_scan_configuration", None)
21822197
service = data.get("service", None)
21832198
apply_tags_to_findings = data.get("apply_tags_to_findings", False)
2199+
apply_tags_to_endpoints = data.get("apply_tags_to_endpoints", False)
21842200
source_code_management_uri = data.get(
21852201
"source_code_management_uri", None
21862202
)
@@ -2274,6 +2290,7 @@ def save(self, push_to_jira=False):
22742290
title=test_title,
22752291
create_finding_groups_for_all_findings=create_finding_groups_for_all_findings,
22762292
apply_tags_to_findings=apply_tags_to_findings,
2293+
apply_tags_to_endpoints=apply_tags_to_endpoints,
22772294
)
22782295

22792296
if test:
@@ -2446,6 +2463,10 @@ class ReImportScanSerializer(TaggitSerializer, serializers.Serializer):
24462463
help_text="If set to True, the tags will be applied to the findings",
24472464
required=False
24482465
)
2466+
apply_tags_to_endpoints = serializers.BooleanField(
2467+
help_text="If set to True, the tags will be applied to the endpoints",
2468+
required=False,
2469+
)
24492470

24502471
def save(self, push_to_jira=False):
24512472
logger.debug("push_to_jira: %s", push_to_jira)
@@ -2459,6 +2480,7 @@ def save(self, push_to_jira=False):
24592480
"close_old_findings_product_scope"
24602481
)
24612482
apply_tags_to_findings = data.get("apply_tags_to_findings", False)
2483+
apply_tags_to_endpoints = data.get("apply_tags_to_endpoints", False)
24622484
do_not_reactivate = data.get("do_not_reactivate", False)
24632485
version = data.get("version", None)
24642486
build_id = data.get("build_id", None)
@@ -2560,6 +2582,7 @@ def save(self, push_to_jira=False):
25602582
do_not_reactivate=do_not_reactivate,
25612583
create_finding_groups_for_all_findings=create_finding_groups_for_all_findings,
25622584
apply_tags_to_findings=apply_tags_to_findings,
2585+
apply_tags_to_endpoints=apply_tags_to_endpoints,
25632586
)
25642587

25652588
if test_import:
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 4.1.13 on 2024-03-14 17:18
2+
3+
import django.core.validators
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('dojo', '0203_alter_finding_options_finding_epss_percentile_and_more'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='finding',
16+
name='cvssv3_score',
17+
field=models.FloatField(blank=True, help_text='Numerical CVSSv3 score for the vulnerability. If the vector is given, the score is updated while saving the finding. The value must be between 0-10.', null=True, validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(10.0)], verbose_name='CVSSv3 score'),
18+
),
19+
]

dojo/engagement/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ def post(self, request, eid=None, pid=None):
738738
service = form.cleaned_data.get('service', None)
739739
close_old_findings = form.cleaned_data.get('close_old_findings', None)
740740
apply_tags_to_findings = form.cleaned_data.get('apply_tags_to_findings', False)
741+
apply_tags_to_endpoints = form.cleaned_data.get('apply_tags_to_endpoints', False)
741742
# close_old_findings_prodct_scope is a modifier of close_old_findings.
742743
# If it is selected, close_old_findings should also be selected.
743744
close_old_findings_product_scope = form.cleaned_data.get('close_old_findings_product_scope', None)
@@ -804,7 +805,7 @@ def post(self, request, eid=None, pid=None):
804805
minimum_severity=minimum_severity, endpoints_to_add=list(form.cleaned_data['endpoints']) + added_endpoints, scan_date=scan_date,
805806
version=version, branch_tag=branch_tag, build_id=build_id, commit_hash=commit_hash, push_to_jira=push_to_jira,
806807
close_old_findings=close_old_findings, close_old_findings_product_scope=close_old_findings_product_scope, group_by=group_by, api_scan_configuration=api_scan_configuration, service=service,
807-
create_finding_groups_for_all_findings=create_finding_groups_for_all_findings, apply_tags_to_findings=apply_tags_to_findings)
808+
create_finding_groups_for_all_findings=create_finding_groups_for_all_findings, apply_tags_to_findings=apply_tags_to_findings, apply_tags_to_endpoints=apply_tags_to_endpoints)
808809

809810
message = f'{scan_type} processed a total of {finding_count} findings'
810811

dojo/forms.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,12 @@ class ImportScanForm(forms.Form):
485485
required=False,
486486
initial=False
487487
)
488+
apply_tags_to_endpoints = forms.BooleanField(
489+
help_text="If set to True, the tags will be applied to the endpoints",
490+
label="Apply Tags to Endpoints",
491+
required=False,
492+
initial=False
493+
)
488494

489495
if is_finding_groups_enabled():
490496
group_by = forms.ChoiceField(required=False, choices=Finding_Group.GROUP_BY_OPTIONS, help_text='Choose an option to automatically group new findings by the chosen option.')
@@ -577,6 +583,12 @@ class ReImportScanForm(forms.Form):
577583
required=False,
578584
initial=False
579585
)
586+
apply_tags_to_endpoints = forms.BooleanField(
587+
help_text="If set to True, the tags will be applied to the endpoints",
588+
label="Apply Tags to Endpoints",
589+
required=False,
590+
initial=False
591+
)
580592

581593
if is_finding_groups_enabled():
582594
group_by = forms.ChoiceField(required=False, choices=Finding_Group.GROUP_BY_OPTIONS, help_text='Choose an option to automatically group new findings by the chosen option')
@@ -1190,6 +1202,7 @@ class FindingForm(forms.ModelForm):
11901202
cwe = forms.IntegerField(required=False)
11911203
vulnerability_ids = vulnerability_ids_field
11921204
cvssv3 = forms.CharField(max_length=117, required=False, widget=forms.TextInput(attrs={'class': 'cvsscalculator', 'data-toggle': 'dropdown', 'aria-haspopup': 'true', 'aria-expanded': 'false'}))
1205+
cvssv3_score = forms.FloatField(required=False, max_value=10.0, min_value=0.0)
11931206
description = forms.CharField(widget=forms.Textarea)
11941207
severity = forms.ChoiceField(
11951208
choices=SEVERITY_CHOICES,

dojo/importers/importer/importer.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ def close_old_findings(self, test, scan_date_time, user, push_to_jira=None, serv
265265
def import_scan(self, scan, scan_type, engagement, lead, environment, active=None, verified=None, tags=None, minimum_severity=None,
266266
user=None, endpoints_to_add=None, scan_date=None, version=None, branch_tag=None, build_id=None,
267267
commit_hash=None, push_to_jira=None, close_old_findings=False, close_old_findings_product_scope=False,
268-
group_by=None, api_scan_configuration=None, service=None, title=None, create_finding_groups_for_all_findings=True, apply_tags_to_findings=False):
268+
group_by=None, api_scan_configuration=None, service=None, title=None, create_finding_groups_for_all_findings=True,
269+
apply_tags_to_findings=False, apply_tags_to_endpoints=False):
269270

270271
logger.debug(f'IMPORT_SCAN: parameters: {locals()}')
271272

@@ -389,6 +390,12 @@ def import_scan(self, scan, scan_type, engagement, lead, environment, active=Non
389390
for tag in tags:
390391
finding.tags.add(tag)
391392

393+
if apply_tags_to_endpoints and tags:
394+
for finding in test_import.findings_affected.all():
395+
for endpoint in finding.endpoints.all():
396+
for tag in tags:
397+
endpoint.tags.add(tag)
398+
392399
logger.debug('IMPORT_SCAN: Generating notifications')
393400
notifications_helper.notify_test_created(test)
394401
updated_count = len(new_findings) + len(closed_findings)

0 commit comments

Comments
 (0)