Skip to content

Commit 73dddf6

Browse files
authored
Merge pull request #10647 from DefectDojo/release/2.36.6
Release: Merge release into master from: release/2.36.6
2 parents c58a297 + f58e43b commit 73dddf6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4886
-660
lines changed

.github/workflows/refresh_helm_lock_file.yaml

Lines changed: 0 additions & 40 deletions
This file was deleted.

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.36.5",
3+
"version": "2.36.6",
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.36.5'
7+
__version__ = '2.36.6'
88
__url__ = 'https://github.com/DefectDojo/django-DefectDojo'
99
__docs__ = 'https://documentation.defectdojo.com'

dojo/api_v2/views.py

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
from dojo.user.utils import get_configuration_permissions_codenames
165165
from dojo.utils import (
166166
async_delete,
167+
generate_file_response,
167168
get_setting,
168169
get_system_setting,
169170
)
@@ -646,21 +647,8 @@ def download_file(self, request, file_id, pk=None):
646647
{"error": "File ID not associated with Engagement"},
647648
status=status.HTTP_404_NOT_FOUND,
648649
)
649-
# Get the path of the file in media root
650-
file_path = f"{settings.MEDIA_ROOT}/{file_object.file.url.lstrip(settings.MEDIA_URL)}"
651-
file_handle = open(file_path, "rb")
652650
# send file
653-
response = FileResponse(
654-
file_handle,
655-
content_type=f"{mimetypes.guess_type(file_path)}",
656-
status=status.HTTP_200_OK,
657-
)
658-
response["Content-Length"] = file_object.file.size
659-
response[
660-
"Content-Disposition"
661-
] = f'attachment; filename="{file_object.file.name}"'
662-
663-
return response
651+
return generate_file_response(file_object)
664652

665653

666654
class RiskAcceptanceViewSet(
@@ -1156,21 +1144,8 @@ def download_file(self, request, file_id, pk=None):
11561144
{"error": "File ID not associated with Finding"},
11571145
status=status.HTTP_404_NOT_FOUND,
11581146
)
1159-
# Get the path of the file in media root
1160-
file_path = f"{settings.MEDIA_ROOT}/{file_object.file.url.lstrip(settings.MEDIA_URL)}"
1161-
file_handle = open(file_path, "rb")
11621147
# send file
1163-
response = FileResponse(
1164-
file_handle,
1165-
content_type=f"{mimetypes.guess_type(file_path)}",
1166-
status=status.HTTP_200_OK,
1167-
)
1168-
response["Content-Length"] = file_object.file.size
1169-
response[
1170-
"Content-Disposition"
1171-
] = f'attachment; filename="{file_object.file.name}"'
1172-
1173-
return response
1148+
return generate_file_response(file_object)
11741149

11751150
@extend_schema(
11761151
request=serializers.FindingNoteSerializer,
@@ -2320,21 +2295,8 @@ def download_file(self, request, file_id, pk=None):
23202295
{"error": "File ID not associated with Test"},
23212296
status=status.HTTP_404_NOT_FOUND,
23222297
)
2323-
# Get the path of the file in media root
2324-
file_path = f"{settings.MEDIA_ROOT}/{file_object.file.url.lstrip(settings.MEDIA_URL)}"
2325-
file_handle = open(file_path, "rb")
23262298
# send file
2327-
response = FileResponse(
2328-
file_handle,
2329-
content_type=f"{mimetypes.guess_type(file_path)}",
2330-
status=status.HTTP_200_OK,
2331-
)
2332-
response["Content-Length"] = file_object.file.size
2333-
response[
2334-
"Content-Disposition"
2335-
] = f'attachment; filename="{file_object.file.name}"'
2336-
2337-
return response
2299+
return generate_file_response(file_object)
23382300

23392301

23402302
# Authorization: authenticated, configuration

dojo/apps.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,19 @@ def ready(self):
7272
# Load any signals here that will be ready for runtime
7373
# Importing the signals file is good enough if using the reciever decorator
7474
import dojo.announcement.signals # noqa: F401
75+
import dojo.benchmark.signals # noqa: F401
76+
import dojo.cred.signals # noqa: F401
7577
import dojo.endpoint.signals # noqa: F401
7678
import dojo.engagement.signals # noqa: F401
7779
import dojo.finding_group.signals # noqa: F401
80+
import dojo.notes.signals # noqa: F401
7881
import dojo.product.signals # noqa: F401
7982
import dojo.product_type.signals # noqa: F401
83+
import dojo.risk_acceptance.signals # noqa: F401
8084
import dojo.sla_config.helpers # noqa: F401
8185
import dojo.tags_signals # noqa: F401
8286
import dojo.test.signals # noqa: F401
87+
import dojo.tool_product.signals # noqa: F401
8388

8489

8590
def get_model_fields_with_extra(model, extra_fields=()):

dojo/benchmark/signals.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import logging
2+
3+
from django.db.models.signals import pre_delete
4+
from django.dispatch import receiver
5+
6+
from dojo.models import Benchmark_Product
7+
from dojo.notes.helper import delete_related_notes
8+
9+
logger = logging.getLogger(__name__)
10+
11+
12+
@receiver(pre_delete, sender=Benchmark_Product)
13+
def benchmark_product_pre_delete(sender, instance, **kwargs):
14+
delete_related_notes(instance)

dojo/benchmark/views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def add_benchmark(queryset, product):
4343
pass
4444

4545

46+
@user_is_authorized(Product, Permissions.Benchmark_Edit, "pid")
4647
def update_benchmark(request, pid, _type):
4748
if request.method == "POST":
4849
bench_id = request.POST.get("bench_id")
@@ -90,6 +91,7 @@ def update_benchmark(request, pid, _type):
9091
)
9192

9293

94+
@user_is_authorized(Product, Permissions.Benchmark_Edit, "pid")
9395
def update_benchmark_summary(request, pid, _type, summary):
9496
if request.method == "POST":
9597
field = request.POST.get("field")

dojo/components/views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,6 @@ def components(request):
7070
"filter": comp_filter,
7171
"result": result,
7272
"component_words": sorted(set(component_words)),
73+
"enable_table_filtering": get_system_setting("enable_ui_table_based_searching"),
7374
},
7475
)

dojo/cred/signals.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import logging
2+
3+
from django.db.models.signals import pre_delete
4+
from django.dispatch import receiver
5+
6+
from dojo.models import Cred_User
7+
from dojo.notes.helper import delete_related_notes
8+
9+
logger = logging.getLogger(__name__)
10+
11+
12+
@receiver(pre_delete, sender=Cred_User)
13+
def cred_user_pre_delete(sender, instance, **kwargs):
14+
delete_related_notes(instance)

dojo/cred/views.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ def view_cred_details(request, ttid):
112112
'cred': cred,
113113
'form': form,
114114
'notes': notes,
115-
'cred_products': cred_products
115+
'cred_products': cred_products,
116+
'person': request.user.username,
116117
})
117118

118119

@@ -650,7 +651,7 @@ def delete_cred_controller(request, destination_url, id, ttid):
650651
if id:
651652
product = None
652653
if destination_url == "all_cred_product":
653-
product = get_object_or_404(Product, id)
654+
product = get_object_or_404(Product, id=id)
654655
elif destination_url == "view_engagement":
655656
engagement = get_object_or_404(Engagement, id=id)
656657
product = engagement.product
@@ -669,7 +670,7 @@ def delete_cred_controller(request, destination_url, id, ttid):
669670

670671
@user_is_authorized(Cred_User, Permissions.Credential_Delete, 'ttid')
671672
def delete_cred(request, ttid):
672-
return delete_cred_controller(request, "cred", 0, ttid)
673+
return delete_cred_controller(request, "cred", 0, ttid=ttid)
673674

674675

675676
@user_is_authorized(Product, Permissions.Product_Edit, 'pid')

0 commit comments

Comments
 (0)