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 35dc31d13ab..6d966e414a0 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 00000000000..84aeffe4b03 --- /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 031c70a6c97..e247f5f9093 100644 --- a/dojo/forms.py +++ b/dojo/forms.py @@ -828,7 +828,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 @@ -1545,7 +1545,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) @@ -1689,12 +1689,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): @@ -1723,7 +1728,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()) @@ -1792,7 +1797,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 @@ -1806,7 +1811,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 @@ -1826,7 +1831,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", @@ -2293,7 +2298,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): @@ -2721,7 +2726,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 98706ee46d3..afe8e18f4e3 100644 --- a/dojo/templates/dojo/form_fields.html +++ b/dojo/templates/dojo/form_fields.html @@ -16,6 +16,13 @@ {{ field }} {% endfor %} +{% if form.disclaimer %} +
{{ form.disclaimer }}
+