From 2bf0781882140f5f654c544f81d3a66e8359af3f Mon Sep 17 00:00:00 2001 From: kiblik <5609770+kiblik@users.noreply.github.com> Date: Thu, 12 Sep 2024 20:33:28 +0200 Subject: [PATCH 1/8] feat(disclaimers): Split disclaimers --- .../0215_system_settings_disclaimer_notif.py | 38 +++++++++++++++++++ dojo/models.py | 17 +++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 dojo/db_migrations/0215_system_settings_disclaimer_notif.py diff --git a/dojo/db_migrations/0215_system_settings_disclaimer_notif.py b/dojo/db_migrations/0215_system_settings_disclaimer_notif.py new file mode 100644 index 0000000000..ed774c3274 --- /dev/null +++ b/dojo/db_migrations/0215_system_settings_disclaimer_notif.py @@ -0,0 +1,38 @@ +# Generated by Django 5.0.8 on 2024-09-12 18:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dojo', '0214_test_type_dynamically_generated'), + ] + + operations = [ + migrations.RenameField( + model_name='system_settings', + old_name='disclaimer', + new_name='disclaimer_notifications', + ), + migrations.AlterField( + model_name='system_settings', + name='disclaimer_notifications', + field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer on all notifications', max_length=3000, verbose_name='Custom Disclaimer for Notifications'), + ), + migrations.AddField( + model_name='system_settings', + name='disclaimer_reports', + field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer on generated reports', max_length=5000, verbose_name='Custom Disclaimer for Reports'), + ), + migrations.AddField( + model_name='system_settings', + name='disclaimer_notes', + field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer next to input form for notes', max_length=3000, verbose_name='Custom Disclaimer for Notes'), + ), + migrations.AddField( + model_name='system_settings', + name='disclaimer_reports_forced', + field=models.BooleanField(default=False, help_text="Disclaimer will be added to all reports even if user didn't selected 'Include disclaimer'.", verbose_name='Force to add disclaimer reports'), + ), + ] diff --git a/dojo/models.py b/dojo/models.py index ff34cde034..6d2d4037b8 100644 --- a/dojo/models.py +++ b/dojo/models.py @@ -513,9 +513,20 @@ class System_Settings(models.Model): help_text=_("Enable anyone with a link to the survey to answer a survey"), ) credentials = models.TextField(max_length=3000, blank=True) - disclaimer = models.TextField(max_length=3000, default="", blank=True, - verbose_name=_("Custom Disclaimer"), - help_text=_("Include this custom disclaimer on all notifications and generated reports")) + disclaimer_notifications = models.TextField(max_length=3000, default="", blank=True, + verbose_name=_("Custom Disclaimer for Notifications"), + help_text=_("Include this custom disclaimer on all notifications")) + disclaimer_reports = models.TextField(max_length=5000, default="", blank=True, + verbose_name=_("Custom Disclaimer for Reports"), + help_text=_("Include this custom disclaimer on generated reports")) + disclaimer_reports_forced = models.BooleanField( + default=False, + blank=False, + verbose_name=_("Force to add disclaimer reports"), + help_text=_("Disclaimer will be added to all reports even if user didn't selected 'Include disclaimer'.")) + disclaimer_notes = models.TextField(max_length=3000, default="", blank=True, + verbose_name=_("Custom Disclaimer for Notes"), + help_text=_("Include this custom disclaimer next to input form for notes")) risk_acceptance_form_default_days = models.IntegerField(null=True, blank=True, default=180, help_text=_("Default expiry period for risk acceptance form.")) risk_acceptance_notify_before_expiration = models.IntegerField(null=True, blank=True, default=10, verbose_name=_("Risk acceptance expiration heads up days"), help_text=_("Notify X days before risk acceptance expires. Leave empty to disable.")) From c726a406c00d2bf78b554cc1794242a2d1460171 Mon Sep 17 00:00:00 2001 From: kiblik <5609770+kiblik@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:27:51 +0200 Subject: [PATCH 2/8] fix existing --- ..._notif.py => 0216_system_settings_disclaimer_notif.py} | 2 +- dojo/fixtures/defect_dojo_sample_data.json | 2 +- dojo/forms.py | 7 +++++++ dojo/reports/views.py | 8 ++++---- dojo/templates/notifications/alert/review_requested.tpl | 4 ++-- dojo/templates/notifications/mail/engagement_added.tpl | 4 ++-- dojo/templates/notifications/mail/other.tpl | 4 ++-- dojo/templates/notifications/mail/product_added.tpl | 4 ++-- dojo/templates/notifications/mail/product_type_added.tpl | 4 ++-- dojo/templates/notifications/mail/report_created.tpl | 4 ++-- dojo/templates/notifications/mail/review_requested.tpl | 4 ++-- .../notifications/mail/risk_acceptance_expiration.tpl | 4 ++-- dojo/templates/notifications/mail/scan_added.tpl | 4 ++-- dojo/templates/notifications/mail/sla_breach.tpl | 4 ++-- dojo/templates/notifications/mail/sla_breach_combined.tpl | 4 ++-- dojo/templates/notifications/mail/test_added.tpl | 4 ++-- dojo/templates/notifications/mail/upcoming_engagement.tpl | 4 ++-- dojo/templates/notifications/mail/user_mentioned.tpl | 4 ++-- dojo/templates/notifications/msteams/engagement_added.tpl | 4 ++-- dojo/templates/notifications/msteams/other.tpl | 4 ++-- dojo/templates/notifications/msteams/product_added.tpl | 4 ++-- .../notifications/msteams/product_type_added.tpl | 4 ++-- dojo/templates/notifications/msteams/report_created.tpl | 4 ++-- dojo/templates/notifications/msteams/review_requested.tpl | 4 ++-- .../notifications/msteams/risk_acceptance_expiration.tpl | 4 ++-- dojo/templates/notifications/msteams/scan_added.tpl | 4 ++-- dojo/templates/notifications/msteams/sla_breach.tpl | 4 ++-- dojo/templates/notifications/msteams/test_added.tpl | 4 ++-- .../notifications/msteams/upcoming_engagement.tpl | 4 ++-- dojo/templates/notifications/msteams/user_mentioned.tpl | 4 ++-- dojo/templates/notifications/slack/engagement_added.tpl | 4 ++-- dojo/templates/notifications/slack/other.tpl | 4 ++-- dojo/templates/notifications/slack/product_added.tpl | 4 ++-- dojo/templates/notifications/slack/product_type_added.tpl | 4 ++-- dojo/templates/notifications/slack/report_created.tpl | 4 ++-- dojo/templates/notifications/slack/review_requested.tpl | 4 ++-- .../notifications/slack/risk_acceptance_expiration.tpl | 4 ++-- dojo/templates/notifications/slack/scan_added.tpl | 4 ++-- dojo/templates/notifications/slack/sla_breach.tpl | 4 ++-- dojo/templates/notifications/slack/test_added.tpl | 4 ++-- .../templates/notifications/slack/upcoming_engagement.tpl | 4 ++-- dojo/templates/notifications/slack/user_mentioned.tpl | 4 ++-- .../notifications/webhooks/subtemplates/base.tpl | 4 ++-- 43 files changed, 91 insertions(+), 84 deletions(-) rename dojo/db_migrations/{0215_system_settings_disclaimer_notif.py => 0216_system_settings_disclaimer_notif.py} (96%) diff --git a/dojo/db_migrations/0215_system_settings_disclaimer_notif.py b/dojo/db_migrations/0216_system_settings_disclaimer_notif.py similarity index 96% rename from dojo/db_migrations/0215_system_settings_disclaimer_notif.py rename to dojo/db_migrations/0216_system_settings_disclaimer_notif.py index ed774c3274..35dc31d13a 100644 --- a/dojo/db_migrations/0215_system_settings_disclaimer_notif.py +++ b/dojo/db_migrations/0216_system_settings_disclaimer_notif.py @@ -6,7 +6,7 @@ class Migration(migrations.Migration): dependencies = [ - ('dojo', '0214_test_type_dynamically_generated'), + ('dojo', '0215_webhooks_notifications'), ] operations = [ diff --git a/dojo/fixtures/defect_dojo_sample_data.json b/dojo/fixtures/defect_dojo_sample_data.json index 2d0ece6cb1..a0c5414058 100644 --- a/dojo/fixtures/defect_dojo_sample_data.json +++ b/dojo/fixtures/defect_dojo_sample_data.json @@ -7119,7 +7119,7 @@ "enable_finding_sla": true, "allow_anonymous_survey_repsonse": false, "credentials": "", - "disclaimer": "", + "disclaimer_notifications": "", "risk_acceptance_form_default_days": 180, "risk_acceptance_notify_before_expiration": 10, "enable_credentials": true, diff --git a/dojo/forms.py b/dojo/forms.py index 04ed0d424d..7e9f7c934f 100644 --- a/dojo/forms.py +++ b/dojo/forms.py @@ -2303,6 +2303,13 @@ class ReportOptionsForm(forms.Form): include_disclaimer = forms.ChoiceField(choices=yes_no, label="Disclaimer") report_type = forms.ChoiceField(choices=(("HTML", "HTML"),)) + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + if get_system_setting("disclaimer_reports_forced"): + self.fields["include_disclaimer"].disabled = True + self.fields["include_disclaimer"].initial = "1" # represents yes + self.fields["include_disclaimer"].help_text="Administrator of the system enforced placement of disclaimer in all reports. You are not able exclude disclaimer from this report." + class CustomReportOptionsForm(forms.Form): yes_no = (("0", "No"), ("1", "Yes")) diff --git a/dojo/reports/views.py b/dojo/reports/views.py index 4bcd738676..390e402cb1 100644 --- a/dojo/reports/views.py +++ b/dojo/reports/views.py @@ -285,8 +285,8 @@ def product_endpoint_report(request, pid): include_finding_images = int(request.GET.get("include_finding_images", 0)) include_executive_summary = int(request.GET.get("include_executive_summary", 0)) include_table_of_contents = int(request.GET.get("include_table_of_contents", 0)) - include_disclaimer = int(request.GET.get("include_disclaimer", 0)) - disclaimer = get_system_setting("disclaimer") + include_disclaimer = int(request.GET.get("include_disclaimer", 0)) or (get_system_setting("disclaimer_reports_forced", 0)) + disclaimer = get_system_setting("disclaimer_reports") if include_disclaimer and len(disclaimer) == 0: disclaimer = "Please configure in System Settings." generate = "_generate" in request.GET @@ -363,8 +363,8 @@ def generate_report(request, obj, host_view=False): include_finding_images = int(request.GET.get("include_finding_images", 0)) include_executive_summary = int(request.GET.get("include_executive_summary", 0)) include_table_of_contents = int(request.GET.get("include_table_of_contents", 0)) - include_disclaimer = int(request.GET.get("include_disclaimer", 0)) - disclaimer = get_system_setting("disclaimer") + include_disclaimer = int(request.GET.get("include_disclaimer", 0)) or (get_system_setting("disclaimer_reports_forced", 0)) + disclaimer = get_system_setting("disclaimer_reports") if include_disclaimer and len(disclaimer) == 0: disclaimer = "Please configure in System Settings." diff --git a/dojo/templates/notifications/alert/review_requested.tpl b/dojo/templates/notifications/alert/review_requested.tpl index 6d4ee62e63..486e1ce6fe 100644 --- a/dojo/templates/notifications/alert/review_requested.tpl +++ b/dojo/templates/notifications/alert/review_requested.tpl @@ -14,7 +14,7 @@ {% trans "Full details of the finding can be reviewed at" %} {{ url|full_url }} -{% if system_settings.disclaimer and system_settings.disclaimer.strip %} +{% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} {% trans "Disclaimer:" %} - {{ system_settings.disclaimer }} + {{ system_settings.disclaimer_notifications }} {% endif %} \ No newline at end of file diff --git a/dojo/templates/notifications/mail/engagement_added.tpl b/dojo/templates/notifications/mail/engagement_added.tpl index 4769979ba1..681adc36cc 100644 --- a/dojo/templates/notifications/mail/engagement_added.tpl +++ b/dojo/templates/notifications/mail/engagement_added.tpl @@ -29,11 +29,11 @@ {% url 'notifications' as notification_url %} {% trans "You can manage your notification settings here" %}: {{ notification_url|full_url }}

- {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %}
{% trans "Disclaimer" %}
-

{{ system_settings.disclaimer }}

+

{{ system_settings.disclaimer_notifications }}

{% endif %} {% endautoescape %} diff --git a/dojo/templates/notifications/mail/other.tpl b/dojo/templates/notifications/mail/other.tpl index 69c96362d2..65e5d854c3 100644 --- a/dojo/templates/notifications/mail/other.tpl +++ b/dojo/templates/notifications/mail/other.tpl @@ -31,11 +31,11 @@ {% url 'notifications' as notification_url %} {% trans "You can manage your notification settings here" %}: {{ notification_url|full_url }}

- {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %}
{% trans "Disclaimer" %}
-

{{ system_settings.disclaimer }}

+

{{ system_settings.disclaimer_notifications }}

{% endif %} {% endautoescape %} diff --git a/dojo/templates/notifications/mail/product_added.tpl b/dojo/templates/notifications/mail/product_added.tpl index ef8fa7faa6..9e5ecded41 100644 --- a/dojo/templates/notifications/mail/product_added.tpl +++ b/dojo/templates/notifications/mail/product_added.tpl @@ -28,11 +28,11 @@ {% url 'notifications' as notification_url %} {% trans "You can manage your notification settings here" %}: {{ notification_url|full_url }}

- {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %}
{% trans "Disclaimer" %}
-

{{ system_settings.disclaimer }}

+

{{ system_settings.disclaimer_notifications }}

{% endif %} {% endautoescape %} diff --git a/dojo/templates/notifications/mail/product_type_added.tpl b/dojo/templates/notifications/mail/product_type_added.tpl index 72d7972f56..a229882a34 100644 --- a/dojo/templates/notifications/mail/product_type_added.tpl +++ b/dojo/templates/notifications/mail/product_type_added.tpl @@ -28,11 +28,11 @@ {% url 'notifications' as notification_url %} {% trans "You can manage your notification settings here" %}: {{ notification_url|full_url }}

- {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %}
{% trans "Disclaimer" %}
-

{{ system_settings.disclaimer }}

+

{{ system_settings.disclaimer_notifications }}

{% endif %} {% endautoescape %} diff --git a/dojo/templates/notifications/mail/report_created.tpl b/dojo/templates/notifications/mail/report_created.tpl index efbb4b8fd6..0c898d276e 100644 --- a/dojo/templates/notifications/mail/report_created.tpl +++ b/dojo/templates/notifications/mail/report_created.tpl @@ -25,11 +25,11 @@ {% trans "You can manage your notification settings here" %}: {{ notification_url|full_url }}

- {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %}
{% trans "Disclaimer" %}
-

{{ system_settings.disclaimer }}

+

{{ system_settings.disclaimer_notifications }}

{% endif %} {% endautoescape %} diff --git a/dojo/templates/notifications/mail/review_requested.tpl b/dojo/templates/notifications/mail/review_requested.tpl index 98bde4113a..c3ef81b1a1 100644 --- a/dojo/templates/notifications/mail/review_requested.tpl +++ b/dojo/templates/notifications/mail/review_requested.tpl @@ -33,11 +33,11 @@ {% url 'notifications' as notification_url %} {% trans "You can manage your notification settings here" %}: {{ notification_url|full_url }}

- {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %}
{% trans "Disclaimer" %}
-

{{ system_settings.disclaimer }}

+

{{ system_settings.disclaimer_notifications }}

{% endif %} {% endautoescape %} diff --git a/dojo/templates/notifications/mail/risk_acceptance_expiration.tpl b/dojo/templates/notifications/mail/risk_acceptance_expiration.tpl index 7fc4916d1d..ce76a2d1b5 100644 --- a/dojo/templates/notifications/mail/risk_acceptance_expiration.tpl +++ b/dojo/templates/notifications/mail/risk_acceptance_expiration.tpl @@ -52,11 +52,11 @@ {% url 'notifications' as notification_url %} {% trans "You can manage your notification settings here" %}: {{ notification_url|full_url }}

- {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %}
{% trans "Disclaimer" %}
-

{{ system_settings.disclaimer }}

+

{{ system_settings.disclaimer_notifications }}

{% endif %} {% endautoescape %} diff --git a/dojo/templates/notifications/mail/scan_added.tpl b/dojo/templates/notifications/mail/scan_added.tpl index 513b24818d..263585246e 100644 --- a/dojo/templates/notifications/mail/scan_added.tpl +++ b/dojo/templates/notifications/mail/scan_added.tpl @@ -72,11 +72,11 @@ {% url 'notifications' as notification_url %} {% trans "You can manage your notification settings here" %}: {{ notification_url|full_url }}

- {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %}
{% trans "Disclaimer" %}
-

{{ system_settings.disclaimer }}

+

{{ system_settings.disclaimer_notifications }}

{% endif %} {% endautoescape %} diff --git a/dojo/templates/notifications/mail/sla_breach.tpl b/dojo/templates/notifications/mail/sla_breach.tpl index 692df2ef2e..97c08762ba 100644 --- a/dojo/templates/notifications/mail/sla_breach.tpl +++ b/dojo/templates/notifications/mail/sla_breach.tpl @@ -45,11 +45,11 @@ {% url 'notifications' as notification_url %} {% trans "You can manage your notification settings here" %}: {{ notification_url|full_url }}

- {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %}
{% trans "Disclaimer" %}
-

{{ system_settings.disclaimer }}

+

{{ system_settings.disclaimer_notifications }}

{% endif %} {% endautoescape %} diff --git a/dojo/templates/notifications/mail/sla_breach_combined.tpl b/dojo/templates/notifications/mail/sla_breach_combined.tpl index 5b88a656e2..4fc8c8f801 100644 --- a/dojo/templates/notifications/mail/sla_breach_combined.tpl +++ b/dojo/templates/notifications/mail/sla_breach_combined.tpl @@ -55,7 +55,7 @@ {% url 'notifications' as notification_url %} {% trans "You can manage your notification settings here" %}: {{ notification_url|full_url }}

- {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %}
{{ system_settings.disclaimer }}

+ font-family: 'Cambria','times roman',serif">{{ system_settings.disclaimer_notifications }}

{% endif %} {% endautoescape %} diff --git a/dojo/templates/notifications/mail/test_added.tpl b/dojo/templates/notifications/mail/test_added.tpl index 285bb28faf..3c235ea076 100644 --- a/dojo/templates/notifications/mail/test_added.tpl +++ b/dojo/templates/notifications/mail/test_added.tpl @@ -30,11 +30,11 @@ {% url 'notifications' as notification_url %} {% trans "You can manage your notification settings here" %}: {{ notification_url|full_url }}

- {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %}
{% trans "Disclaimer" %}
-

{{ system_settings.disclaimer }}

+

{{ system_settings.disclaimer_notifications }}

{% endif %} {% endautoescape %} diff --git a/dojo/templates/notifications/mail/upcoming_engagement.tpl b/dojo/templates/notifications/mail/upcoming_engagement.tpl index ae6da9da7b..858314449c 100644 --- a/dojo/templates/notifications/mail/upcoming_engagement.tpl +++ b/dojo/templates/notifications/mail/upcoming_engagement.tpl @@ -28,11 +28,11 @@ {% url 'notifications' as notification_url %} {% trans "You can manage your notification settings here" %}: {{ notification_url|full_url }}

- {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %}
{% trans "Disclaimer" %}
-

{{ system_settings.disclaimer }}

+

{{ system_settings.disclaimer_notifications }}

{% endif %} {% endautoescape %} diff --git a/dojo/templates/notifications/mail/user_mentioned.tpl b/dojo/templates/notifications/mail/user_mentioned.tpl index 651fd9df49..9601da3c9a 100644 --- a/dojo/templates/notifications/mail/user_mentioned.tpl +++ b/dojo/templates/notifications/mail/user_mentioned.tpl @@ -31,11 +31,11 @@ {% url 'notifications' as notification_url %} {% trans "You can manage your notification settings here" %}: {{ notification_url|full_url }}

- {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %}
{% trans "Disclaimer" %}
-

{{ system_settings.disclaimer }}

+

{{ system_settings.disclaimer_notifications }}

{% endif %} {% endautoescape %} diff --git a/dojo/templates/notifications/msteams/engagement_added.tpl b/dojo/templates/notifications/msteams/engagement_added.tpl index 9d7c7ef5b3..747f891107 100644 --- a/dojo/templates/notifications/msteams/engagement_added.tpl +++ b/dojo/templates/notifications/msteams/engagement_added.tpl @@ -21,10 +21,10 @@ } ] } - {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} ,{ "activityTitle": "{% trans "Disclaimer" %}", - "text": "{{ system_settings.disclaimer }}" + "text": "{{ system_settings.disclaimer_notifications }}" } {% endif %} diff --git a/dojo/templates/notifications/msteams/other.tpl b/dojo/templates/notifications/msteams/other.tpl index ef0cbe4bd9..123390f9c5 100644 --- a/dojo/templates/notifications/msteams/other.tpl +++ b/dojo/templates/notifications/msteams/other.tpl @@ -11,10 +11,10 @@ "activityImage": "https://raw.githubusercontent.com/DefectDojo/django-DefectDojo/master/dojo/static/dojo/img/chop.png", "text": "{% autoescape on %} {{ description }} {% endautoescape %}" } - {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} ,{ "activityTitle": "{% trans "Disclaimer" %}", - "text": "{{ system_settings.disclaimer }}" + "text": "{{ system_settings.disclaimer_notifications }}" } {% endif %} ], diff --git a/dojo/templates/notifications/msteams/product_added.tpl b/dojo/templates/notifications/msteams/product_added.tpl index 31e5a71bf9..d2def33cd0 100644 --- a/dojo/templates/notifications/msteams/product_added.tpl +++ b/dojo/templates/notifications/msteams/product_added.tpl @@ -17,10 +17,10 @@ } ] } - {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} ,{ "activityTitle": "{% trans "Disclaimer" %}", - "text": "{{ system_settings.disclaimer }}" + "text": "{{ system_settings.disclaimer_notifications }}" } {% endif %} ], diff --git a/dojo/templates/notifications/msteams/product_type_added.tpl b/dojo/templates/notifications/msteams/product_type_added.tpl index 926ade5a2c..b650f23d6c 100644 --- a/dojo/templates/notifications/msteams/product_type_added.tpl +++ b/dojo/templates/notifications/msteams/product_type_added.tpl @@ -17,10 +17,10 @@ } ] } - {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} ,{ "activityTitle": "{% trans "Disclaimer" %}", - "text": "{{ system_settings.disclaimer }}" + "text": "{{ system_settings.disclaimer_notifications }}" } {% endif %} ], diff --git a/dojo/templates/notifications/msteams/report_created.tpl b/dojo/templates/notifications/msteams/report_created.tpl index 8a9b246ebf..42f8398ed2 100644 --- a/dojo/templates/notifications/msteams/report_created.tpl +++ b/dojo/templates/notifications/msteams/report_created.tpl @@ -17,10 +17,10 @@ } ] } - {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} ,{ "activityTitle": "{% trans "Disclaimer" %}", - "text": "{{ system_settings.disclaimer }}" + "text": "{{ system_settings.disclaimer_notifications }}" } {% endif %} ], diff --git a/dojo/templates/notifications/msteams/review_requested.tpl b/dojo/templates/notifications/msteams/review_requested.tpl index d1a38c49b0..1ec637c900 100644 --- a/dojo/templates/notifications/msteams/review_requested.tpl +++ b/dojo/templates/notifications/msteams/review_requested.tpl @@ -29,10 +29,10 @@ } ] } - {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} ,{ "activityTitle": "{% trans "Disclaimer" %}", - "text": "{{ system_settings.disclaimer }}" + "text": "{{ system_settings.disclaimer_notifications }}" } {% endif %} ], diff --git a/dojo/templates/notifications/msteams/risk_acceptance_expiration.tpl b/dojo/templates/notifications/msteams/risk_acceptance_expiration.tpl index babf9376e8..95e6279b5f 100644 --- a/dojo/templates/notifications/msteams/risk_acceptance_expiration.tpl +++ b/dojo/templates/notifications/msteams/risk_acceptance_expiration.tpl @@ -35,10 +35,10 @@ } ] } - {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} ,{ "activityTitle": "{% trans "Disclaimer" %}", - "text": "{{ system_settings.disclaimer }}" + "text": "{{ system_settings.disclaimer_notifications }}" } {% endif %} ], diff --git a/dojo/templates/notifications/msteams/scan_added.tpl b/dojo/templates/notifications/msteams/scan_added.tpl index af32887e9a..52a67fd76c 100644 --- a/dojo/templates/notifications/msteams/scan_added.tpl +++ b/dojo/templates/notifications/msteams/scan_added.tpl @@ -26,10 +26,10 @@ } ] } - {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} ,{ "activityTitle": "{% trans "Disclaimer" %}", - "text": "{{ system_settings.disclaimer }}" + "text": "{{ system_settings.disclaimer_notifications }}" } {% endif %} ], diff --git a/dojo/templates/notifications/msteams/sla_breach.tpl b/dojo/templates/notifications/msteams/sla_breach.tpl index c74b7abea2..31ad6991bf 100644 --- a/dojo/templates/notifications/msteams/sla_breach.tpl +++ b/dojo/templates/notifications/msteams/sla_breach.tpl @@ -34,10 +34,10 @@ } ] } - {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} ,{ "activityTitle": "{% trans "Disclaimer" %}", - "text": "{{ system_settings.disclaimer }}" + "text": "{{ system_settings.disclaimer_notifications }}" } {% endif %} ], diff --git a/dojo/templates/notifications/msteams/test_added.tpl b/dojo/templates/notifications/msteams/test_added.tpl index 8d5515138e..7b22e5d131 100644 --- a/dojo/templates/notifications/msteams/test_added.tpl +++ b/dojo/templates/notifications/msteams/test_added.tpl @@ -26,10 +26,10 @@ } ] } - {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} ,{ "activityTitle": "{% trans "Disclaimer" %}", - "text": "{{ system_settings.disclaimer }}" + "text": "{{ system_settings.disclaimer_notifications }}" } {% endif %} ], diff --git a/dojo/templates/notifications/msteams/upcoming_engagement.tpl b/dojo/templates/notifications/msteams/upcoming_engagement.tpl index 06cbbb2e1c..9cb22d025d 100644 --- a/dojo/templates/notifications/msteams/upcoming_engagement.tpl +++ b/dojo/templates/notifications/msteams/upcoming_engagement.tpl @@ -30,10 +30,10 @@ } ] } - {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} ,{ "activityTitle": "{% trans "Disclaimer" %}", - "text": "{{ system_settings.disclaimer }}" + "text": "{{ system_settings.disclaimer_notifications }}" } {% endif %} ], diff --git a/dojo/templates/notifications/msteams/user_mentioned.tpl b/dojo/templates/notifications/msteams/user_mentioned.tpl index 5c09d1c789..fb27ea5ad1 100644 --- a/dojo/templates/notifications/msteams/user_mentioned.tpl +++ b/dojo/templates/notifications/msteams/user_mentioned.tpl @@ -25,10 +25,10 @@ } ] } - {% if system_settings.disclaimer and system_settings.disclaimer.strip %} + {% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} ,{ "activityTitle": "{% trans "Disclaimer" %}", - "text": "{{ system_settings.disclaimer }}" + "text": "{{ system_settings.disclaimer_notifications }}" } {% endif %} ], diff --git a/dojo/templates/notifications/slack/engagement_added.tpl b/dojo/templates/notifications/slack/engagement_added.tpl index 711fb2d7e7..212f0f5ee3 100644 --- a/dojo/templates/notifications/slack/engagement_added.tpl +++ b/dojo/templates/notifications/slack/engagement_added.tpl @@ -3,8 +3,8 @@ {% blocktranslate trimmed with name=engagement.name eng_product=engagement.product eng_url=url|full_url %} The engagement "{{ name }}" has been created in the product "{{ eng_product }}". It can be viewed here: {{ eng_url }} {% endblocktranslate %} -{% if system_settings.disclaimer and system_settings.disclaimer.strip %} +{% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} {% trans "Disclaimer" %}: - {{ system_settings.disclaimer }} + {{ system_settings.disclaimer_notifications }} {% endif %} diff --git a/dojo/templates/notifications/slack/other.tpl b/dojo/templates/notifications/slack/other.tpl index 0bbe40eb8b..f371af5263 100644 --- a/dojo/templates/notifications/slack/other.tpl +++ b/dojo/templates/notifications/slack/other.tpl @@ -6,8 +6,8 @@ More information on this event can be found here: {{ event_url }} {% endblocktranslate %} {% endif %} -{% if system_settings.disclaimer|length %} +{% if system_settings.disclaimer_notifications|length %} {% trans "Disclaimer" %}: - {{ system_settings.disclaimer }} + {{ system_settings.disclaimer_notifications }} {% endif %} diff --git a/dojo/templates/notifications/slack/product_added.tpl b/dojo/templates/notifications/slack/product_added.tpl index ca57b54333..6d1cef8445 100644 --- a/dojo/templates/notifications/slack/product_added.tpl +++ b/dojo/templates/notifications/slack/product_added.tpl @@ -3,8 +3,8 @@ {% blocktranslate trimmed with prod_url=url|full_url %} The new product "{{ title }}" has been added. It can be viewed here: {{ prod_url }} {% endblocktranslate %} -{% if system_settings.disclaimer and system_settings.disclaimer.strip %} +{% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} {% trans "Disclaimer" %}: - {{ system_settings.disclaimer }} + {{ system_settings.disclaimer_notifications }} {% endif %} diff --git a/dojo/templates/notifications/slack/product_type_added.tpl b/dojo/templates/notifications/slack/product_type_added.tpl index 914114ca43..8818a3f101 100644 --- a/dojo/templates/notifications/slack/product_type_added.tpl +++ b/dojo/templates/notifications/slack/product_type_added.tpl @@ -3,8 +3,8 @@ {% blocktranslate trimmed with prod_url=url|full_url %} The new product type "{{ title }}" has been added. It can be viewed here: {{ prod_url }} {% endblocktranslate %} -{% if system_settings.disclaimer and system_settings.disclaimer.strip %} +{% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} {% trans "Disclaimer" %}: - {{ system_settings.disclaimer }} + {{ system_settings.disclaimer_notifications }} {% endif %} diff --git a/dojo/templates/notifications/slack/report_created.tpl b/dojo/templates/notifications/slack/report_created.tpl index 29b08597b1..8c5ca4a929 100644 --- a/dojo/templates/notifications/slack/report_created.tpl +++ b/dojo/templates/notifications/slack/report_created.tpl @@ -3,8 +3,8 @@ {% blocktranslate trimmed with name=report.name report_url=url|full_url %} Your report "{{ name }}" is ready. It can be downloaded here: {{ report_url }} {% endblocktranslate %} -{% if system_settings.disclaimer and system_settings.disclaimer.strip %} +{% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} {% trans "Disclaimer" %}: - {{ system_settings.disclaimer }} + {{ system_settings.disclaimer_notifications }} {% endif %} diff --git a/dojo/templates/notifications/slack/review_requested.tpl b/dojo/templates/notifications/slack/review_requested.tpl index 64a78af408..395954e774 100644 --- a/dojo/templates/notifications/slack/review_requested.tpl +++ b/dojo/templates/notifications/slack/review_requested.tpl @@ -15,7 +15,7 @@ {% trans "Full details of the finding can be reviewed at" %} {{ url|full_url }} -{% if system_settings.disclaimer and system_settings.disclaimer.strip %} +{% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} {% trans "Disclaimer:" %} - {{ system_settings.disclaimer }} + {{ system_settings.disclaimer_notifications }} {% endif %} diff --git a/dojo/templates/notifications/slack/risk_acceptance_expiration.tpl b/dojo/templates/notifications/slack/risk_acceptance_expiration.tpl index e3751c7abf..d5222c8182 100644 --- a/dojo/templates/notifications/slack/risk_acceptance_expiration.tpl +++ b/dojo/templates/notifications/slack/risk_acceptance_expiration.tpl @@ -11,8 +11,8 @@ {% blocktranslate trimmed with risk_url=risk_acceptance_url|full_url %} Risk Acceptance can be viewed here: {{ risk_url }} {% endblocktranslate %} -{% if system_settings.disclaimer and system_settings.disclaimer.strip %} +{% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} {% trans "Disclaimer" %}: - {{ system_settings.disclaimer }} + {{ system_settings.disclaimer_notifications }} {% endif %} diff --git a/dojo/templates/notifications/slack/scan_added.tpl b/dojo/templates/notifications/slack/scan_added.tpl index aa72932e8f..97488ee6c0 100644 --- a/dojo/templates/notifications/slack/scan_added.tpl +++ b/dojo/templates/notifications/slack/scan_added.tpl @@ -8,8 +8,8 @@ They can be viewed here: {{ scan_url }} {% endblocktranslate %} {% endif %} -{% if system_settings.disclaimer and system_settings.disclaimer.strip %} +{% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} {% trans "Disclaimer" %}: - {{ system_settings.disclaimer }} + {{ system_settings.disclaimer_notifications }} {% endif %} diff --git a/dojo/templates/notifications/slack/sla_breach.tpl b/dojo/templates/notifications/slack/sla_breach.tpl index fc6913e005..0e9d4ce9e5 100644 --- a/dojo/templates/notifications/slack/sla_breach.tpl +++ b/dojo/templates/notifications/slack/sla_breach.tpl @@ -6,8 +6,8 @@ Title: {{title}} Severity: {{severity}} You can find details here: {{ sla_url }} {% endblocktranslate %} -{% if system_settings.disclaimer and system_settings.disclaimer.strip %} +{% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} {% trans "Disclaimer" %}: - {{ system_settings.disclaimer }} + {{ system_settings.disclaimer_notifications }} {% endif %} diff --git a/dojo/templates/notifications/slack/test_added.tpl b/dojo/templates/notifications/slack/test_added.tpl index 38c9a9b752..fddccc1e81 100644 --- a/dojo/templates/notifications/slack/test_added.tpl +++ b/dojo/templates/notifications/slack/test_added.tpl @@ -6,8 +6,8 @@ Title: {{title}} Type: {{ test_type }} You can find details here: {{ test_url }} {% endblocktranslate %} -{% if system_settings.disclaimer and system_settings.disclaimer.strip %} +{% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} {% trans "Disclaimer" %}: - {{ system_settings.disclaimer }} + {{ system_settings.disclaimer_notifications }} {% endif %} diff --git a/dojo/templates/notifications/slack/upcoming_engagement.tpl b/dojo/templates/notifications/slack/upcoming_engagement.tpl index 59f64529da..1b2e80df6d 100644 --- a/dojo/templates/notifications/slack/upcoming_engagement.tpl +++ b/dojo/templates/notifications/slack/upcoming_engagement.tpl @@ -1,8 +1,8 @@ {% load i18n %}{% blocktranslate trimmed with eng_product=engagement.product start=engagement.target_start %} The engagement "{{ eng_product }}" is starting on {{ start }}. {% endblocktranslate %} -{% if system_settings.disclaimer and system_settings.disclaimer.strip %} +{% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} {% trans "Disclaimer" %}: - {{ system_settings.disclaimer }} + {{ system_settings.disclaimer_notifications }} {% endif %} diff --git a/dojo/templates/notifications/slack/user_mentioned.tpl b/dojo/templates/notifications/slack/user_mentioned.tpl index 3d1cf77801..aba6c9aed6 100644 --- a/dojo/templates/notifications/slack/user_mentioned.tpl +++ b/dojo/templates/notifications/slack/user_mentioned.tpl @@ -5,8 +5,8 @@ User {{ user }} jotted a note on {{ section }}: Full details of the note can be reviewed at {{ url }} {% endblocktranslate %} -{% if system_settings.disclaimer and system_settings.disclaimer.strip %} +{% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} {% trans "Disclaimer" %}: - {{ system_settings.disclaimer }} + {{ system_settings.disclaimer_notifications }} {% endif %} diff --git a/dojo/templates/notifications/webhooks/subtemplates/base.tpl b/dojo/templates/notifications/webhooks/subtemplates/base.tpl index 3b6e30da98..f8cb3e46bb 100644 --- a/dojo/templates/notifications/webhooks/subtemplates/base.tpl +++ b/dojo/templates/notifications/webhooks/subtemplates/base.tpl @@ -9,6 +9,6 @@ url_ui: {{ url|full_url }} {% if url_api %} url_api: {{ url_api|full_url }} {% endif %} -{% if system_settings.disclaimer and system_settings.disclaimer.strip %} -disclaimer: {{ system_settings.disclaimer }} +{% if system_settings.disclaimer_notifications and system_settings.disclaimer_notifications.strip %} +disclaimer: {{ system_settings.disclaimer_notifications }} {% endif %} From cbb7d782303be75f281ce9f7ad99870b49f82a83 Mon Sep 17 00:00:00 2001 From: kiblik <5609770+kiblik@users.noreply.github.com> Date: Fri, 20 Sep 2024 19:48:12 +0200 Subject: [PATCH 3/8] Add disclaimer_notes to form_fields.html --- ... 0218_system_settings_disclaimer_notif.py} | 2 +- .../0219_system_settings_disclaimer_notif.py | 21 +++++++++++++++++ dojo/forms.py | 23 +++++++++++-------- dojo/templates/dojo/form_fields.html | 7 ++++++ 4 files changed, 43 insertions(+), 10 deletions(-) rename dojo/db_migrations/{0216_system_settings_disclaimer_notif.py => 0218_system_settings_disclaimer_notif.py} (97%) create mode 100644 dojo/db_migrations/0219_system_settings_disclaimer_notif.py diff --git a/dojo/db_migrations/0216_system_settings_disclaimer_notif.py b/dojo/db_migrations/0218_system_settings_disclaimer_notif.py similarity index 97% rename from dojo/db_migrations/0216_system_settings_disclaimer_notif.py rename to dojo/db_migrations/0218_system_settings_disclaimer_notif.py index 35dc31d13a..6d966e414a 100644 --- a/dojo/db_migrations/0216_system_settings_disclaimer_notif.py +++ b/dojo/db_migrations/0218_system_settings_disclaimer_notif.py @@ -6,7 +6,7 @@ class Migration(migrations.Migration): dependencies = [ - ('dojo', '0215_webhooks_notifications'), + ('dojo', '0217_jira_project_enabled'), ] operations = [ diff --git a/dojo/db_migrations/0219_system_settings_disclaimer_notif.py b/dojo/db_migrations/0219_system_settings_disclaimer_notif.py new file mode 100644 index 0000000000..84aeffe4b0 --- /dev/null +++ b/dojo/db_migrations/0219_system_settings_disclaimer_notif.py @@ -0,0 +1,21 @@ +# Generated by Django 5.0.8 on 2024-09-12 18:22 + +from django.db import migrations + + +def copy_notif_field(apps, schema_editor): + system_settings_model = apps.get_model('dojo', 'System_Settings').objects.get() + if system_settings_model.disclaimer_notifications: + system_settings_model.disclaimer_reports = system_settings_model.disclaimer_notifications + system_settings_model.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('dojo', '0218_system_settings_disclaimer_notif'), + ] + + operations = [ + migrations.RunPython(copy_notif_field), + ] diff --git a/dojo/forms.py b/dojo/forms.py index 7e9f7c934f..0fcf6c9af2 100644 --- a/dojo/forms.py +++ b/dojo/forms.py @@ -844,7 +844,7 @@ class RiskAcceptanceForm(EditRiskAcceptanceForm): help_text=("Active, verified findings listed, please select to add findings.")) notes = forms.CharField(required=False, max_length=2400, widget=forms.Textarea, - label="Notes") + label="Notes") # TODO: here as well? class Meta: model = Risk_Acceptance @@ -1562,7 +1562,7 @@ class FindingBulkUpdateForm(forms.ModelForm): # unlink_from_jira = forms.BooleanField(required=False) push_to_github = forms.BooleanField(required=False) tags = TagField(required=False, autocomplete_tags=Finding.tags.tag_model.objects.all().order_by("name")) - notes = forms.CharField(required=False, max_length=1024, widget=forms.TextInput(attrs={"class": "form-control"})) + notes = forms.CharField(required=False, max_length=1024, widget=forms.TextInput(attrs={"class": "form-control"})) # TODO: Here as well? def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -1706,12 +1706,17 @@ class Meta: class NoteForm(forms.ModelForm): entry = forms.CharField(max_length=2400, widget=forms.Textarea(attrs={"rows": 4, "cols": 15}), - label="Notes:") + label="Notes:") # TODO: Here class Meta: model = Notes fields = ["entry", "private"] + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + if disclaimer := get_system_setting("disclaimer_notes"): + self.disclaimer = disclaimer.strip() + class TypedNoteForm(NoteForm): @@ -1740,7 +1745,7 @@ class CloseFindingForm(forms.ModelForm): widget=forms.Textarea, label="Notes:", error_messages={"required": ("The reason for closing a finding is " "required, please use the text area " - "below to provide documentation.")}) + "below to provide documentation.")}) # TODO: here as well mitigated = forms.DateField(required=False, help_text="Date and time when the flaw has been fixed", widget=forms.TextInput(attrs={"class": "datepicker", "autocomplete": "off"})) mitigated_by = forms.ModelChoiceField(required=False, queryset=Dojo_User.objects.none()) @@ -1809,7 +1814,7 @@ class DefectFindingForm(forms.ModelForm): widget=forms.Textarea, label="Notes:", error_messages={"required": ("The reason for closing a finding is " "required, please use the text area " - "below to provide documentation.")}) + "below to provide documentation.")}) # TODO: Here as well class Meta: model = Notes @@ -1823,7 +1828,7 @@ class ClearFindingReviewForm(forms.ModelForm): widget=forms.Textarea, label="Notes:", error_messages={"required": ("The reason for clearing a review is " "required, please use the text area " - "below to provide documentation.")}) + "below to provide documentation.")}) # TODO: here as well? class Meta: model = Finding @@ -1843,7 +1848,7 @@ class ReviewFindingForm(forms.Form): widget=forms.Textarea, label="Notes:", error_messages={"required": ("The reason for requesting a review is " "required, please use the text area " - "below to provide documentation.")}) + "below to provide documentation.")}) # TODO: here as well? allow_all_reviewers = forms.BooleanField( required=False, label="Allow All Eligible Reviewers", @@ -2308,7 +2313,7 @@ def __init__(self, *args, **kwargs): if get_system_setting("disclaimer_reports_forced"): self.fields["include_disclaimer"].disabled = True self.fields["include_disclaimer"].initial = "1" # represents yes - self.fields["include_disclaimer"].help_text="Administrator of the system enforced placement of disclaimer in all reports. You are not able exclude disclaimer from this report." + self.fields["include_disclaimer"].help_text = "Administrator of the system enforced placement of disclaimer in all reports. You are not able exclude disclaimer from this report." class CustomReportOptionsForm(forms.Form): @@ -2736,7 +2741,7 @@ class Meta: class EngagementPresetsForm(forms.ModelForm): notes = forms.CharField(widget=forms.Textarea(attrs={}), - required=False, help_text="Description of what needs to be tested or setting up environment for testing") + required=False, help_text="Description of what needs to be tested or setting up environment for testing") # TODO: here as well? scope = forms.CharField(widget=forms.Textarea(attrs={}), required=False, help_text="Scope of Engagement testing, IP's/Resources/URL's)") diff --git a/dojo/templates/dojo/form_fields.html b/dojo/templates/dojo/form_fields.html index 98706ee46d..afe8e18f4e 100644 --- a/dojo/templates/dojo/form_fields.html +++ b/dojo/templates/dojo/form_fields.html @@ -16,6 +16,13 @@ {{ field }} {% endfor %} +{% if form.disclaimer %} +
+ Disclaimer
+

{{ form.disclaimer }}

+
+{% endif %} + {% for field in form.visible_fields %}
{% if field|is_checkbox %} From be70f30c1cf708cb43ed10382a7ed6473a7425ea Mon Sep 17 00:00:00 2001 From: kiblik <5609770+kiblik@users.noreply.github.com> Date: Mon, 21 Oct 2024 20:34:26 +0200 Subject: [PATCH 4/8] Add to other places --- dojo/forms.py | 39 +++++++++++++++---- .../templates/dojo/findings_list_snippet.html | 6 +++ dojo/templates/dojo/form_fields.html | 16 ++++---- dojo/templates/dojo/view_test.html | 6 +++ 4 files changed, 51 insertions(+), 16 deletions(-) diff --git a/dojo/forms.py b/dojo/forms.py index 0fcf6c9af2..f9a52f9530 100644 --- a/dojo/forms.py +++ b/dojo/forms.py @@ -844,7 +844,7 @@ class RiskAcceptanceForm(EditRiskAcceptanceForm): help_text=("Active, verified findings listed, please select to add findings.")) notes = forms.CharField(required=False, max_length=2400, widget=forms.Textarea, - label="Notes") # TODO: here as well? + label="Notes") class Meta: model = Risk_Acceptance @@ -860,6 +860,8 @@ def __init__(self, *args, **kwargs): self.fields["expiration_date"].initial = expiration_date # self.fields['path'].help_text = 'Existing proof uploaded: %s' % self.instance.filename() if self.instance.filename() else 'None' self.fields["accepted_findings"].queryset = get_authorized_findings(Permissions.Risk_Acceptance) + if disclaimer := get_system_setting("disclaimer_notes"): + self.disclaimer = disclaimer.strip() class BaseManageFileFormSet(forms.BaseModelFormSet): @@ -1562,13 +1564,15 @@ class FindingBulkUpdateForm(forms.ModelForm): # unlink_from_jira = forms.BooleanField(required=False) push_to_github = forms.BooleanField(required=False) tags = TagField(required=False, autocomplete_tags=Finding.tags.tag_model.objects.all().order_by("name")) - notes = forms.CharField(required=False, max_length=1024, widget=forms.TextInput(attrs={"class": "form-control"})) # TODO: Here as well? + notes = forms.CharField(required=False, max_length=1024, widget=forms.TextInput(attrs={"class": "form-control"})) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["severity"].required = False # we need to defer initialization to prevent multiple initializations if other forms are shown self.fields["tags"].widget.tag_options = tagulous.models.options.TagOptions(autocomplete_settings={"width": "200px", "defer": True}) + if disclaimer := get_system_setting("disclaimer_notes"): + self.disclaimer = disclaimer.strip() def clean(self): cleaned_data = super().clean() @@ -1706,7 +1710,7 @@ class Meta: class NoteForm(forms.ModelForm): entry = forms.CharField(max_length=2400, widget=forms.Textarea(attrs={"rows": 4, "cols": 15}), - label="Notes:") # TODO: Here + label="Notes:") class Meta: model = Notes @@ -1745,7 +1749,7 @@ class CloseFindingForm(forms.ModelForm): widget=forms.Textarea, label="Notes:", error_messages={"required": ("The reason for closing a finding is " "required, please use the text area " - "below to provide documentation.")}) # TODO: here as well + "below to provide documentation.")}) mitigated = forms.DateField(required=False, help_text="Date and time when the flaw has been fixed", widget=forms.TextInput(attrs={"class": "datepicker", "autocomplete": "off"})) mitigated_by = forms.ModelChoiceField(required=False, queryset=Dojo_User.objects.none()) @@ -1768,6 +1772,8 @@ def __init__(self, *args, **kwargs): self.fields["mitigated_by"].queryset = get_authorized_users(Permissions.Test_Edit) self.fields["mitigated"].initial = self.instance.mitigated self.fields["mitigated_by"].initial = self.instance.mitigated_by + if disclaimer := get_system_setting("disclaimer_notes"): + self.disclaimer = disclaimer.strip() def _post_clean(self): super()._post_clean() @@ -1814,12 +1820,17 @@ class DefectFindingForm(forms.ModelForm): widget=forms.Textarea, label="Notes:", error_messages={"required": ("The reason for closing a finding is " "required, please use the text area " - "below to provide documentation.")}) # TODO: Here as well + "below to provide documentation.")}) class Meta: model = Notes fields = ["entry"] + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + if disclaimer := get_system_setting("disclaimer_notes"): + self.disclaimer = disclaimer.strip() + class ClearFindingReviewForm(forms.ModelForm): entry = forms.CharField( @@ -1828,12 +1839,17 @@ class ClearFindingReviewForm(forms.ModelForm): widget=forms.Textarea, label="Notes:", error_messages={"required": ("The reason for clearing a review is " "required, please use the text area " - "below to provide documentation.")}) # TODO: here as well? + "below to provide documentation.")}) class Meta: model = Finding fields = ["active", "verified", "false_p", "out_of_scope", "duplicate", "is_mitigated"] + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + if disclaimer := get_system_setting("disclaimer_notes"): + self.disclaimer = disclaimer.strip() + class ReviewFindingForm(forms.Form): reviewers = forms.MultipleChoiceField( @@ -1848,7 +1864,7 @@ class ReviewFindingForm(forms.Form): widget=forms.Textarea, label="Notes:", error_messages={"required": ("The reason for requesting a review is " "required, please use the text area " - "below to provide documentation.")}) # TODO: here as well? + "below to provide documentation.")}) allow_all_reviewers = forms.BooleanField( required=False, label="Allow All Eligible Reviewers", @@ -1871,6 +1887,8 @@ def __init__(self, *args, **kwargs): self.reviewer_queryset = users # Set the users in the form self.fields["reviewers"].choices = self._get_choices(self.reviewer_queryset) + if disclaimer := get_system_setting("disclaimer_notes"): + self.disclaimer = disclaimer.strip() @staticmethod def _get_choices(queryset): @@ -2741,7 +2759,7 @@ class Meta: class EngagementPresetsForm(forms.ModelForm): notes = forms.CharField(widget=forms.Textarea(attrs={}), - required=False, help_text="Description of what needs to be tested or setting up environment for testing") # TODO: here as well? + required=False, help_text="Description of what needs to be tested or setting up environment for testing") scope = forms.CharField(widget=forms.Textarea(attrs={}), required=False, help_text="Scope of Engagement testing, IP's/Resources/URL's)") @@ -2750,6 +2768,11 @@ class Meta: model = Engagement_Presets exclude = ["product"] + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + if disclaimer := get_system_setting("disclaimer_notes"): + self.disclaimer = disclaimer.strip() + class DeleteEngagementPresetsForm(forms.ModelForm): id = forms.IntegerField(required=True, diff --git a/dojo/templates/dojo/findings_list_snippet.html b/dojo/templates/dojo/findings_list_snippet.html index 51e85ab8d1..c83ba1f22f 100644 --- a/dojo/templates/dojo/findings_list_snippet.html +++ b/dojo/templates/dojo/findings_list_snippet.html @@ -253,6 +253,12 @@

{{ bulk_edit_form.media.js }} {% endcomment %} {{ bulk_edit_form.tags }} + {% if bulk_edit_form.disclaimer %} +
+
Disclaimer
+
{{ bulk_edit_form.disclaimer }}
+
+ {% endif %} diff --git a/dojo/templates/dojo/form_fields.html b/dojo/templates/dojo/form_fields.html index afe8e18f4e..6af19a96aa 100644 --- a/dojo/templates/dojo/form_fields.html +++ b/dojo/templates/dojo/form_fields.html @@ -16,13 +16,6 @@ {{ field }} {% endfor %} -{% if form.disclaimer %} -
- Disclaimer
-

{{ form.disclaimer }}

-
-{% endif %} - {% for field in form.visible_fields %}
{% if field|is_checkbox %} @@ -87,4 +80,11 @@
{% endif %}

-{% endfor %} \ No newline at end of file +{% endfor %} + +{% if form.disclaimer %} +
+
Disclaimer
+
{{ form.disclaimer }}
+
+{% endif %} diff --git a/dojo/templates/dojo/view_test.html b/dojo/templates/dojo/view_test.html index a4e0390b91..e551c4858e 100644 --- a/dojo/templates/dojo/view_test.html +++ b/dojo/templates/dojo/view_test.html @@ -848,6 +848,12 @@

{{ bulk_edit_form.media.css }} {{ bulk_edit_form.media.js }} {{ bulk_edit_form.tags }} + {% if bulk_edit_form.disclaimer %} +
+
Disclaimer
+
{{ bulk_edit_form.disclaimer }}
+
+ {% endif %} Date: Mon, 21 Oct 2024 21:17:37 +0200 Subject: [PATCH 5/8] fix rendering of disc. in report --- .../0218_system_settings_disclaimer_notif.py | 38 ------------------- .../0219_system_settings_disclaimer_notif.py | 37 +++++++++++++----- .../0220_system_settings_disclaimer_notif.py | 21 ++++++++++ dojo/reports/views.py | 9 ++++- dojo/templates/dojo/custom_html_report.html | 6 +++ dojo/templates/dojo/endpoint_pdf_report.html | 2 +- .../templates/dojo/engagement_pdf_report.html | 2 +- dojo/templates/dojo/finding_pdf_report.html | 2 +- .../dojo/product_endpoint_pdf_report.html | 2 +- dojo/templates/dojo/product_pdf_report.html | 2 +- .../dojo/product_type_pdf_report.html | 2 +- dojo/templates/dojo/test_pdf_report.html | 2 +- 12 files changed, 69 insertions(+), 56 deletions(-) delete mode 100644 dojo/db_migrations/0218_system_settings_disclaimer_notif.py create mode 100644 dojo/db_migrations/0220_system_settings_disclaimer_notif.py diff --git a/dojo/db_migrations/0218_system_settings_disclaimer_notif.py b/dojo/db_migrations/0218_system_settings_disclaimer_notif.py deleted file mode 100644 index 6d966e414a..0000000000 --- a/dojo/db_migrations/0218_system_settings_disclaimer_notif.py +++ /dev/null @@ -1,38 +0,0 @@ -# Generated by Django 5.0.8 on 2024-09-12 18:22 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('dojo', '0217_jira_project_enabled'), - ] - - operations = [ - migrations.RenameField( - model_name='system_settings', - old_name='disclaimer', - new_name='disclaimer_notifications', - ), - migrations.AlterField( - model_name='system_settings', - name='disclaimer_notifications', - field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer on all notifications', max_length=3000, verbose_name='Custom Disclaimer for Notifications'), - ), - migrations.AddField( - model_name='system_settings', - name='disclaimer_reports', - field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer on generated reports', max_length=5000, verbose_name='Custom Disclaimer for Reports'), - ), - migrations.AddField( - model_name='system_settings', - name='disclaimer_notes', - field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer next to input form for notes', max_length=3000, verbose_name='Custom Disclaimer for Notes'), - ), - migrations.AddField( - model_name='system_settings', - name='disclaimer_reports_forced', - field=models.BooleanField(default=False, help_text="Disclaimer will be added to all reports even if user didn't selected 'Include disclaimer'.", verbose_name='Force to add disclaimer reports'), - ), - ] diff --git a/dojo/db_migrations/0219_system_settings_disclaimer_notif.py b/dojo/db_migrations/0219_system_settings_disclaimer_notif.py index 84aeffe4b0..4f57cad2f1 100644 --- a/dojo/db_migrations/0219_system_settings_disclaimer_notif.py +++ b/dojo/db_migrations/0219_system_settings_disclaimer_notif.py @@ -1,21 +1,38 @@ # Generated by Django 5.0.8 on 2024-09-12 18:22 -from django.db import migrations - - -def copy_notif_field(apps, schema_editor): - system_settings_model = apps.get_model('dojo', 'System_Settings').objects.get() - if system_settings_model.disclaimer_notifications: - system_settings_model.disclaimer_reports = system_settings_model.disclaimer_notifications - system_settings_model.save() +from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('dojo', '0218_system_settings_disclaimer_notif'), + ('dojo', '0218_system_settings_enforce_verified_status_and_more'), ] operations = [ - migrations.RunPython(copy_notif_field), + migrations.RenameField( + model_name='system_settings', + old_name='disclaimer', + new_name='disclaimer_notifications', + ), + migrations.AlterField( + model_name='system_settings', + name='disclaimer_notifications', + field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer on all notifications', max_length=3000, verbose_name='Custom Disclaimer for Notifications'), + ), + migrations.AddField( + model_name='system_settings', + name='disclaimer_reports', + field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer on generated reports', max_length=5000, verbose_name='Custom Disclaimer for Reports'), + ), + migrations.AddField( + model_name='system_settings', + name='disclaimer_notes', + field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer next to input form for notes', max_length=3000, verbose_name='Custom Disclaimer for Notes'), + ), + migrations.AddField( + model_name='system_settings', + name='disclaimer_reports_forced', + field=models.BooleanField(default=False, help_text="Disclaimer will be added to all reports even if user didn't selected 'Include disclaimer'.", verbose_name='Force to add disclaimer reports'), + ), ] diff --git a/dojo/db_migrations/0220_system_settings_disclaimer_notif.py b/dojo/db_migrations/0220_system_settings_disclaimer_notif.py new file mode 100644 index 0000000000..ceb126d6ab --- /dev/null +++ b/dojo/db_migrations/0220_system_settings_disclaimer_notif.py @@ -0,0 +1,21 @@ +# Generated by Django 5.0.8 on 2024-09-12 18:22 + +from django.db import migrations + + +def copy_notif_field(apps, schema_editor): + system_settings_model = apps.get_model('dojo', 'System_Settings').objects.get() + if system_settings_model.disclaimer_notifications: + system_settings_model.disclaimer_reports = system_settings_model.disclaimer_notifications + system_settings_model.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('dojo', '0219_system_settings_disclaimer_notif'), + ] + + operations = [ + migrations.RunPython(copy_notif_field), + ] diff --git a/dojo/reports/views.py b/dojo/reports/views.py index 390e402cb1..c57931df10 100644 --- a/dojo/reports/views.py +++ b/dojo/reports/views.py @@ -132,6 +132,10 @@ def _set_state(self, request: HttpRequest): self.host = report_url_resolver(request) self.selected_widgets = self.get_selected_widgets(request) self.widgets = list(self.selected_widgets.values()) + self.include_disclaimer = get_system_setting("disclaimer_reports_forced", 0) + self.disclaimer = get_system_setting("disclaimer_reports") + if self.include_disclaimer and len(self.disclaimer) == 0: + self.disclaimer = "Please configure in System Settings." def get_selected_widgets(self, request): selected_widgets = report_widget_factory(json_data=request.POST["json"], request=request, host=self.host, @@ -164,7 +168,10 @@ def get_context(self): "host": self.host, "finding_notes": self.finding_notes, "finding_images": self.finding_images, - "user_id": self.request.user.id} + "user_id": self.request.user.id, + "include_disclaimer": self.include_disclaimer, + "disclaimer": self.disclaimer, + } def report_findings(request): diff --git a/dojo/templates/dojo/custom_html_report.html b/dojo/templates/dojo/custom_html_report.html index de89837f74..db7b4e3c07 100644 --- a/dojo/templates/dojo/custom_html_report.html +++ b/dojo/templates/dojo/custom_html_report.html @@ -3,6 +3,12 @@ {% block content %} {{ block.super }}
+ {% if include_disclaimer %} +
+ Disclaimer
+

{{ disclaimer | safe }}

+
+ {% endif %} {% for widget in widgets %} {{ widget.get_html }} {% endfor %} diff --git a/dojo/templates/dojo/endpoint_pdf_report.html b/dojo/templates/dojo/endpoint_pdf_report.html index b214afadb3..10cf2804c9 100644 --- a/dojo/templates/dojo/endpoint_pdf_report.html +++ b/dojo/templates/dojo/endpoint_pdf_report.html @@ -81,7 +81,7 @@
{% if include_disclaimer%}
Disclaimer
-

{{ disclaimer }}

+

{{ disclaimer | safe }}

{% endif %}
diff --git a/dojo/templates/dojo/engagement_pdf_report.html b/dojo/templates/dojo/engagement_pdf_report.html index a9c8ac8101..ff34127435 100644 --- a/dojo/templates/dojo/engagement_pdf_report.html +++ b/dojo/templates/dojo/engagement_pdf_report.html @@ -158,7 +158,7 @@
{% if include_disclaimer%}
Disclaimer
-

{{ disclaimer }}

+

{{ disclaimer | safe }}

{% endif %}
diff --git a/dojo/templates/dojo/finding_pdf_report.html b/dojo/templates/dojo/finding_pdf_report.html index 6d376c15bc..ea051d43d0 100644 --- a/dojo/templates/dojo/finding_pdf_report.html +++ b/dojo/templates/dojo/finding_pdf_report.html @@ -57,7 +57,7 @@
{% if include_disclaimer%}
Disclaimer
-

{{ disclaimer }}

+

{{ disclaimer | safe }}

{% endif %}
diff --git a/dojo/templates/dojo/product_endpoint_pdf_report.html b/dojo/templates/dojo/product_endpoint_pdf_report.html index 614fa0f00f..0a1cb6e523 100644 --- a/dojo/templates/dojo/product_endpoint_pdf_report.html +++ b/dojo/templates/dojo/product_endpoint_pdf_report.html @@ -119,7 +119,7 @@
Finding Age
{% if include_disclaimer%}
Disclaimer
-

{{ disclaimer }}

+

{{ disclaimer | safe }}

{% endif %}
diff --git a/dojo/templates/dojo/product_pdf_report.html b/dojo/templates/dojo/product_pdf_report.html index b02b2609de..2548050275 100644 --- a/dojo/templates/dojo/product_pdf_report.html +++ b/dojo/templates/dojo/product_pdf_report.html @@ -142,7 +142,7 @@
Finding Age
{% if include_disclaimer%}
Disclaimer
-

{{ disclaimer }}

+

{{ disclaimer | safe }}

{% endif %}
diff --git a/dojo/templates/dojo/product_type_pdf_report.html b/dojo/templates/dojo/product_type_pdf_report.html index 4b0fc48d9f..ec550d1524 100644 --- a/dojo/templates/dojo/product_type_pdf_report.html +++ b/dojo/templates/dojo/product_type_pdf_report.html @@ -114,7 +114,7 @@

{% if include_disclaimer%}
Disclaimer
-

{{ disclaimer }}

+

{{ disclaimer | safe }}

{% endif %}
diff --git a/dojo/templates/dojo/test_pdf_report.html b/dojo/templates/dojo/test_pdf_report.html index e9ec79d6aa..b1d1cd7b5f 100644 --- a/dojo/templates/dojo/test_pdf_report.html +++ b/dojo/templates/dojo/test_pdf_report.html @@ -146,7 +146,7 @@
{% if include_disclaimer%}
Disclaimer
-

{{ disclaimer }}

+

{{ disclaimer | safe }}

{% endif %}
From 613061212e8665e584a1d5cfac706f20413ca499 Mon Sep 17 00:00:00 2001 From: kiblik <5609770+kiblik@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:34:12 +0100 Subject: [PATCH 6/8] Add reverse_code to DB migration --- dojo/db_migrations/0220_system_settings_disclaimer_notif.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dojo/db_migrations/0220_system_settings_disclaimer_notif.py b/dojo/db_migrations/0220_system_settings_disclaimer_notif.py index ceb126d6ab..3a6910381f 100644 --- a/dojo/db_migrations/0220_system_settings_disclaimer_notif.py +++ b/dojo/db_migrations/0220_system_settings_disclaimer_notif.py @@ -17,5 +17,5 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RunPython(copy_notif_field), + migrations.RunPython(copy_notif_field, reverse_code=migrations.RunPython.noop), ] From d1e7c55906ccec9e6be7483c5a37f888fc41c3b2 Mon Sep 17 00:00:00 2001 From: kiblik <5609770+kiblik@users.noreply.github.com> Date: Wed, 15 Jan 2025 17:23:44 +0100 Subject: [PATCH 7/8] Add info to upgrade notes --- docs/content/en/open_source/upgrading/2.43.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/content/en/open_source/upgrading/2.43.md b/docs/content/en/open_source/upgrading/2.43.md index faa443cfea..596b2a0080 100644 --- a/docs/content/en/open_source/upgrading/2.43.md +++ b/docs/content/en/open_source/upgrading/2.43.md @@ -2,6 +2,9 @@ title: 'Upgrading to DefectDojo Version 2.43.x' toc_hide: true weight: -20250106 -description: No special instructions. +description: Disclaimer field renamed/split. --- -There are no special instructions for upgrading to 2.43.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.43.0) for the contents of the release. + +[Pull request #10902](https://github.com/DefectDojo/django-DefectDojo/pull/10902) introduced different kinds of disclaimers within the DefectDojo instance. The original content of the disclaimer was copied to all new fields where it had been used until now (so this change does not require any action on the user's side). However, if users were managing the original disclaimer via API (endpoint `/api/v2/system_settings/1/`, field `disclaimer`), be aware that the fields are now called `disclaimer_notifications` and `disclaimer_reports` (plus there is one additional, previously unused field called `disclaimer_notes`). + +But there are no other special instructions for upgrading to 2.43.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.43.0) for the contents of the release. From 564ccdcdbef8d8f8cec078019caf40cb99209b6a Mon Sep 17 00:00:00 2001 From: kiblik <5609770+kiblik@users.noreply.github.com> Date: Tue, 21 Jan 2025 21:50:05 +0100 Subject: [PATCH 8/8] Inc db-mig --- .../0219_system_settings_disclaimer_notif.py | 38 ------------------- .../0220_system_settings_disclaimer_notif.py | 37 +++++++++++++----- .../0221_system_settings_disclaimer_notif.py | 21 ++++++++++ 3 files changed, 48 insertions(+), 48 deletions(-) delete mode 100644 dojo/db_migrations/0219_system_settings_disclaimer_notif.py create mode 100644 dojo/db_migrations/0221_system_settings_disclaimer_notif.py diff --git a/dojo/db_migrations/0219_system_settings_disclaimer_notif.py b/dojo/db_migrations/0219_system_settings_disclaimer_notif.py deleted file mode 100644 index 4f57cad2f1..0000000000 --- a/dojo/db_migrations/0219_system_settings_disclaimer_notif.py +++ /dev/null @@ -1,38 +0,0 @@ -# Generated by Django 5.0.8 on 2024-09-12 18:22 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('dojo', '0218_system_settings_enforce_verified_status_and_more'), - ] - - operations = [ - migrations.RenameField( - model_name='system_settings', - old_name='disclaimer', - new_name='disclaimer_notifications', - ), - migrations.AlterField( - model_name='system_settings', - name='disclaimer_notifications', - field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer on all notifications', max_length=3000, verbose_name='Custom Disclaimer for Notifications'), - ), - migrations.AddField( - model_name='system_settings', - name='disclaimer_reports', - field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer on generated reports', max_length=5000, verbose_name='Custom Disclaimer for Reports'), - ), - migrations.AddField( - model_name='system_settings', - name='disclaimer_notes', - field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer next to input form for notes', max_length=3000, verbose_name='Custom Disclaimer for Notes'), - ), - migrations.AddField( - model_name='system_settings', - name='disclaimer_reports_forced', - field=models.BooleanField(default=False, help_text="Disclaimer will be added to all reports even if user didn't selected 'Include disclaimer'.", verbose_name='Force to add disclaimer reports'), - ), - ] diff --git a/dojo/db_migrations/0220_system_settings_disclaimer_notif.py b/dojo/db_migrations/0220_system_settings_disclaimer_notif.py index 3a6910381f..77a9d836c7 100644 --- a/dojo/db_migrations/0220_system_settings_disclaimer_notif.py +++ b/dojo/db_migrations/0220_system_settings_disclaimer_notif.py @@ -1,21 +1,38 @@ # Generated by Django 5.0.8 on 2024-09-12 18:22 -from django.db import migrations - - -def copy_notif_field(apps, schema_editor): - system_settings_model = apps.get_model('dojo', 'System_Settings').objects.get() - if system_settings_model.disclaimer_notifications: - system_settings_model.disclaimer_reports = system_settings_model.disclaimer_notifications - system_settings_model.save() +from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('dojo', '0219_system_settings_disclaimer_notif'), + ('dojo', '0219_system_settings_enforce_verified_status_jira_and_more'), ] operations = [ - migrations.RunPython(copy_notif_field, reverse_code=migrations.RunPython.noop), + migrations.RenameField( + model_name='system_settings', + old_name='disclaimer', + new_name='disclaimer_notifications', + ), + migrations.AlterField( + model_name='system_settings', + name='disclaimer_notifications', + field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer on all notifications', max_length=3000, verbose_name='Custom Disclaimer for Notifications'), + ), + migrations.AddField( + model_name='system_settings', + name='disclaimer_reports', + field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer on generated reports', max_length=5000, verbose_name='Custom Disclaimer for Reports'), + ), + migrations.AddField( + model_name='system_settings', + name='disclaimer_notes', + field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer next to input form for notes', max_length=3000, verbose_name='Custom Disclaimer for Notes'), + ), + migrations.AddField( + model_name='system_settings', + name='disclaimer_reports_forced', + field=models.BooleanField(default=False, help_text="Disclaimer will be added to all reports even if user didn't selected 'Include disclaimer'.", verbose_name='Force to add disclaimer reports'), + ), ] diff --git a/dojo/db_migrations/0221_system_settings_disclaimer_notif.py b/dojo/db_migrations/0221_system_settings_disclaimer_notif.py new file mode 100644 index 0000000000..8a97935064 --- /dev/null +++ b/dojo/db_migrations/0221_system_settings_disclaimer_notif.py @@ -0,0 +1,21 @@ +# Generated by Django 5.0.8 on 2024-09-12 18:22 + +from django.db import migrations + + +def copy_notif_field(apps, schema_editor): + system_settings_model = apps.get_model('dojo', 'System_Settings').objects.get() + if system_settings_model.disclaimer_notifications: + system_settings_model.disclaimer_reports = system_settings_model.disclaimer_notifications + system_settings_model.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('dojo', '0220_system_settings_disclaimer_notif'), + ] + + operations = [ + migrations.RunPython(copy_notif_field, reverse_code=migrations.RunPython.noop), + ]