-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
dissallow already linked issue #11298
base: bugfix
Are you sure you want to change the base?
Conversation
DryRun Security SummaryThe pull request focuses on improving the handling of JIRA issue linking in the Defect Dojo application by introducing a new function to check if a finding is already linked to a JIRA issue and using it in the Expand for full summarySummary: The code changes in this pull request focus on improving the handling of JIRA issue linking in the Defect Dojo application. The changes introduce a new function, These changes are a positive step in maintaining data integrity and preventing duplicate JIRA issues from being created, which could lead to confusion and potential security issues. By ensuring that JIRA issues are uniquely linked to findings, the application can improve its overall security and traceability. Overall, these code changes appear to be a reasonable and appropriate security-focused update to the Defect Dojo application. Files Changed:
Code AnalysisWe ran Riskiness🟢 Risk threshold not exceeded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the function to return the whole finding rather than just the ID. It could be useful in the future
def jira_already_linked(finding, jira_issue_key, jira_id): | ||
jira_issues = JIRA_Issue.objects.filter(jira_id=jira_id, jira_key=jira_issue_key).exclude(engagement__isnull=False) | ||
jira_issues = jira_issues.exclude(finding=finding) | ||
|
||
result = 0 | ||
if len(jira_issues) > 0: | ||
result = jira_issues[0].finding_id | ||
|
||
return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def jira_already_linked(finding, jira_issue_key, jira_id): | |
jira_issues = JIRA_Issue.objects.filter(jira_id=jira_id, jira_key=jira_issue_key).exclude(engagement__isnull=False) | |
jira_issues = jira_issues.exclude(finding=finding) | |
result = 0 | |
if len(jira_issues) > 0: | |
result = jira_issues[0].finding_id | |
return result | |
def jira_already_linked(finding, jira_issue_key, jira_id) -> Finding | None: | |
jira_issues = JIRA_Issue.objects.filter(jira_id=jira_id, jira_key=jira_issue_key).exclude(engagement__isnull=False) | |
jira_issues = jira_issues.exclude(finding=finding) | |
return jira_issues.first() |
linked_finding = jira_helper.jira_already_linked(finding, data.get("jira_key"), data.get("jira_id")) | ||
if linked_finding: | ||
msg = "JIRA issue " + data.get("jira_key") + " already linked to " + reverse("view_finding", args=(linked_finding,)) | ||
raise serializers.ValidationError(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linked_finding = jira_helper.jira_already_linked(finding, data.get("jira_key"), data.get("jira_id")) | |
if linked_finding: | |
msg = "JIRA issue " + data.get("jira_key") + " already linked to " + reverse("view_finding", args=(linked_finding,)) | |
raise serializers.ValidationError(msg) | |
if (linked_finding := jira_helper.jira_already_linked(finding, data.get("jira_key"), data.get("jira_id"))) is not None: | |
msg = "JIRA issue " + data.get("jira_key") + " already linked to " + reverse("view_finding", args=(linked_finding.id,)) | |
raise serializers.ValidationError(msg) |
[sc-5525]
Fixes #9930
When using the jira_finding_mappings API endpoint, trying to update a finding's Jira mapping with a Jira issue that is already assigned to another finding will now raise a validation error.