Skip to content

Commit 975135c

Browse files
Merge branch 'bugfix' into implement_oidc_groups
2 parents be4da7f + e2dbca5 commit 975135c

File tree

13 files changed

+230
-41
lines changed

13 files changed

+230
-41
lines changed

.github/workflows/test-helm-chart.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ jobs:
107107
steps:
108108
- name: Checkout
109109
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
110+
with:
111+
repository: ${{ github.event.pull_request.head.repo.full_name }}
112+
ref: ${{ github.event.pull_request.head.ref }}
110113

111114
- name: Update values in HELM chart
112115
if: startsWith(github.head_ref, 'renovate/') || startsWith(github.head_ref, 'dependabot/')

dojo/forms.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,18 @@ def __init__(self, *args, **kwargs):
11311131
else:
11321132
self.fields["lead"].queryset = get_authorized_users(Permissions.Test_View).filter(is_active=True)
11331133

1134+
def is_valid(self):
1135+
valid = super().is_valid()
1136+
1137+
# we're done now if not valid
1138+
if not valid:
1139+
return valid
1140+
if self.cleaned_data["target_start"] > self.cleaned_data["target_end"]:
1141+
self.add_error("target_start", "Your target start date exceeds your target end date")
1142+
self.add_error("target_end", "Your target start date exceeds your target end date")
1143+
return False
1144+
return True
1145+
11341146
class Meta:
11351147
model = Test
11361148
fields = ["title", "test_type", "target_start", "target_end", "description",

dojo/models.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,8 +1095,8 @@ def save(self, *args, **kwargs):
10951095
product.async_updating = True
10961096
super(Product, product).save()
10971097
# launch the async task to update all finding sla expiration dates
1098-
from dojo.sla_config.helpers import update_sla_expiration_dates_sla_config_async # noqa: I001, PLC0415 circular import
1099-
update_sla_expiration_dates_sla_config_async(self, products, tuple(severities))
1098+
from dojo.sla_config.helpers import async_update_sla_expiration_dates_sla_config_sync # noqa: I001, PLC0415 circular import
1099+
async_update_sla_expiration_dates_sla_config_sync(self, products, severities=severities)
11001100

11011101
def clean(self):
11021102
sla_days = [self.critical, self.high, self.medium, self.low]
@@ -1257,8 +1257,8 @@ def save(self, *args, **kwargs):
12571257
sla_config.async_updating = True
12581258
super(SLA_Configuration, sla_config).save()
12591259
# launch the async task to update all finding sla expiration dates
1260-
from dojo.sla_config.helpers import update_sla_expiration_dates_product_async # noqa: I001, PLC0415 circular import
1261-
update_sla_expiration_dates_product_async(self, sla_config)
1260+
from dojo.sla_config.helpers import async_update_sla_expiration_dates_sla_config_sync # noqa: I001, PLC0415 circular import
1261+
async_update_sla_expiration_dates_sla_config_sync(sla_config, Product.objects.filter(id=self.id))
12621262

12631263
def get_absolute_url(self):
12641264
return reverse("view_product", args=[str(self.id)])
@@ -3148,16 +3148,25 @@ def get_sla_configuration(self):
31483148
return self.test.engagement.product.sla_configuration
31493149

31503150
def get_sla_period(self):
3151+
# Determine which method to use to calculate the SLA
3152+
from dojo.utils import get_custom_method # noqa: PLC0415 circular import
3153+
if method := get_custom_method("FINDING_SLA_PERIOD_METHOD"):
3154+
return method(self)
3155+
# Run the default method
31513156
sla_configuration = self.get_sla_configuration()
31523157
sla_period = getattr(sla_configuration, self.severity.lower(), None)
31533158
enforce_period = getattr(sla_configuration, str("enforce_" + self.severity.lower()), None)
31543159
return sla_period, enforce_period
31553160

31563161
def set_sla_expiration_date(self):
3162+
# First check if SLA is enabled globally
31573163
system_settings = System_Settings.objects.get()
31583164
if not system_settings.enable_finding_sla:
31593165
return
3166+
# Call the internal method to set the sla expiration date
3167+
self._set_sla_expiration_date()
31603168

3169+
def _set_sla_expiration_date(self):
31613170
# some parsers provide date as a `str` instead of a `date` in which case we need to parse it #12299 on GitHub
31623171
sla_start_date = self.get_sla_start_date()
31633172
if sla_start_date and isinstance(sla_start_date, str):

dojo/sla_config/helpers.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,50 @@
22

33
from dojo.celery import app
44
from dojo.decorators import dojo_async_task
5-
from dojo.models import Finding, Product, SLA_Configuration
6-
from dojo.utils import calculate_grade, mass_model_updater
5+
from dojo.models import Finding, Product, SLA_Configuration, System_Settings
6+
from dojo.utils import get_custom_method, mass_model_updater
77

88
logger = logging.getLogger(__name__)
99

1010

1111
@dojo_async_task
1212
@app.task
13-
def update_sla_expiration_dates_sla_config_async(sla_config, products, severities, *args, **kwargs):
14-
update_sla_expiration_dates_sla_config_sync(sla_config, products, severities)
13+
def async_update_sla_expiration_dates_sla_config_sync(sla_config: SLA_Configuration, products: list[Product], *args, severities: list[str] | None = None, **kwargs):
14+
if method := get_custom_method("FINDING_SLA_EXPIRATION_CALCULATION_METHOD"):
15+
method(sla_config, products, severities=severities)
16+
else:
17+
update_sla_expiration_dates_sla_config_sync(sla_config, products, severities=severities)
1518

1619

17-
@dojo_async_task
18-
@app.task
19-
def update_sla_expiration_dates_product_async(product, sla_config, *args, **kwargs):
20-
update_sla_expiration_dates_sla_config_sync(sla_config, [product])
21-
22-
23-
def update_sla_expiration_dates_sla_config_sync(sla_config, products, severities=None):
20+
def update_sla_expiration_dates_sla_config_sync(sla_config: SLA_Configuration, products: list[Product], severities: list[str] | None = None):
2421
logger.info("Updating finding SLA expiration dates within the %s SLA configuration", sla_config)
22+
# First check if SLA is enabled globally
23+
system_settings = System_Settings.objects.get()
24+
if not system_settings.enable_finding_sla:
25+
return
2526
# update each finding that is within the SLA configuration that was saved
2627
findings = Finding.objects.filter(test__engagement__product__sla_configuration_id=sla_config.id)
2728
if products:
2829
findings = findings.filter(test__engagement__product__in=products)
2930
if severities:
3031
findings = findings.filter(severity__in=severities)
3132

32-
findings = findings.prefetch_related(
33+
findings = (
34+
findings.prefetch_related(
3335
"test",
3436
"test__engagement",
3537
"test__engagement__product",
3638
"test__engagement__product__sla_configuration",
39+
)
40+
.order_by("id")
41+
.only("id", "sla_start_date", "date", "severity", "test")
3742
)
38-
39-
findings = findings.order_by("id").only("id", "sla_start_date", "date", "severity", "test")
40-
43+
# Call the internal method so that we are not checking system settings for each finding
4144
mass_model_updater(Finding, findings, lambda f: f.set_sla_expiration_date(), fields=["sla_expiration_date"])
4245

4346
# reset the async updating flag to false for all products using this sla config
44-
for product in products:
45-
product.async_updating = False
46-
super(Product, product).save()
47-
calculate_grade(product)
47+
# use update as we don't want save() and signals to be triggered
48+
products.update(async_updating=False)
4849

4950
# reset the async updating flag to false for this sla config
5051
sla_config.async_updating = False

dojo/tools/nancy/parser.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22

33
from cvss.cvss3 import CVSS3
4+
from cvss.cvss4 import CVSS4
45

56
from dojo.models import Finding
67

@@ -64,17 +65,18 @@ def get_items(self, vulnerable, test):
6465
out_of_scope=False,
6566
static_finding=True,
6667
dynamic_finding=False,
67-
vuln_id_from_tool=associated_vuln["Id"],
68+
vuln_id_from_tool=associated_vuln.get("Id", associated_vuln.get("ID")),
6869
references="\n".join(references),
6970
)
70-
7171
finding.unsaved_vulnerability_ids = vulnerability_ids
72-
72+
cvss_vector = associated_vuln["CvssVector"]
7373
# CVSSv3 vector
74-
if associated_vuln["CvssVector"]:
74+
if cvss_vector and cvss_vector.startswith("CVSS:3."):
7575
finding.cvssv3 = CVSS3(
7676
associated_vuln["CvssVector"]).clean_vector()
77-
77+
elif cvss_vector and cvss_vector.startswith("CVSS:4."):
78+
finding.cvssv4 = CVSS4(
79+
associated_vuln["CvssVector"]).clean_vector()
7880
# do we have a CWE?
7981
if associated_vuln["Title"].startswith("CWE-"):
8082
cwe = (associated_vuln["Title"]

helm/defectdojo/Chart.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,8 @@ dependencies:
3434
# description: Critical bug
3535
annotations:
3636
artifacthub.io/prerelease: "true"
37-
artifacthub.io/changes: ""
37+
artifacthub.io/changes: |
38+
- kind: fixed
39+
description: Broken rendering of media PVC
40+
- kind: fixed
41+
description: Typo in description of digests

helm/defectdojo/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,11 +674,11 @@ A Helm chart for Kubernetes to install DefectDojo
674674
| host | string | `"defectdojo.default.minikube.local"` | Primary hostname of instance |
675675
| imagePullPolicy | string | `"Always"` | |
676676
| imagePullSecrets | string | `nil` | When using a private registry, name of the secret that holds the registry secret (eg deploy token from gitlab-ci project) Create secrets as: kubectl create secret docker-registry defectdojoregistrykey --docker-username=registry_username --docker-password=registry_password --docker-server='https://index.docker.io/v1/' |
677-
| images.django.image.digest | string | `""` | Prefix "sha@" is expected in this place |
677+
| images.django.image.digest | string | `""` | Prefix "sha256:" is expected in this place |
678678
| images.django.image.registry | string | `""` | |
679679
| images.django.image.repository | string | `"defectdojo/defectdojo-django"` | |
680680
| images.django.image.tag | string | `""` | If empty, use appVersion. Another possible values are: latest, X.X.X, X.X.X-debian, X.X.X-alpine (where X.X.X is version of DD). For dev builds (only for testing purposes): nightly-dev, nightly-dev-debian, nightly-dev-alpine. To see all, check https://hub.docker.com/r/defectdojo/defectdojo-django/tags. |
681-
| images.nginx.image.digest | string | `""` | Prefix "sha@" is expected in this place |
681+
| images.nginx.image.digest | string | `""` | Prefix "sha256:" is expected in this place |
682682
| images.nginx.image.registry | string | `""` | |
683683
| images.nginx.image.repository | string | `"defectdojo/defectdojo-nginx"` | |
684684
| images.nginx.image.tag | string | `""` | If empty, use appVersion. Another possible values are: latest, X.X.X, X.X.X-alpine (where X.X.X is version of DD). For dev builds (only for testing purposes): nightly-dev, nightly-dev-alpine. To see all, check https://hub.docker.com/r/defectdojo/defectdojo-nginx/tags. |

helm/defectdojo/templates/media-pvc.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
apiVersion: v1
55
kind: PersistentVolumeClaim
66
metadata:
7-
{{- with .Values.extraAnnotations }}
7+
{{- with $.Values.extraAnnotations }}
88
annotations:
99
{{- range $key, $value := . }}
1010
{{ $key }}: {{ quote $value }}
@@ -16,19 +16,19 @@ metadata:
1616
app.kubernetes.io/instance: {{ $.Release.Name }}
1717
app.kubernetes.io/managed-by: {{ $.Release.Service }}
1818
helm.sh/chart: {{ include "defectdojo.chart" $ }}
19-
{{- range $key, $value := .Values.extraLabels }}
19+
{{- range $key, $value := $.Values.extraLabels }}
2020
{{ $key }}: {{ quote $value }}
2121
{{- end }}
2222
name: {{ $fullName }}
23-
namespace: {{ .Release.Namespace }}
23+
namespace: {{ $.Release.Namespace }}
2424
spec:
2525
accessModes:
2626
{{- toYaml .persistentVolumeClaim.accessModes | nindent 4 }}
2727
resources:
2828
requests:
2929
storage: {{ .persistentVolumeClaim.size }}
30-
{{- if .persistentVolumeClaim.storageClassName }}
31-
storageClassName: {{ .persistentVolumeClaim.storageClassName }}
30+
{{- with .persistentVolumeClaim.storageClassName }}
31+
storageClassName: {{ . }}
3232
{{- end }}
3333
{{- end }}
3434
{{- end }}

helm/defectdojo/values.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@
865865
"type": "object",
866866
"properties": {
867867
"digest": {
868-
"description": "Prefix \"sha@\" is expected in this place",
868+
"description": "Prefix \"sha256:\" is expected in this place",
869869
"type": "string"
870870
},
871871
"registry": {
@@ -889,7 +889,7 @@
889889
"type": "object",
890890
"properties": {
891891
"digest": {
892-
"description": "Prefix \"sha@\" is expected in this place",
892+
"description": "Prefix \"sha256:\" is expected in this place",
893893
"type": "string"
894894
},
895895
"registry": {

helm/defectdojo/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ images:
3737
# For dev builds (only for testing purposes): nightly-dev, nightly-dev-debian, nightly-dev-alpine.
3838
# To see all, check https://hub.docker.com/r/defectdojo/defectdojo-django/tags.
3939
tag: ""
40-
# -- Prefix "sha@" is expected in this place
40+
# -- Prefix "sha256:" is expected in this place
4141
digest: ""
4242
nginx:
4343
image:
@@ -48,7 +48,7 @@ images:
4848
# For dev builds (only for testing purposes): nightly-dev, nightly-dev-alpine.
4949
# To see all, check https://hub.docker.com/r/defectdojo/defectdojo-nginx/tags.
5050
tag: ""
51-
# -- Prefix "sha@" is expected in this place
51+
# -- Prefix "sha256:" is expected in this place
5252
digest: ""
5353

5454
# -- Enables application network policy

0 commit comments

Comments
 (0)