Skip to content

Commit b9ac3c5

Browse files
authored
Merge pull request #14032 from DefectDojo/bugfix
Release 2.54.0: Merge Bugfix into Dev
2 parents 801ccd4 + 94c93fd commit b9ac3c5

19 files changed

Lines changed: 745 additions & 204 deletions

.dryrunsecurity.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ sensitiveCodepaths:
5252
- 'docker/entrypoint-celery-beat.sh'
5353
- 'docker/entrypoint-celery-worker.sh'
5454
- 'docker/entrypoint-initializer.sh'
55-
- 'docker/entrypoint-first-boot.sh'
5655
- 'docker/entrypoint-nginx.sh'
5756
- 'docker/entrypoint-uwsgi.sh'
5857
- 'docker/wait-for-it.sh'

.github/workflows/validate_docs_build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
paths:
66
- 'docs/**'
7+
- '.github/workflows/*'
78

89
jobs:
910
deploy:

Dockerfile.django-alpine

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ COPY \
6969
docker/entrypoint-celery-beat.sh \
7070
docker/entrypoint-celery-worker.sh \
7171
docker/entrypoint-initializer.sh \
72-
docker/entrypoint-first-boot.sh \
7372
docker/entrypoint-uwsgi.sh \
7473
docker/wait-for-it.sh \
7574
docker/secret-file-loader.sh \

Dockerfile.django-debian

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ COPY \
7272
docker/entrypoint-celery-beat.sh \
7373
docker/entrypoint-celery-worker.sh \
7474
docker/entrypoint-initializer.sh \
75-
docker/entrypoint-first-boot.sh \
7675
docker/entrypoint-uwsgi.sh \
7776
docker/wait-for-it.sh \
7877
docker/secret-file-loader.sh \

docker-compose.override.dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ services:
33
uwsgi:
44
build:
55
context: .
6-
dockerfile: Dockerfile.django-debian
6+
dockerfile: Dockerfile.django-${DEFECT_DOJO_OS:-debian}
77
target: development
88
entrypoint: ['/wait-for-it.sh', '${DD_DATABASE_HOST:-postgres}:${DD_DATABASE_PORT:-5432}', '-t', '30', '--', '/entrypoint-uwsgi-dev.sh']
99
volumes:

docker/entrypoint-initializer.sh

Lines changed: 2 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,6 @@ set -e # needed to handle "exit" correctly
55
. /secret-file-loader.sh
66
. /reach_database.sh
77

8-
initialize_data()
9-
{
10-
# Test types shall be initialized every time by the initializer, to make sure test types are complete
11-
# when new parsers have been implemented
12-
echo "Initialization of test_types"
13-
python3 manage.py initialize_test_types
14-
15-
# Non-standard permissions cannot be created with a database migration, because the content type will only
16-
# be available after the dojo migrations
17-
echo "Creation of non-standard permissions"
18-
python3 manage.py initialize_permissions
19-
}
20-
21-
create_announcement_banner()
22-
{
23-
# Load the announcement banner
24-
if [ -z "$DD_CREATE_CLOUD_BANNER" ]; then
25-
echo "Creating Announcement Banner"
26-
cat <<EOD | python3 manage.py shell
27-
from dojo.models import Announcement, UserAnnouncement, Dojo_User
28-
announcement, created = Announcement.objects.get_or_create(id=1)
29-
announcement.message = '<a href="https://cloud.defectdojo.com/accounts/onboarding/plg_step_1" target="_blank">DefectDojo Pro Cloud and On-Premise Subscriptions Now Available! Create an account to try Pro for free!</a>'
30-
announcement.dismissable = True
31-
announcement.save()
32-
for dojo_user in Dojo_User.objects.all():
33-
user_announcments = UserAnnouncement.objects.filter(
34-
user=dojo_user,
35-
announcement=announcement)
36-
if user_announcments.count() == 0:
37-
UserAnnouncement.objects.get_or_create(
38-
user=dojo_user,
39-
announcement=announcement)
40-
EOD
41-
fi
42-
}
43-
448
# Allow for bind-mount multiple settings.py overrides
459
FILES=$(ls /app/docker/extra_settings/* 2>/dev/null || true)
4610
NUM_FILES=$(echo "$FILES" | wc -w)
@@ -56,122 +20,7 @@ fi
5620

5721
umask 0002
5822

59-
if [ "${DD_INITIALIZE}" = false ]
60-
then
61-
echo "Echo initialization skipped. Exiting."
62-
exit
63-
fi
64-
echo "Initializing."
65-
6623
wait_for_database_to_be_reachable
67-
echo
68-
69-
echo "Checking ENABLE_AUDITLOG"
70-
cat <<EOD | if ! python manage.py shell
71-
from django.db import connections, DEFAULT_DB_ALIAS
72-
from django.db.utils import ProgrammingError
73-
from dojo.settings import settings
74-
def dictfetchall(cursor):
75-
columns = [col[0] for col in cursor.description]
76-
return [dict(zip(columns, row)) for row in cursor.fetchall()]
77-
with connections[DEFAULT_DB_ALIAS].cursor() as c:
78-
try:
79-
c.execute('select * from dojo_system_settings limit 1')
80-
except ProgrammingError as e:
81-
err_msg = str(e)
82-
if "does not exist" in err_msg or "doesn't exist" in err_msg:
83-
print('Django has not been initialized. Nothing to check.')
84-
exit(0)
85-
else:
86-
raise
87-
raw_row = dictfetchall(c)[0]
88-
if 'enable_auditlog' in raw_row: # db is not migrated yet
89-
print("Database has not been migrated yet. Good we can check the latest values.")
90-
if not raw_row['enable_auditlog']:
91-
print("Auditlog has been disabled. Ok, let's check setting of environmental variable DD_ENABLE_AUDITLOG.")
92-
if settings.ENABLE_AUDITLOG:
93-
print("Misconfiguration detected")
94-
exit(47)
95-
else:
96-
print("It was disabled as well so we are good.")
97-
else:
98-
print("Auditlog has not been disabled. Good, we can continue.")
99-
else:
100-
print("Database has been already migrated. Nothing to check.")
101-
EOD
102-
then
103-
echo "You have set 'enable_auditlog' to False in the past. It is not possible to manage auditlog in System settings anymore. If you would like to keep auditlog disabled, you need to set environmental variable DD_ENABLE_AUDITLOG to False for all Django containers (uwsgi, celeryworker & initializer)."
104-
echo "Or there is some other error in checking script. Check logs of this container."
105-
exit 47
106-
fi
107-
108-
109-
python3 manage.py makemigrations --no-input --check --dry-run --verbosity 3 || {
110-
cat <<-EOF
111-
112-
********************************************************************************
113-
WARNING: Missing Database Migrations Detected
114-
********************************************************************************
115-
116-
You made changes to the models without creating a DB migration for them.
117-
118-
**NEVER** change existing migrations, create a new one.
119-
120-
If you're not familiar with migrations in Django, please read the
121-
great documentation thoroughly:
122-
https://docs.djangoproject.com/en/5.0/topics/migrations/
24+
python manage.py complete_initialization
12325

124-
This is now a WARNING and the container will continue to start.
125-
However, you should create the necessary migrations as soon as possible using:
126-
docker compose exec uwsgi bash -c 'python manage.py makemigrations -v2'
127-
128-
********************************************************************************
129-
130-
EOF
131-
echo "WARNING: Continuing startup despite missing migrations..."
132-
}
133-
134-
echo "Migrating"
135-
python3 manage.py migrate
136-
137-
echo "Configuring pghistory triggers based on audit settings"
138-
cat <<EOD | python3 manage.py shell
139-
from dojo.auditlog import configure_pghistory_triggers
140-
configure_pghistory_triggers()
141-
EOD
142-
143-
echo "Admin user: ${DD_ADMIN_USER}"
144-
ADMIN_EXISTS=$(echo "SELECT * from auth_user;" | python manage.py dbshell | grep "${DD_ADMIN_USER}" || true)
145-
# Abort if the admin user already exists, instead of giving a new fake password that won't work
146-
if [ -n "$ADMIN_EXISTS" ]
147-
then
148-
echo "Admin password: Initialization detected that the admin user ${DD_ADMIN_USER} already exists in your database."
149-
echo "If you don't remember the ${DD_ADMIN_USER} password, you can create a new superuser with:"
150-
echo "$ docker compose exec uwsgi /bin/bash -c 'python manage.py createsuperuser'"
151-
create_announcement_banner
152-
initialize_data
153-
exit
154-
fi
155-
156-
if [ -z "${DD_ADMIN_PASSWORD}" ]
157-
then
158-
DD_ADMIN_PASSWORD="$(LC_ALL=C tr -dc a-zA-Z0-9 < /dev/urandom | \
159-
head -c 22)"
160-
export DD_ADMIN_PASSWORD
161-
echo "Admin password: ${DD_ADMIN_PASSWORD}"
162-
fi
163-
164-
if [ -z "${DD_JIRA_WEBHOOK_SECRET}" ]
165-
then
166-
DD_JIRA_WEBHOOK_SECRET="$(uuidgen)"
167-
export DD_JIRA_WEBHOOK_SECRET
168-
echo "JIRA Webhook Secret: ${DD_JIRA_WEBHOOK_SECRET}"
169-
fi
170-
171-
if [ -z "${ADMIN_EXISTS}" ]
172-
then
173-
. /entrypoint-first-boot.sh
174-
175-
create_announcement_banner
176-
initialize_data
177-
fi
26+
exec "$@"
120 KB
Loading
49 KB
Loading

docs/config/_default/hugo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ copyRight = "Copyright (c) 2020-2024 Thulite"
2222
enable = true
2323

2424
[outputs]
25-
home = ["HTML", "RSS", "searchIndex"]
25+
home = ["HTML", "RSS", "searchIndex", "SITEMAP"]
2626
section = ["HTML", "RSS", "SITEMAP"]
2727

2828
[outputFormats.searchIndex]
@@ -41,7 +41,7 @@ copyRight = "Copyright (c) 2020-2024 Thulite"
4141
rel = "sitemap"
4242

4343
[sitemap]
44-
changefreq = "monthly"
44+
changefreq = "weekly"
4545
filename = "sitemap.xml"
4646
priority = 0.5
4747

docs/content/_index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "DefectDojo Documentation"
3+
date: 2021-02-02T20:46:29+01:00
4+
draft: false
5+
---

0 commit comments

Comments
 (0)