-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsettings.dist.py
1337 lines (1184 loc) · 56.4 KB
/
settings.dist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Django settings for DefectDojo
import os
from datetime import timedelta
from celery.schedules import crontab
from dojo import __version__
import environ
root = environ.Path(__file__) - 3 # Three folders back
# reference: https://pypi.org/project/django-environ/
env = environ.Env(
# Set casting and default values
DD_SITE_URL=(str, 'https://localhost:8080'),
DD_DEBUG=(bool, False),
DD_TEMPLATE_DEBUG=(bool, False),
DD_LOG_LEVEL=(str, ''),
DD_DJANGO_METRICS_ENABLED=(bool, False),
DD_LOGIN_REDIRECT_URL=(str, '/'),
DD_LOGIN_URL=(str, '/login'),
DD_DJANGO_ADMIN_ENABLED=(bool, True),
DD_SESSION_COOKIE_HTTPONLY=(bool, True),
DD_CSRF_COOKIE_HTTPONLY=(bool, True),
DD_SECURE_SSL_REDIRECT=(bool, False),
DD_SECURE_CROSS_ORIGIN_OPENER_POLICY=(str, 'same-origin'),
DD_SECURE_HSTS_INCLUDE_SUBDOMAINS=(bool, False),
DD_SECURE_HSTS_SECONDS=(int, 31536000), # One year expiration
DD_SESSION_COOKIE_SECURE=(bool, False),
DD_SESSION_EXPIRE_AT_BROWSER_CLOSE=(bool, False),
DD_SESSION_COOKIE_AGE=(int, 1209600), # 14 days
DD_CSRF_COOKIE_SECURE=(bool, False),
DD_SECURE_BROWSER_XSS_FILTER=(bool, True),
DD_SECURE_CONTENT_TYPE_NOSNIFF=(bool, True),
DD_TIME_ZONE=(str, 'UTC'),
DD_LANG=(str, 'en-us'),
DD_TEAM_NAME=(str, 'Security Team'),
DD_ADMINS=(str, 'DefectDojo:dojo@localhost,Admin:admin@localhost'),
DD_WHITENOISE=(bool, False),
DD_TRACK_MIGRATIONS=(bool, True),
DD_SECURE_PROXY_SSL_HEADER=(bool, False),
DD_TEST_RUNNER=(str, 'django.test.runner.DiscoverRunner'),
DD_URL_PREFIX=(str, ''),
DD_ROOT=(str, root('dojo')),
DD_LANGUAGE_CODE=(str, 'en-us'),
DD_SITE_ID=(int, 1),
DD_USE_I18N=(bool, True),
DD_USE_L10N=(bool, True),
DD_USE_TZ=(bool, True),
DD_MEDIA_URL=(str, '/media/'),
DD_MEDIA_ROOT=(str, root('media')),
DD_STATIC_URL=(str, '/static/'),
DD_STATIC_ROOT=(str, root('static')),
DD_CELERY_BROKER_URL=(str, ''),
DD_CELERY_BROKER_SCHEME=(str, 'sqla+sqlite'),
DD_CELERY_BROKER_USER=(str, ''),
DD_CELERY_BROKER_PASSWORD=(str, ''),
DD_CELERY_BROKER_HOST=(str, ''),
DD_CELERY_BROKER_PORT=(int, -1),
DD_CELERY_BROKER_PATH=(str, '/dojo.celerydb.sqlite'),
DD_CELERY_BROKER_PARAMS=(str, ''),
DD_CELERY_TASK_IGNORE_RESULT=(bool, True),
DD_CELERY_RESULT_BACKEND=(str, 'django-db'),
DD_CELERY_RESULT_EXPIRES=(int, 86400),
DD_CELERY_BEAT_SCHEDULE_FILENAME=(str, root('dojo.celery.beat.db')),
DD_CELERY_TASK_SERIALIZER=(str, 'pickle'),
DD_CELERY_PASS_MODEL_BY_ID=(str, True),
DD_FOOTER_VERSION=(str, ''),
# models should be passed to celery by ID, default is False (for now)
DD_FORCE_LOWERCASE_TAGS=(bool, True),
DD_MAX_TAG_LENGTH=(int, 25),
DD_DATABASE_ENGINE=(str, 'django.db.backends.postgresql'),
DD_DATABASE_HOST=(str, 'bhadra-postgresql-1'),
DD_DATABASE_NAME=(str, 'defectdojo'),
# default django database name for testing is test_<dbname>
DD_TEST_DATABASE_NAME=(str, 'test_defectdojo'),
DD_DATABASE_PASSWORD=(str, 'defectdojo'),
DD_DATABASE_PORT=(int, 3306),
DD_DATABASE_USER=(str, 'defectdojo'),
DD_SECRET_KEY=(str, ''),
DD_CREDENTIAL_AES_256_KEY=(str, '.'),
DD_DATA_UPLOAD_MAX_MEMORY_SIZE=(int, 8388608), # Max post size set to 8mb
DD_SOCIAL_AUTH_SHOW_LOGIN_FORM=(bool, True), # do we show user/pass input
DD_SOCIAL_LOGIN_AUTO_REDIRECT=(bool, True), # auto-redirect if there is only one social login method
DD_SOCIAL_AUTH_TRAILING_SLASH=(bool, True),
DD_SOCIAL_AUTH_AUTH0_OAUTH2_ENABLED=(bool, False),
DD_SOCIAL_AUTH_AUTH0_KEY=(str, ''),
DD_SOCIAL_AUTH_AUTH0_SECRET=(str, ''),
DD_SOCIAL_AUTH_AUTH0_DOMAIN=(str, ''),
DD_SOCIAL_AUTH_AUTH0_SCOPE=(list, ['openid', 'profile', 'email']),
DD_SOCIAL_AUTH_GOOGLE_OAUTH2_ENABLED=(bool, False),
DD_SOCIAL_AUTH_GOOGLE_OAUTH2_KEY=(str, ''),
DD_SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET=(str, ''),
DD_SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS=(list, ['']),
DD_SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_EMAILS=(list, ['']),
DD_SOCIAL_AUTH_OKTA_OAUTH2_ENABLED=(bool, False),
DD_SOCIAL_AUTH_OKTA_OAUTH2_KEY=(str, ''),
DD_SOCIAL_AUTH_OKTA_OAUTH2_SECRET=(str, ''),
DD_SOCIAL_AUTH_OKTA_OAUTH2_API_URL=(str, 'https://{your-org-url}/oauth2/default'),
DD_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_ENABLED=(bool, False),
DD_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_KEY=(str, ''),
DD_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_SECRET=(str, ''),
DD_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_TENANT_ID=(str, ''),
DD_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_RESOURCE=(str, 'https://graph.microsoft.com/'),
DD_SOCIAL_AUTH_GITLAB_OAUTH2_ENABLED=(bool, False),
DD_SOCIAL_AUTH_GITLAB_PROJECT_AUTO_IMPORT=(bool, False),
DD_SOCIAL_AUTH_GITLAB_PROJECT_IMPORT_TAGS=(bool, False),
DD_SOCIAL_AUTH_GITLAB_PROJECT_IMPORT_URL=(bool, False),
DD_SOCIAL_AUTH_GITLAB_PROJECT_MIN_ACCESS_LEVEL=(int, 20),
DD_SOCIAL_AUTH_GITLAB_KEY=(str, ''),
DD_SOCIAL_AUTH_GITLAB_SECRET=(str, ''),
DD_SOCIAL_AUTH_GITLAB_API_URL=(str, 'https://gitlab.com'),
DD_SOCIAL_AUTH_GITLAB_SCOPE=(list, ['api', 'read_user', 'openid', 'profile', 'email']),
DD_SAML2_ENABLED=(bool, False),
DD_SAML2_METADATA_AUTO_CONF_URL=(str, ''),
DD_SAML2_METADATA_LOCAL_FILE_PATH=(str, ''),
DD_SAML2_ASSERTION_URL=(str, ''),
DD_SAML2_ENTITY_ID=(str, ''),
DD_SAML2_LOGOUT_URL=(str, ''),
DD_SAML2_DEFAULT_NEXT_URL=(str, ''),
DD_SAML2_CREATE_USER=(bool, True),
DD_SAML2_NEW_USER_PROFILE=(dict, {
# The default group name when a new user logs in
'USER_GROUPS': ['dev'],
# The default active status for new users
'ACTIVE_STATUS': True,
# The staff status for new users
'STAFF_STATUS': False,
# The superuser status for new users
'SUPERUSER_STATUS': False,
}),
DD_SAML2_ATTRIBUTES_MAP=(dict, {
# Change Email/UserName/FirstName/LastName to corresponding SAML2 userprofile attributes.
'emailAddress': 'email',
'emailAddress': 'username',
'Firstname': 'first_name',
'Lastname': 'last_name',
}),
DD_SAML2_ALLOW_UNKNOWN_ATTRIBUTE=(bool, False),
# merging findings doesn't always work well with dedupe and reimport etc.
# disable it if you see any issues (and report them on github)
DD_DISABLE_FINDING_MERGE=(bool, False),
# Set to True if you want to allow authorized users to make changes to findings or delete them
# These parameters are only used for the legacy authorization, which is not active per default anymore.
DD_AUTHORIZED_USERS_ALLOW_CHANGE=(bool, False),
DD_AUTHORIZED_USERS_ALLOW_DELETE=(bool, False),
# Set to True if you want to allow authorized users staff access only on specific products
# This will only apply to users with 'active' status
# This parameter is only used for the legacy authorization, which is not active per default anymore.
DD_AUTHORIZED_USERS_ALLOW_STAFF=(bool, False),
# SLA Notifications via alerts and JIRA comments
# enable either DD_SLA_NOTIFY_ACTIVE or DD_SLA_NOTIFY_ACTIVE_VERIFIED_ONLY to enable the feature
DD_SLA_NOTIFY_ACTIVE=(bool, False),
DD_SLA_NOTIFY_ACTIVE_VERIFIED_ONLY=(bool, False),
# finetuning settings for when enabled
DD_SLA_NOTIFY_WITH_JIRA_ONLY=(bool, False),
DD_SLA_NOTIFY_PRE_BREACH=(int, 3),
DD_SLA_NOTIFY_POST_BREACH=(int, 7),
# maximum number of result in search as search can be an expensive operation
DD_SEARCH_MAX_RESULTS=(int, 100),
DD_SIMILAR_FINDINGS_MAX_RESULTS=(int, 25),
DD_MAX_AUTOCOMPLETE_WORDS=(int, 20000),
DD_JIRA_SSL_VERIFY=(bool, True),
# if you want to keep logging to the console but in json format, change this here to 'json_console'
DD_LOGGING_HANDLER=(str, 'console'),
DD_ALERT_REFRESH=(bool, True),
DD_DISABLE_ALERT_COUNTER=(bool, False),
# to disable deleting alerts per user set value to -1
DD_MAX_ALERTS_PER_USER=(int, 999),
DD_TAG_PREFETCHING=(bool, True),
DD_QUALYS_WAS_WEAKNESS_IS_VULN=(bool, False),
# when enabled in sytem settings, every minute a job run to delete excess duplicates
# we limit the amount of duplicates that can be deleted in a single run of that job
# to prevent overlapping runs of that job from occurrring
DD_DUPE_DELETE_MAX_PER_RUN=(int, 200),
# APIv1 is depreacted and will be removed at 2021-06-30
DD_LEGACY_API_V1_ENABLE=(bool, False),
# when enabled 'mitigated date' and 'mitigated by' of a finding become editable
DD_EDITABLE_MITIGATED_DATA=(bool, False),
# new feature that tracks history across multiple reimports for the same test
DD_TRACK_IMPORT_HISTORY=(bool, True),
# Feature toggle for new authorization, which is the default configuration now.
DD_FEATURE_AUTHORIZATION_V2=(bool, True),
# When enabled, staff users have full access to all product types and products
DD_AUTHORIZATION_STAFF_OVERRIDE=(bool, False),
# Allow grouping of findings in the same test, for example to group findings per dependency
DD_FEATURE_FINDING_GROUPS=(bool, True),
DD_JIRA_TEMPLATE_ROOT=(str, 'dojo/templates/issue-trackers'),
DD_TEMPLATE_DIR_PREFIX=(str, 'dojo/templates/'),
# Initial behaviour in Defect Dojo was to delete all duplicates when an original was deleted
# New behaviour is to leave the duplicates in place, but set the oldest of duplicates as new original
# Set to True to revert to the old behaviour where all duplicates are deleted
DD_DUPLICATE_CLUSTER_CASCADE_DELETE=(str, False),
# Enable Rate Limiting for the login page
DD_RATE_LIMITER_ENABLED=(bool, False),
# Examples include 5/m 100/h and more https://django-ratelimit.readthedocs.io/en/stable/rates.html#simple-rates
DD_RATE_LIMITER_RATE=(str, '5/m'),
# Block the requests after rate limit is exceeded
DD_RATE_LIMITER_BLOCK=(bool, False),
# Forces the user to change password on next login.
DD_RATE_LIMITER_ACCOUNT_LOCKOUT=(bool, False),
)
def generate_url(scheme, double_slashes, user, password, host, port, path, params):
result_list = []
result_list.append(scheme)
result_list.append(':')
if double_slashes:
result_list.append('//')
result_list.append(user)
if len(password) > 0:
result_list.append(':')
result_list.append(password)
if len(user) > 0 or len(password) > 0:
result_list.append('@')
result_list.append(host)
if port >= 0:
result_list.append(':')
result_list.append(str(port))
if len(path) > 0 and path[0] != '/':
result_list.append('/')
result_list.append(path)
if len(params) > 0 and params[0] != '?':
result_list.append('?')
result_list.append(params)
return ''.join(result_list)
# Read .env file as default or from the command line, DD_ENV_PATH
if os.path.isfile(root('dojo/settings/.env.prod')) or 'DD_ENV_PATH' in os.environ:
env.read_env(root('dojo/settings/' + env.str('DD_ENV_PATH', '.env.prod')))
# ------------------------------------------------------------------------------
# GENERAL
# ------------------------------------------------------------------------------
# False if not in os.environ
DEBUG = env('DD_DEBUG')
TEMPLATE_DEBUG = env('DD_TEMPLATE_DEBUG')
# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/2.0/ref/settings/#allowed-hosts
SITE_URL = env('DD_SITE_URL')
ALLOWED_HOSTS = tuple(env.list('DD_ALLOWED_HOSTS', default=['localhost', '127.0.0.1']))
# Raises django's ImproperlyConfigured exception if SECRET_KEY not in os.environ
SECRET_KEY = env('DD_SECRET_KEY')
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = env('DD_TIME_ZONE')
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = env('DD_LANGUAGE_CODE')
SITE_ID = env('DD_SITE_ID')
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = env('DD_USE_I18N')
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = env('DD_USE_L10N')
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = env('DD_USE_TZ')
TEST_RUNNER = env('DD_TEST_RUNNER')
ALERT_REFRESH = env('DD_ALERT_REFRESH')
DISABLE_ALERT_COUNTER = env("DD_DISABLE_ALERT_COUNTER")
MAX_ALERTS_PER_USER = env("DD_MAX_ALERTS_PER_USER")
TAG_PREFETCHING = env('DD_TAG_PREFETCHING')
# ------------------------------------------------------------------------------
# DATABASE
# ------------------------------------------------------------------------------
# Parse database connection url strings like psql://user:[email protected]:8458/db
if os.getenv('DD_DATABASE_URL') is not None:
DATABASES = {
'default': env.db('DD_DATABASE_URL')
}
else:
DATABASES = {
'default': {
'ENGINE': env('DD_DATABASE_ENGINE'),
'NAME': env('DD_DATABASE_NAME'),
'TEST': {
'NAME': env('DD_TEST_DATABASE_NAME'),
},
'USER': env('DD_DATABASE_USER'),
'PASSWORD': env('DD_DATABASE_PASSWORD'),
'HOST': env('DD_DATABASE_HOST'),
'PORT': env('DD_DATABASE_PORT'),
}
}
# Track migrations through source control rather than making migrations locally
if env('DD_TRACK_MIGRATIONS'):
MIGRATION_MODULES = {'dojo': 'dojo.db_migrations'}
# Default for automatically created id fields,
# see https://docs.djangoproject.com/en/3.2/releases/3.2/#customizing-type-of-auto-created-primary-keys
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
# ------------------------------------------------------------------------------
# MEDIA
# ------------------------------------------------------------------------------
DOJO_ROOT = env('DD_ROOT')
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = env('DD_MEDIA_ROOT')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = env('DD_MEDIA_URL')
# ------------------------------------------------------------------------------
# STATIC
# ------------------------------------------------------------------------------
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = env('DD_STATIC_ROOT')
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = env('DD_STATIC_URL')
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(os.path.dirname(DOJO_ROOT), 'components', 'node_modules'),
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
FILE_UPLOAD_HANDLERS = (
"django.core.files.uploadhandler.TemporaryFileUploadHandler",
)
DATA_UPLOAD_MAX_MEMORY_SIZE = env('DD_DATA_UPLOAD_MAX_MEMORY_SIZE')
# ------------------------------------------------------------------------------
# URLS
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
# AUTHENTICATION_BACKENDS = [
# 'axes.backends.AxesModelBackend',
# ]
ROOT_URLCONF = 'dojo.urls'
# Python dotted path to the WSGI application used by Django's runserver.
# https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
WSGI_APPLICATION = 'dojo.wsgi.application'
URL_PREFIX = env('DD_URL_PREFIX')
# ------------------------------------------------------------------------------
# AUTHENTICATION
# ------------------------------------------------------------------------------
LOGIN_REDIRECT_URL = env('DD_LOGIN_REDIRECT_URL')
LOGIN_URL = env('DD_LOGIN_URL')
# These are the individidual modules supported by social-auth
AUTHENTICATION_BACKENDS = (
'social_core.backends.auth0.Auth0OAuth2',
'social_core.backends.google.GoogleOAuth2',
'dojo.okta.OktaOAuth2',
'social_core.backends.azuread_tenant.AzureADTenantOAuth2',
'social_core.backends.gitlab.GitLabOAuth2',
'django.contrib.auth.backends.RemoteUserBackend',
'django.contrib.auth.backends.ModelBackend',
)
SOCIAL_AUTH_PIPELINE = (
'social_core.pipeline.social_auth.social_details',
'dojo.pipeline.social_uid',
'social_core.pipeline.social_auth.auth_allowed',
'social_core.pipeline.social_auth.social_user',
'social_core.pipeline.user.get_username',
'social_core.pipeline.social_auth.associate_by_email',
'social_core.pipeline.user.create_user',
'dojo.pipeline.modify_permissions',
'social_core.pipeline.social_auth.associate_user',
'social_core.pipeline.social_auth.load_extra_data',
'social_core.pipeline.user.user_details',
'dojo.pipeline.update_product_access',
)
CLASSIC_AUTH_ENABLED = True
# Showing login form (form is not needed for external auth: OKTA, Google Auth, etc.)
SHOW_LOGIN_FORM = env('DD_SOCIAL_AUTH_SHOW_LOGIN_FORM')
SOCIAL_LOGIN_AUTO_REDIRECT = env('DD_SOCIAL_LOGIN_AUTO_REDIRECT')
SOCIAL_AUTH_STRATEGY = 'social_django.strategy.DjangoStrategy'
SOCIAL_AUTH_STORAGE = 'social_django.models.DjangoStorage'
SOCIAL_AUTH_ADMIN_USER_SEARCH_FIELDS = ['username', 'first_name', 'last_name', 'email']
SOCIAL_AUTH_USERNAME_IS_FULL_EMAIL = True
GOOGLE_OAUTH_ENABLED = env('DD_SOCIAL_AUTH_GOOGLE_OAUTH2_ENABLED')
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = env('DD_SOCIAL_AUTH_GOOGLE_OAUTH2_KEY')
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = env('DD_SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET')
SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS = env('DD_SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS')
SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_EMAILS = env('DD_SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_EMAILS')
SOCIAL_AUTH_LOGIN_ERROR_URL = '/login'
SOCIAL_AUTH_BACKEND_ERROR_URL = '/login'
OKTA_OAUTH_ENABLED = env('DD_SOCIAL_AUTH_OKTA_OAUTH2_ENABLED')
SOCIAL_AUTH_OKTA_OAUTH2_KEY = env('DD_SOCIAL_AUTH_OKTA_OAUTH2_KEY')
SOCIAL_AUTH_OKTA_OAUTH2_SECRET = env('DD_SOCIAL_AUTH_OKTA_OAUTH2_SECRET')
SOCIAL_AUTH_OKTA_OAUTH2_API_URL = env('DD_SOCIAL_AUTH_OKTA_OAUTH2_API_URL')
AZUREAD_TENANT_OAUTH2_ENABLED = env('DD_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_ENABLED')
SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_KEY = env('DD_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_KEY')
SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_SECRET = env('DD_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_SECRET')
SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_TENANT_ID = env('DD_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_TENANT_ID')
SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_RESOURCE = env('DD_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_RESOURCE')
GITLAB_OAUTH2_ENABLED = env('DD_SOCIAL_AUTH_GITLAB_OAUTH2_ENABLED')
GITLAB_PROJECT_AUTO_IMPORT = env('DD_SOCIAL_AUTH_GITLAB_PROJECT_AUTO_IMPORT')
GITLAB_PROJECT_IMPORT_TAGS = env('DD_SOCIAL_AUTH_GITLAB_PROJECT_IMPORT_TAGS')
GITLAB_PROJECT_IMPORT_URL = env('DD_SOCIAL_AUTH_GITLAB_PROJECT_IMPORT_URL')
GITLAB_PROJECT_MIN_ACCESS_LEVEL = env('DD_SOCIAL_AUTH_GITLAB_PROJECT_MIN_ACCESS_LEVEL')
SOCIAL_AUTH_GITLAB_KEY = env('DD_SOCIAL_AUTH_GITLAB_KEY')
SOCIAL_AUTH_GITLAB_SECRET = env('DD_SOCIAL_AUTH_GITLAB_SECRET')
SOCIAL_AUTH_GITLAB_API_URL = env('DD_SOCIAL_AUTH_GITLAB_API_URL')
SOCIAL_AUTH_GITLAB_SCOPE = env('DD_SOCIAL_AUTH_GITLAB_SCOPE')
AUTH0_OAUTH2_ENABLED = env('DD_SOCIAL_AUTH_AUTH0_OAUTH2_ENABLED')
SOCIAL_AUTH_AUTH0_KEY = env('DD_SOCIAL_AUTH_AUTH0_KEY')
SOCIAL_AUTH_AUTH0_SECRET = env('DD_SOCIAL_AUTH_AUTH0_SECRET')
SOCIAL_AUTH_AUTH0_DOMAIN = env('DD_SOCIAL_AUTH_AUTH0_DOMAIN')
SOCIAL_AUTH_AUTH0_SCOPE = env('DD_SOCIAL_AUTH_AUTH0_SCOPE')
SOCIAL_AUTH_TRAILING_SLASH = env('DD_SOCIAL_AUTH_TRAILING_SLASH')
# For more configuration and customization options, see django-saml2-auth documentation
# https://github.com/fangli/django-saml2-auth
SAML2_ENABLED = env('DD_SAML2_ENABLED')
SAML2_LOGOUT_URL = env('DD_SAML2_LOGOUT_URL')
SAML2_AUTH = {
'ASSERTION_URL': env('DD_SAML2_ASSERTION_URL'),
'ENTITY_ID': env('DD_SAML2_ENTITY_ID'),
# Optional settings below
'DEFAULT_NEXT_URL': env('DD_SAML2_DEFAULT_NEXT_URL'),
'NEW_USER_PROFILE': env('DD_SAML2_NEW_USER_PROFILE'),
'ATTRIBUTES_MAP': env('DD_SAML2_ATTRIBUTES_MAP'),
}
# Metadata is required, choose either remote url or local file path
SAML2_AUTH['METADATA_AUTO_CONF_URL'] = 'https://login.microsoftonline.com/1b9f208d-686e-4c09-876f-faac935b2a53/federationmetadata/2007-06/federationmetadata.xml?appid=f409b699-35a0-4e41-b599-c905d0d87a21'
AUTHORIZED_USERS_ALLOW_CHANGE = env('DD_AUTHORIZED_USERS_ALLOW_CHANGE')
AUTHORIZED_USERS_ALLOW_DELETE = env('DD_AUTHORIZED_USERS_ALLOW_DELETE')
AUTHORIZED_USERS_ALLOW_STAFF = env('DD_AUTHORIZED_USERS_ALLOW_STAFF')
# Setting SLA_NOTIFY_ACTIVE and SLA_NOTIFY_ACTIVE_VERIFIED to False will disable the feature
# If you import thousands of Active findings through your pipeline everyday,
# and make the choice of enabling SLA notifications for non-verified findings,
# be mindful of performance.
SLA_NOTIFY_ACTIVE = env('DD_SLA_NOTIFY_ACTIVE') # this will include 'verified' findings as well as non-verified.
SLA_NOTIFY_ACTIVE_VERIFIED_ONLY = env('DD_SLA_NOTIFY_ACTIVE_VERIFIED_ONLY')
SLA_NOTIFY_WITH_JIRA_ONLY = env('DD_SLA_NOTIFY_WITH_JIRA_ONLY') # Based on the 2 above, but only with a JIRA link
SLA_NOTIFY_PRE_BREACH = env('DD_SLA_NOTIFY_PRE_BREACH') # in days, notify between dayofbreach minus this number until dayofbreach
SLA_NOTIFY_POST_BREACH = env('DD_SLA_NOTIFY_POST_BREACH') # in days, skip notifications for findings that go past dayofbreach plus this number
SEARCH_MAX_RESULTS = env('DD_SEARCH_MAX_RESULTS')
SIMILAR_FINDINGS_MAX_RESULTS = env('DD_SIMILAR_FINDINGS_MAX_RESULTS')
MAX_AUTOCOMPLETE_WORDS = env('DD_MAX_AUTOCOMPLETE_WORDS')
LOGIN_EXEMPT_URLS = (
r'^%sstatic/' % URL_PREFIX,
r'^%swebhook/([\w-]+)$' % URL_PREFIX,
r'^%swebhook/' % URL_PREFIX,
r'^%sjira/webhook/([\w-]+)$' % URL_PREFIX,
r'^%sjira/webhook/' % URL_PREFIX,
r'^%sreports/cover$' % URL_PREFIX,
r'^%sfinding/image/(?P<token>[^/]+)$' % URL_PREFIX,
r'^%sapi/v2/' % URL_PREFIX,
r'complete/',
r'empty_questionnaire/([\d]+)/answer',
r'adminlogin'
)
LEGACY_API_V1_ENABLE = env('DD_LEGACY_API_V1_ENABLE')
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
'OPTIONS': {
'min_length': 9,
}
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'dojo.user.validators.NumberValidator'
},
{
'NAME': 'dojo.user.validators.UppercaseValidator'
},
{
'NAME': 'dojo.user.validators.LowercaseValidator'
},
{
'NAME': 'dojo.user.validators.SymbolValidator'
}
]
# https://django-ratelimit.readthedocs.io/en/stable/index.html
RATE_LIMITER_ENABLED = env('DD_RATE_LIMITER_ENABLED')
RATE_LIMITER_RATE = env('DD_RATE_LIMITER_RATE') # Examples include 5/m 100/h and more https://django-ratelimit.readthedocs.io/en/stable/rates.html#simple-rates
RATE_LIMITER_BLOCK = env('DD_RATE_LIMITER_BLOCK') # Block the requests after rate limit is exceeded
RATE_LIMITER_ACCOUNT_LOCKOUT = env('DD_RATE_LIMITER_ACCOUNT_LOCKOUT') # Forces the user to change password on next login.
# ------------------------------------------------------------------------------
# SECURITY DIRECTIVES
# ------------------------------------------------------------------------------
# If True, the SecurityMiddleware redirects all non-HTTPS requests to HTTPS
# (except for those URLs matching a regular expression listed in SECURE_REDIRECT_EXEMPT).
SECURE_SSL_REDIRECT = env('DD_SECURE_SSL_REDIRECT')
# If True, the SecurityMiddleware sets the X-XSS-Protection: 1;
# mode=block header on all responses that do not already have it.
SECURE_BROWSER_XSS_FILTER = env('DD_SECURE_BROWSER_XSS_FILTER')
# If True, the SecurityMiddleware sets the X-Content-Type-Options: nosniff;
SECURE_CONTENT_TYPE_NOSNIFF = env('DD_SECURE_CONTENT_TYPE_NOSNIFF')
# Whether to use HTTPOnly flag on the session cookie.
# If this is set to True, client-side JavaScript will not to be able to access the session cookie.
SESSION_COOKIE_HTTPONLY = env('DD_SESSION_COOKIE_HTTPONLY')
# Whether to use HttpOnly flag on the CSRF cookie. If this is set to True,
# client-side JavaScript will not to be able to access the CSRF cookie.
CSRF_COOKIE_HTTPONLY = env('DD_CSRF_COOKIE_HTTPONLY')
# Whether to use a secure cookie for the session cookie. If this is set to True,
# the cookie will be marked as secure, which means browsers may ensure that the
# cookie is only sent with an HTTPS connection.
SESSION_COOKIE_SECURE = env('DD_SESSION_COOKIE_SECURE')
# Whether to use a secure cookie for the CSRF cookie.
CSRF_COOKIE_SECURE = env('DD_CSRF_COOKIE_SECURE')
SECURE_CROSS_ORIGIN_OPENER_POLICY = env('DD_SECURE_CROSS_ORIGIN_OPENER_POLICY') if env('DD_SECURE_CROSS_ORIGIN_OPENER_POLICY') != 'None' else None
if env('DD_SECURE_PROXY_SSL_HEADER'):
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
if env('DD_SECURE_HSTS_INCLUDE_SUBDOMAINS'):
SECURE_HSTS_SECONDS = env('DD_SECURE_HSTS_SECONDS')
SECURE_HSTS_INCLUDE_SUBDOMAINS = env('DD_SECURE_HSTS_INCLUDE_SUBDOMAINS')
SESSION_EXPIRE_AT_BROWSER_CLOSE = env('DD_SESSION_EXPIRE_AT_BROWSER_CLOSE')
SESSION_COOKIE_AGE = env('DD_SESSION_COOKIE_AGE')
# ------------------------------------------------------------------------------
# DEFECTDOJO SPECIFIC
# ------------------------------------------------------------------------------
# Credential Key
CREDENTIAL_AES_256_KEY = env('DD_CREDENTIAL_AES_256_KEY')
DB_KEY = env('DD_CREDENTIAL_AES_256_KEY')
# Used in a few places to prefix page headings and in email salutations
TEAM_NAME = env('DD_TEAM_NAME')
# Used to configure a custom version in the footer of the base.html template.
FOOTER_VERSION = env('DD_FOOTER_VERSION')
# Django-tagging settings
FORCE_LOWERCASE_TAGS = env('DD_FORCE_LOWERCASE_TAGS')
MAX_TAG_LENGTH = env('DD_MAX_TAG_LENGTH')
# ------------------------------------------------------------------------------
# ADMIN
# ------------------------------------------------------------------------------
from email.utils import getaddresses
ADMINS = getaddresses([env('DD_ADMINS')])
# https://docs.djangoproject.com/en/dev/ref/settings/#managers
MANAGERS = ADMINS
# Django admin enabled
DJANGO_ADMIN_ENABLED = env('DD_DJANGO_ADMIN_ENABLED')
# ------------------------------------------------------------------------------
# API V2
# ------------------------------------------------------------------------------
REST_FRAMEWORK = {
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.BasicAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.DjangoModelPermissions',
),
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
),
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
'PAGE_SIZE': 25,
'EXCEPTION_HANDLER': 'dojo.api_v2.exception_handler.custom_exception_handler'
}
SWAGGER_SETTINGS = {
'SECURITY_DEFINITIONS': {
'api_key': {
'type': 'apiKey',
'in': 'header',
'name': 'Authorization'
}
},
'DOC_EXPANSION': "none",
'JSON_EDITOR': True,
'SHOW_REQUEST_HEADERS': True,
}
SPECTACULAR_SETTINGS = {
'TITLE': 'Defect Dojo API v2',
'DESCRIPTION': 'Defect Dojo - Open Source vulnerability Management made easy. Prefetch related parameters/responses not yet in the schema.',
'VERSION': __version__,
# OTHER SETTINGS
# the following set to False could help some client generators
# 'ENUM_ADD_EXPLICIT_BLANK_NULL_CHOICE': False,
'POSTPROCESSING_HOOKS': ['dojo.api_v2.prefetch.schema.prefetch_postprocessing_hook']
}
# ------------------------------------------------------------------------------
# TEMPLATES
# ------------------------------------------------------------------------------
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'OPTIONS': {
'debug': env('DD_DEBUG'),
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'social_django.context_processors.backends',
'social_django.context_processors.login_redirect',
'dojo.context_processors.globalize_oauth_vars',
'dojo.context_processors.bind_system_settings',
'dojo.context_processors.bind_alert_count',
],
},
},
]
# ------------------------------------------------------------------------------
# APPS
# ------------------------------------------------------------------------------
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'polymorphic', # provides admin templates
'django.contrib.admin',
'django.contrib.humanize',
'gunicorn',
'auditlog',
'dojo',
'watson',
'tagging', # not used, but still needed for migration 0065_django_tagulous.py (v1.10.0)
'imagekit',
'multiselectfield',
'rest_framework',
'rest_framework.authtoken',
'dbbackup',
'django_celery_results',
'social_django',
'drf_yasg',
'drf_spectacular',
'tagulous'
)
# ------------------------------------------------------------------------------
# MIDDLEWARE
# ------------------------------------------------------------------------------
DJANGO_MIDDLEWARE_CLASSES = [
'django.middleware.common.CommonMiddleware',
'dojo.middleware.DojoSytemSettingsMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'dojo.middleware.LoginRequiredMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware',
'watson.middleware.SearchContextMiddleware',
'auditlog.middleware.AuditlogMiddleware',
'crum.CurrentRequestUserMiddleware',
'dojo.request_cache.middleware.RequestCacheMiddleware',
]
MIDDLEWARE = DJANGO_MIDDLEWARE_CLASSES
# WhiteNoise allows your web app to serve its own static files,
# making it a self-contained unit that can be deployed anywhere without relying on nginx
if env('DD_WHITENOISE'):
WHITE_NOISE = [
# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
'whitenoise.middleware.WhiteNoiseMiddleware',
]
MIDDLEWARE = MIDDLEWARE + WHITE_NOISE
EMAIL_CONFIG = env.email_url(
'DD_EMAIL_URL', default='smtp://user@:password@localhost:25')
vars().update(EMAIL_CONFIG)
# ------------------------------------------------------------------------------
# SAML
# ------------------------------------------------------------------------------
# For more configuration and customization options, see djangosaml2 documentation
# https://djangosaml2.readthedocs.io/contents/setup.html#configuration
# To override not configurable settings, you can use local_settings.py
# function that helps convert env var into the djangosaml2 attribute mapping format
# https://djangosaml2.readthedocs.io/contents/setup.html#users-attributes-and-account-linking
def saml2_attrib_map_format(dict):
dout = {}
for i in dict:
dout[i] = (dict[i],)
return dout
SAML2_ENABLED = env('DD_SAML2_ENABLED')
SAML2_LOGOUT_URL = env('DD_SAML2_LOGOUT_URL')
if SAML2_ENABLED:
import saml2
import saml2.saml
from os import path
# SSO_URL = env('DD_SSO_URL')
SAML_METADATA = {}
if len(env('DD_SAML2_METADATA_AUTO_CONF_URL')) > 0:
SAML_METADATA['remote'] = [{"url": env('DD_SAML2_METADATA_AUTO_CONF_URL')}]
if len(env('DD_SAML2_METADATA_LOCAL_FILE_PATH')) > 0:
SAML_METADATA['local'] = [env('DD_SAML2_METADATA_LOCAL_FILE_PATH')]
INSTALLED_APPS += ('djangosaml2',)
MIDDLEWARE.append('djangosaml2.middleware.SamlSessionMiddleware')
AUTHENTICATION_BACKENDS += ('djangosaml2.backends.Saml2Backend',)
LOGIN_EXEMPT_URLS += (r'^%ssaml2/' % URL_PREFIX,)
SAML_LOGOUT_REQUEST_PREFERRED_BINDING = saml2.BINDING_HTTP_POST
SAML_IGNORE_LOGOUT_ERRORS = True
SAML_DJANGO_USER_MAIN_ATTRIBUTE = 'username'
# SAML_DJANGO_USER_MAIN_ATTRIBUTE_LOOKUP = '__iexact'
SAML_USE_NAME_ID_AS_USERNAME = True
SAML_CREATE_UNKNOWN_USER = env('DD_SAML2_CREATE_USER')
SAML_ATTRIBUTE_MAPPING = saml2_attrib_map_format(env('DD_SAML2_ATTRIBUTES_MAP'))
BASEDIR = path.dirname(path.abspath(__file__))
if len(env('DD_SAML2_ENTITY_ID')) == 0:
SAML2_ENTITY_ID = '%s/saml2/metadata/' % SITE_URL
else:
SAML2_ENTITY_ID = env('DD_SAML2_ENTITY_ID')
SAML_CONFIG = {
# full path to the xmlsec1 binary programm
'xmlsec_binary': '/usr/bin/xmlsec1',
# your entity id, usually your subdomain plus the url to the metadata view
'entityid': '%s' % SAML2_ENTITY_ID,
# directory with attribute mapping
'attribute_map_dir': path.join(BASEDIR, 'attribute-maps'),
# do now discard attributes not specified in attribute-maps
'allow_unknown_attributes': env('DD_SAML2_ALLOW_UNKNOWN_ATTRIBUTE'),
# this block states what services we provide
'service': {
# we are just a lonely SP
'sp': {
'name': 'Defect_Dojo',
'name_id_format': saml2.saml.NAMEID_FORMAT_TRANSIENT,
'want_response_signed': False,
'want_assertions_signed': True,
'force_authn': True,
'allow_unsolicited': True,
# For Okta add signed logout requets. Enable this:
# "logout_requests_signed": True,
'endpoints': {
# url and binding to the assetion consumer service view
# do not change the binding or service name
'assertion_consumer_service': [
('%s/saml2/acs/' % SITE_URL,
saml2.BINDING_HTTP_POST),
],
# url and binding to the single logout service view
# do not change the binding or service name
'single_logout_service': [
# Disable next two lines for HTTP_REDIRECT for IDP's that only support HTTP_POST. Ex. Okta:
('%s/saml2/ls/' % SITE_URL,
saml2.BINDING_HTTP_REDIRECT),
('%s/saml2/ls/post' % SITE_URL,
saml2.BINDING_HTTP_POST),
],
},
# attributes that this project need to identify a user
'required_attributes': ['Email', 'UserName'],
# attributes that may be useful to have but not required
'optional_attributes': ['Firstname', 'Lastname'],
# in this section the list of IdPs we talk to are defined
# This is not mandatory! All the IdP available in the metadata will be considered.
# 'idp': {
# # we do not need a WAYF service since there is
# # only an IdP defined here. This IdP should be
# # present in our metadata
# # the keys of this dictionary are entity ids
# 'https://localhost/simplesaml/saml2/idp/metadata.php': {
# 'single_sign_on_service': {
# saml2.BINDING_HTTP_REDIRECT: 'https://localhost/simplesaml/saml2/idp/SSOService.php',
# },
# 'single_logout_service': {
# saml2.BINDING_HTTP_REDIRECT: 'https://localhost/simplesaml/saml2/idp/SingleLogoutService.php',
# },
# },
# },
},
},
# where the remote metadata is stored, local, remote or mdq server.
# One metadatastore or many ...
'metadata': SAML_METADATA,
# set to 1 to output debugging information
'debug': 0,
# Signing
# 'key_file': path.join(BASEDIR, 'private.key'), # private part
# 'cert_file': path.join(BASEDIR, 'public.pem'), # public part
# Encryption
# 'encryption_keypairs': [{
# 'key_file': path.join(BASEDIR, 'private.key'), # private part
# 'cert_file': path.join(BASEDIR, 'public.pem'), # public part
# }],
# own metadata settings
'contact_person': [
{'given_name': 'Lorenzo',
'sur_name': 'Gil',
'company': 'Yaco Sistemas',
'email_address': '[email protected]',
'contact_type': 'technical'},
{'given_name': 'Angel',
'sur_name': 'Fernandez',
'company': 'Yaco Sistemas',
'email_address': '[email protected]',
'contact_type': 'administrative'},
],
# you can set multilanguage information here
'organization': {
'name': [('Yaco Sistemas', 'es'), ('Yaco Systems', 'en')],
'display_name': [('Yaco', 'es'), ('Yaco', 'en')],
'url': [('http://www.yaco.es', 'es'), ('http://www.yaco.com', 'en')],
},
'valid_for': 24, # how long is our metadata valid
}
# ------------------------------------------------------------------------------
# CELERY
# ------------------------------------------------------------------------------
# Celery settings
CELERY_BROKER_URL = env('DD_CELERY_BROKER_URL') \
if len(env('DD_CELERY_BROKER_URL')) > 0 else generate_url(
env('DD_CELERY_BROKER_SCHEME'),
True,
env('DD_CELERY_BROKER_USER'),
env('DD_CELERY_BROKER_PASSWORD'),
env('DD_CELERY_BROKER_HOST'),
env('DD_CELERY_BROKER_PORT'),
env('DD_CELERY_BROKER_PATH'),
env('DD_CELERY_BROKER_PARAMS')
)
CELERY_TASK_IGNORE_RESULT = env('DD_CELERY_TASK_IGNORE_RESULT')
CELERY_RESULT_BACKEND = env('DD_CELERY_RESULT_BACKEND')
CELERY_TIMEZONE = TIME_ZONE
CELERY_RESULT_EXPIRES = env('DD_CELERY_RESULT_EXPIRES')
CELERY_BEAT_SCHEDULE_FILENAME = env('DD_CELERY_BEAT_SCHEDULE_FILENAME')
CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
CELERY_TASK_SERIALIZER = env('DD_CELERY_TASK_SERIALIZER')
CELERY_PASS_MODEL_BY_ID = env('DD_CELERY_PASS_MODEL_BY_ID')
CELERY_IMPORTS = ('dojo.tools.tool_issue_updater', )
# Celery beat scheduled tasks
CELERY_BEAT_SCHEDULE = {
'add-alerts': {
'task': 'dojo.tasks.add_alerts',
'schedule': timedelta(hours=1),
'args': [timedelta(hours=1)]
},
'cleanup-alerts': {
'task': 'dojo.tasks.cleanup_alerts',
'schedule': timedelta(hours=8),
},
'dedupe-delete': {
'task': 'dojo.tasks.async_dupe_delete',
'schedule': timedelta(minutes=1),
'args': [timedelta(minutes=1)]
},
'update-findings-from-source-issues': {
'task': 'dojo.tools.tool_issue_updater.update_findings_from_source_issues',
'schedule': timedelta(hours=3),
},
'compute-sla-age-and-notify': {
'task': 'dojo.tasks.async_sla_compute_and_notify_task',
'schedule': crontab(hour=7, minute=30),
},
'risk_acceptance_expiration_handler': {
'task': 'dojo.risk_acceptance.helper.expiration_handler',
'schedule': crontab(minute=0, hour='*/3'), # every 3 hours
},
# 'jira_status_reconciliation': {
# 'task': 'dojo.tasks.jira_status_reconciliation_task',
# 'schedule': timedelta(hours=12),
# 'kwargs': {'mode': 'reconcile', 'dryrun': True, 'daysback': 10, 'product': None, 'engagement': None}
# },
# 'fix_loop_duplicates': {
# 'task': 'dojo.tasks.fix_loop_duplicates_task',
# 'schedule': timedelta(hours=12)
# },
}
# ------------------------------------
# Monitoring Metrics
# ------------------------------------
# address issue when running ./manage.py collectstatic
# reference: https://github.com/korfuri/django-prometheus/issues/34
PROMETHEUS_EXPORT_MIGRATIONS = False
# django metrics for monitoring
if env('DD_DJANGO_METRICS_ENABLED'):
DJANGO_METRICS_ENABLED = env('DD_DJANGO_METRICS_ENABLED')
INSTALLED_APPS = INSTALLED_APPS + ('django_prometheus',)
MIDDLEWARE = ['django_prometheus.middleware.PrometheusBeforeMiddleware', ] + \
MIDDLEWARE + \
['django_prometheus.middleware.PrometheusAfterMiddleware', ]
database_engine = DATABASES.get('default').get('ENGINE')
DATABASES['default']['ENGINE'] = database_engine.replace('django.', 'django_prometheus.', 1)
# CELERY_RESULT_BACKEND.replace('django.core','django_prometheus.', 1)
LOGIN_EXEMPT_URLS += (r'^%sdjango_metrics/' % URL_PREFIX,)
# ------------------------------------
# Hashcode configuration
# ------------------------------------
# List of fields used to compute the hash_code
# The fields must be one of HASHCODE_ALLOWED_FIELDS
# If not present, default is the legacy behavior: see models.py, compute_hash_code_legacy function
# legacy is: