Skip to content

Commit d522bbe

Browse files
authored
Merge pull request #10809 from DefectDojo/release/2.37.3
Release: Merge release into master from: release/2.37.3
2 parents 05f20fc + 2e80f2d commit d522bbe

File tree

21 files changed

+731
-44
lines changed

21 files changed

+731
-44
lines changed

Dockerfile.integration-tests-debian

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ RUN pip install --no-cache-dir selenium==4.9.0 requests
2525

2626
# Install the latest Google Chrome stable release
2727
WORKDIR /opt/chrome
28+
29+
# TODO: figure out whatever fix is necessary to use Chrome >= 128 and put this back in the RUN below so we stay
30+
# up-to-date
31+
# chrome_url=$(curl https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r '.channels[] | select(.channel == "Stable") | .downloads.chrome[] | select(.platform == "linux64").url') && \
32+
2833
RUN \
29-
chrome_url=$(curl https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r '.channels[] | select(.channel == "Stable") | .downloads.chrome[] | select(.platform == "linux64").url') && \
34+
chrome_url="https://storage.googleapis.com/chrome-for-testing-public/127.0.6533.119/linux64/chrome-linux64.zip" && \
3035
wget $chrome_url && \
3136
unzip chrome-linux64.zip && \
3237
rm -rf chrome-linux64.zip && \
@@ -49,8 +54,12 @@ RUN apt-get install -y libxi6 libgconf-2-4 jq libjq1 libonig5 libxkbcommon0 libx
4954

5055
# Installing the latest stable Google Chrome driver release
5156
WORKDIR /opt/chrome-driver
57+
# TODO: figure out whatever fix is necessary to use Chrome >= 128 and put this back in the RUN below so we stay
58+
# up-to-date
59+
# chromedriver_url=$(curl https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r '.channels[] | select(.channel == "Stable") | .downloads.chromedriver[] | select(.platform == "linux64").url') && \
60+
5261
RUN \
53-
chromedriver_url=$(curl https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r '.channels[] | select(.channel == "Stable") | .downloads.chromedriver[] | select(.platform == "linux64").url') && \
62+
chromedriver_url="https://storage.googleapis.com/chrome-for-testing-public/127.0.6533.119/linux64/chromedriver-linux64.zip" && \
5463
wget $chromedriver_url && \
5564
unzip -j chromedriver-linux64.zip chromedriver-linux64/chromedriver && \
5665
rm -rf chromedriver-linux64.zip && \

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.37.2",
3+
"version": "2.37.3",
44
"license" : "BSD-3-Clause",
55
"private": true,
66
"dependencies": {

docs/content/en/integrations/api-v2-docs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ For example: :
4747

4848
If you use [an alternative authentication method](../social-authentication/) for users, you may want to disable DefectDojo API tokens because it could bypass your authentication concept. \
4949
Using of DefectDojo API tokens can be disabled by specifying the environment variable `DD_API_TOKENS_ENABLED` to `False`.
50+
Or only `api/v2/api-token-auth/` endpoint can be disabled by setting `DD_API_TOKEN_AUTH_ENDPOINT_ENABLED` to `False`.
5051

5152
## Sample Code
5253

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.37.2"
7+
__version__ = "2.37.3"
88
__url__ = "https://github.com/DefectDojo/django-DefectDojo"
99
__docs__ = "https://documentation.defectdojo.com"

dojo/context_processors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def globalize_vars(request):
2525
"SAML2_LOGOUT_URL": settings.SAML2_LOGOUT_URL,
2626
"DOCUMENTATION_URL": settings.DOCUMENTATION_URL,
2727
"API_TOKENS_ENABLED": settings.API_TOKENS_ENABLED,
28+
"API_TOKEN_AUTH_ENDPOINT_ENABLED": settings.API_TOKEN_AUTH_ENDPOINT_ENABLED,
2829
}
2930

3031

dojo/engagement/views.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
TypedNoteForm,
6868
UploadThreatForm,
6969
)
70+
from dojo.importers.base_importer import BaseImporter
7071
from dojo.importers.default_importer import DefaultImporter
7172
from dojo.models import (
7273
Check_List,
@@ -921,6 +922,15 @@ def create_engagement(
921922
# Return the engagement
922923
return engagement
923924

925+
def get_importer(
926+
self,
927+
context: dict,
928+
) -> BaseImporter:
929+
"""
930+
Gets the importer to use
931+
"""
932+
return DefaultImporter(**context)
933+
924934
def import_findings(
925935
self,
926936
context: dict,
@@ -929,7 +939,7 @@ def import_findings(
929939
Attempt to import with all the supplied information
930940
"""
931941
try:
932-
importer_client = DefaultImporter(**context)
942+
importer_client = self.get_importer(context)
933943
context["test"], _, finding_count, closed_finding_count, _, _, _ = importer_client.process_scan(
934944
context.pop("scan", None),
935945
)

dojo/importers/default_importer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def process_scan(
108108
new_findings = self.determine_process_method(self.parsed_findings, **kwargs)
109109
# Close any old findings in the processed list if the the user specified for that
110110
# to occur in the form that is then passed to the kwargs
111-
closed_findings = self.close_old_findings(self.test.finding_set.values(), **kwargs)
111+
closed_findings = self.close_old_findings(self.test.finding_set.all(), **kwargs)
112112
# Update the timestamps of the test object by looking at the findings imported
113113
self.update_timestamps()
114114
# Update the test meta
@@ -247,11 +247,12 @@ def close_old_findings(
247247
logger.debug("REIMPORT_SCAN: Closing findings no longer present in scan report")
248248
# Close old active findings that are not reported by this scan.
249249
# Refactoring this to only call test.finding_set.values() once.
250+
findings = findings.values()
250251
mitigated_hash_codes = []
251252
new_hash_codes = []
252253
for finding in findings:
253254
new_hash_codes.append(finding["hash_code"])
254-
if getattr(finding, "is_mitigated", None):
255+
if finding.get("is_mitigated", None):
255256
mitigated_hash_codes.append(finding["hash_code"])
256257
for hash_code in new_hash_codes:
257258
if hash_code == finding["hash_code"]:

dojo/importers/default_reimporter.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ def process_scan(
147147
test_import_history,
148148
)
149149

150+
def determine_deduplication_algorithm(self) -> str:
151+
"""
152+
Determines what dedupe algorithm to use for the Test being processed.
153+
:return: A string representing the dedupe algorithm to use.
154+
"""
155+
return self.test.deduplication_algorithm
156+
150157
def process_findings(
151158
self,
152159
parsed_findings: List[Finding],
@@ -160,7 +167,7 @@ def process_findings(
160167
at import time
161168
"""
162169

163-
self.deduplication_algorithm = self.test.deduplication_algorithm
170+
self.deduplication_algorithm = self.determine_deduplication_algorithm()
164171
self.original_items = list(self.test.finding_set.all())
165172
self.new_items = []
166173
self.reactivated_items = []

dojo/models.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,14 +2640,7 @@ def save(self, dedupe_option=True, rules_option=True, product_grading_option=Tru
26402640
except Exception as ex:
26412641
logger.error("Can't compute cvssv3 score for finding id %i. Invalid cvssv3 vector found: '%s'. Exception: %s", self.id, self.cvssv3, ex)
26422642

2643-
# Finding.save is called once from serializers.py with dedupe_option=False because the finding is not ready yet, for example the endpoints are not built
2644-
# It is then called a second time with dedupe_option defaulted to true; now we can compute the hash_code and run the deduplication
2645-
if dedupe_option:
2646-
if (self.hash_code is not None):
2647-
deduplicationLogger.debug("Hash_code already computed for finding")
2648-
else:
2649-
self.hash_code = self.compute_hash_code()
2650-
deduplicationLogger.debug("Hash_code computed for finding: %s", self.hash_code)
2643+
self.set_hash_code(dedupe_option)
26512644

26522645
if self.pk is None:
26532646
# We enter here during the first call from serializers.py
@@ -3346,6 +3339,20 @@ def inherit_tags(self, potentially_existing_tags):
33463339
def violates_sla(self):
33473340
return (self.sla_expiration_date and self.sla_expiration_date < timezone.now().date())
33483341

3342+
def set_hash_code(self, dedupe_option):
3343+
from dojo.utils import get_custom_method
3344+
if hash_method := get_custom_method("FINDING_HASH_METHOD"):
3345+
hash_method(self, dedupe_option)
3346+
else:
3347+
# Finding.save is called once from serializers.py with dedupe_option=False because the finding is not ready yet, for example the endpoints are not built
3348+
# It is then called a second time with dedupe_option defaulted to true; now we can compute the hash_code and run the deduplication
3349+
if dedupe_option:
3350+
if self.hash_code is not None:
3351+
deduplicationLogger.debug("Hash_code already computed for finding")
3352+
else:
3353+
self.hash_code = self.compute_hash_code()
3354+
deduplicationLogger.debug("Hash_code computed for finding: %s", self.hash_code)
3355+
33493356

33503357
class FindingAdmin(admin.ModelAdmin):
33513358
# For efficiency with large databases, display many-to-many fields with raw
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
66ee64ade0a61b090efd059a63e39f11683bd53e33bd25b8d41009cbbde06073
1+
c2ba2c95bb8a9b55330a5c3a8a627cfcaf2135780893367399f8eb51f4a0b3d8

0 commit comments

Comments
 (0)