Skip to content

Commit fb4728e

Browse files
authored
Merge pull request #12755 from DefectDojo/bugfix
Release 2.48.0: Merge Bugfix into Dev
2 parents 96c8e41 + 9b47699 commit fb4728e

20 files changed

+290
-7
lines changed

.github/workflows/integration-tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,17 @@ jobs:
3131
"tests/search_test.py",
3232
"tests/file_test.py",
3333
"tests/dedupe_test.py",
34+
"tests/announcement_banner_test.py",
35+
"tests/close_old_findings_dedupe_test.py",
36+
"tests/close_old_findings_test.py",
37+
"tests/false_positive_history_test.py",
3438
"tests/check_various_pages.py",
39+
# "tests/import_scanner_test.py",
40+
# "tests/zap.py",
3541
"tests/notifications_test.py",
3642
"tests/tool_config.py",
3743
"openapi-validatator",
44+
3845
]
3946
os: [alpine, debian]
4047
fail-fast: false

Dockerfile.django-alpine

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ RUN export PYCURL_SSL_LIBRARY=openssl && \
6767
COPY \
6868
docker/entrypoint-celery-beat.sh \
6969
docker/entrypoint-celery-worker.sh \
70+
docker/entrypoint-celery-worker-dev.sh \
7071
docker/entrypoint-initializer.sh \
7172
docker/entrypoint-first-boot.sh \
7273
docker/entrypoint-uwsgi.sh \

Dockerfile.django-debian

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ RUN export PYCURL_SSL_LIBRARY=openssl && \
7070
COPY \
7171
docker/entrypoint-celery-beat.sh \
7272
docker/entrypoint-celery-worker.sh \
73+
docker/entrypoint-celery-worker-dev.sh \
7374
docker/entrypoint-initializer.sh \
7475
docker/entrypoint-first-boot.sh \
7576
docker/entrypoint-uwsgi.sh \

docker-compose.override.dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ services:
1111
DD_ADMIN_PASSWORD: "${DD_ADMIN_PASSWORD:-admin}"
1212
DD_EMAIL_URL: "smtp://mailhog:1025"
1313
celeryworker:
14+
entrypoint: ['/wait-for-it.sh', '${DD_DATABASE_HOST:-postgres}:${DD_DATABASE_PORT:-5432}', '-t', '30', '--', '/entrypoint-celery-worker-dev.sh']
1415
volumes:
1516
- '.:/app:z'
1617
environment:

docker-compose.override.integration_tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ services:
3838
environment:
3939
DD_DATABASE_URL: ${DD_TEST_DATABASE_URL:-postgresql://defectdojo:defectdojo@postgres:5432/test_defectdojo}
4040
celeryworker:
41+
entrypoint: ['/wait-for-it.sh', '${DD_DATABASE_HOST:-postgres}:${DD_DATABASE_PORT:-5432}', '-t', '30', '--', '/entrypoint-celery-worker-dev.sh']
4142
environment:
4243
DD_DATABASE_URL: ${DD_TEST_DATABASE_URL:-postgresql://defectdojo:defectdojo@postgres:5432/test_defectdojo}
4344
initializer:
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
umask 0002
3+
4+
id
5+
6+
set -e # needed to handle "exit" correctly
7+
8+
. /secret-file-loader.sh
9+
. /reach_database.sh
10+
11+
wait_for_database_to_be_reachable
12+
echo
13+
14+
if [ "${DD_CELERY_WORKER_POOL_TYPE}" = "prefork" ]; then
15+
EXTRA_PARAMS=("--autoscale=${DD_CELERY_WORKER_AUTOSCALE_MAX},${DD_CELERY_WORKER_AUTOSCALE_MIN}"
16+
"--prefetch-multiplier=${DD_CELERY_WORKER_PREFETCH_MULTIPLIER}")
17+
else
18+
EXTRA_PARAMS=()
19+
fi
20+
21+
# do the check with Django stack
22+
python3 manage.py check
23+
24+
# hot reload using watmedo as we don't want to install celery[dev] and have that end up in our production images
25+
watchmedo auto-restart --directory=./ --pattern="*.py;*.tpl" --recursive -- \
26+
celery --app=dojo worker --loglevel="${DD_CELERY_LOG_LEVEL}" --pool="${DD_CELERY_WORKER_POOL_TYPE}" --concurrency="${DD_CELERY_WORKER_CONCURRENCY:-1}" "${EXTRA_PARAMS[@]}"

docker/entrypoint-integration-tests.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,14 @@ else
288288
# echo "Error: Zap integration test failed"; exit 1
289289
# fi
290290

291+
test="Notifications tests"
292+
echo "Running: $test"
293+
if python3 tests/notifications_test.py ; then
294+
success "$test"
295+
else
296+
fail "$test"
297+
fi
298+
291299
test="Tool Config integration tests"
292300
echo "Running: $test"
293301
if python3 tests/tool_config.py ; then

docker/entrypoint-uwsgi-dev.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ if [ "${DD_DEBUG}" = "True" ]; then
2121
DD_UWSGI_NUM_OF_THREADS=1
2222
fi
2323

24+
# hot reload also on html/template changes
25+
watchmedo shell-command \
26+
--patterns="*.html;*.tpl" \
27+
--recursive \
28+
--command='touch /app/dojo/settings/settings.py' \
29+
/app/dojo &
30+
31+
2432
exec uwsgi \
2533
"--${DD_UWSGI_MODE}" "${DD_UWSGI_ENDPOINT}" \
2634
--protocol uwsgi \
@@ -33,5 +41,5 @@ exec uwsgi \
3341
--py-autoreload 1 \
3442
--buffer-size="${DD_UWSGI_BUFFER_SIZE:-8192}" \
3543
--lazy-apps \
36-
--touch-reload="/app/dojo/setting/settings.py" \
44+
--touch-reload="/app/dojo/settings/settings.py" \
3745
--logformat "${DD_UWSGI_LOGFORMAT:-$DD_UWSGI_LOGFORMAT_DEFAULT}"

dojo/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def __wrapper__(*args, **kwargs):
155155
try:
156156
instance = model.objects.get(id=model_or_id)
157157
except model.DoesNotExist:
158-
logger.debug("error instantiating model_or_id: %s for model: %s: DoesNotExist", model_or_id, model)
158+
logger.warning("error instantiating model_or_id: %s for model: %s: DoesNotExist", model_or_id, model)
159159
instance = None
160160
args = list(args)
161161
args[parameter] = instance

dojo/filters.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,7 @@ def __init__(self, *args, **kwargs):
19751975
self.set_related_object_fields(*args, **kwargs)
19761976

19771977
def set_related_object_fields(self, *args: list, **kwargs: dict):
1978+
finding_group_query = Finding_Group.objects.all()
19781979
if self.pid is not None:
19791980
del self.form.fields["test__engagement__product"]
19801981
del self.form.fields["test__engagement__product__prod_type"]
@@ -1983,6 +1984,7 @@ def set_related_object_fields(self, *args: list, **kwargs: dict):
19831984
product_id=self.pid,
19841985
).all()
19851986
self.form.fields["test"].queryset = get_authorized_tests(Permissions.Test_View, product=self.pid).prefetch_related("test_type")
1987+
finding_group_query = Finding_Group.objects.filter(test__engagement__product_id=self.pid)
19861988
else:
19871989
self.form.fields[
19881990
"test__engagement__product__prod_type"].queryset = get_authorized_product_types(Permissions.Product_Type_View)
@@ -1992,7 +1994,7 @@ def set_related_object_fields(self, *args: list, **kwargs: dict):
19921994
if self.form.fields.get("test__engagement__product"):
19931995
self.form.fields["test__engagement__product"].queryset = get_authorized_products(Permissions.Product_View)
19941996
if self.form.fields.get("finding_group", None):
1995-
self.form.fields["finding_group"].queryset = get_authorized_finding_groups(Permissions.Finding_Group_View)
1997+
self.form.fields["finding_group"].queryset = get_authorized_finding_groups(Permissions.Finding_Group_View, queryset=finding_group_query)
19961998
self.form.fields["reporter"].queryset = get_authorized_users(Permissions.Finding_View)
19971999
self.form.fields["reviewers"].queryset = self.form.fields["reporter"].queryset
19982000

0 commit comments

Comments
 (0)