You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docker/entrypoint-initializer.sh
+2-153Lines changed: 2 additions & 153 deletions
Original file line number
Diff line number
Diff line change
@@ -5,42 +5,6 @@ set -e # needed to handle "exit" correctly
5
5
. /secret-file-loader.sh
6
6
. /reach_database.sh
7
7
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>'
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."
0 commit comments