Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Similar Findings: Create Toggle #10047

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions dojo/db_migrations/0211_system_settings_enable_similar_findings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.13 on 2024-04-26 21:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('dojo', '0210_system_settings_filter_string_matching'),
]

operations = [
migrations.AddField(
model_name='system_settings',
name='enable_similar_findings',
field=models.BooleanField(default=True, help_text='Enable the query of similar findings on the view finding page. This feature can involve potentially large queries and negatively impact performance', verbose_name='Enable Similar Findings'),
),
]
9 changes: 9 additions & 0 deletions dojo/finding/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,14 @@ def get_test_import_data(self, request: HttpRequest, finding: Finding):
}

def get_similar_findings(self, request: HttpRequest, finding: Finding):
similar_findings_enabled = get_system_setting("enable_similar_findings", True)
if similar_findings_enabled is False:
return {
"similar_findings_enabled": similar_findings_enabled,
"duplicate_cluster": duplicate_cluster(request, finding),
"similar_findings": None,
"similar_findings_filter": None,
}
# add related actions for non-similar and non-duplicate cluster members
finding.related_actions = calculate_possible_related_actions_for_similar_finding(
request, finding, finding
Expand Down Expand Up @@ -638,6 +646,7 @@ def get_similar_findings(self, request: HttpRequest, finding: Finding):
)

return {
"similar_findings_enabled": similar_findings_enabled,
"duplicate_cluster": duplicate_cluster(request, finding),
"similar_findings": similar_findings,
"similar_findings_filter": similar_findings_filter,
Expand Down
6 changes: 6 additions & 0 deletions dojo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@ class System_Settings(models.Model):
verbose_name=_('Enable Remediation Advice'),
help_text=_("Enables global remediation advice and matching on CWE and Title. The text will be replaced for mitigation, impact and references on a finding. Useful for providing consistent impact and remediation advice regardless of the scanner."))

enable_similar_findings = models.BooleanField(
default=True,
blank=False,
verbose_name=_("Enable Similar Findings"),
help_text=_("Enable the query of similar findings on the view finding page. This feature can involve potentially large queries and negatively impact performance"))

engagement_auto_close = models.BooleanField(
default=False,
blank=False,
Expand Down
2 changes: 1 addition & 1 deletion dojo/templates/dojo/edit_finding.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ <h4> GitHub </h4>
if ($("#id_duplicate").prop("checked")) {
$("#id_duplicate").parent().parent().append(original_finding)
} else {
$("#id_duplicate").click(function(){ alert('findings can only be marked as duplicates from the view finding screen'); return false; });
$("#id_duplicate").click(function(){ alert('findings can only be marked as duplicates from the view finding screen. Similar Findings must be enabled for this operation.'); return false; });
}
};

Expand Down
5 changes: 3 additions & 2 deletions dojo/templates/dojo/view_finding.html
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ <h4>Duplicate Cluster ({{ finding|finding_duplicate_cluster_size }})<span class=
</div>
{% endif %}

{% if similar_findings_enabled %}
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="has-filters">Similar Findings ({{ similar_findings.paginator.count }})
Expand Down Expand Up @@ -759,8 +760,8 @@ <h4 class="has-filters">Similar Findings ({{ similar_findings.paginator.count }}
</div>
{% endif %}
</span>
</div>

</div>
{% endif %}
{% comment %} Add a form to (ab)use to submit any actions related to similar/duplicates as POST requests {% endcomment %}
<form method="post" style="display: none" id="related_action">
{% csrf_token %}
Expand Down
Loading