Commit fd67ea2f authored by Mehmet Emin INAC's avatar Mehmet Emin INAC

Send `finding_uuid` to backend while creating feedback

As we are transitioning from using compound keys to UUID values as
the foreign between the feedback and finding records, we need to send
UUID values to backend while creating the feedback records.
parent a5fb595d
...@@ -91,6 +91,7 @@ export const createIssue = ({ dispatch }, { vulnerability, flashError }) => { ...@@ -91,6 +91,7 @@ export const createIssue = ({ dispatch }, { vulnerability, flashError }) => {
feedback_type: FEEDBACK_TYPE_ISSUE, feedback_type: FEEDBACK_TYPE_ISSUE,
category: vulnerability.report_type, category: vulnerability.report_type,
project_fingerprint: vulnerability.project_fingerprint, project_fingerprint: vulnerability.project_fingerprint,
finding_uuid: vulnerability.uuid,
vulnerability_data: { vulnerability_data: {
...vulnerability, ...vulnerability,
category: vulnerability.report_type, category: vulnerability.report_type,
...@@ -154,6 +155,7 @@ export const dismissSelectedVulnerabilities = ({ dispatch, state }, { comment } ...@@ -154,6 +155,7 @@ export const dismissSelectedVulnerabilities = ({ dispatch, state }, { comment }
comment, comment,
feedback_type: FEEDBACK_TYPE_DISMISSAL, feedback_type: FEEDBACK_TYPE_DISMISSAL,
project_fingerprint: vulnerability.project_fingerprint, project_fingerprint: vulnerability.project_fingerprint,
finding_uuid: vulnerability.uuid,
vulnerability_data: { vulnerability_data: {
id: vulnerability.id, id: vulnerability.id,
}, },
...@@ -240,6 +242,7 @@ export const dismissVulnerability = ( ...@@ -240,6 +242,7 @@ export const dismissVulnerability = (
feedback_type: FEEDBACK_TYPE_DISMISSAL, feedback_type: FEEDBACK_TYPE_DISMISSAL,
pipeline_id: state.pipelineId, pipeline_id: state.pipelineId,
project_fingerprint: vulnerability.project_fingerprint, project_fingerprint: vulnerability.project_fingerprint,
finding_uuid: vulnerability.uuid,
vulnerability_data: { vulnerability_data: {
...vulnerability, ...vulnerability,
category: vulnerability.report_type, category: vulnerability.report_type,
...@@ -442,6 +445,7 @@ export const createMergeRequest = ({ state, dispatch }, { vulnerability, flashEr ...@@ -442,6 +445,7 @@ export const createMergeRequest = ({ state, dispatch }, { vulnerability, flashEr
feedback_type: FEEDBACK_TYPE_MERGE_REQUEST, feedback_type: FEEDBACK_TYPE_MERGE_REQUEST,
category: report_type, category: report_type,
project_fingerprint, project_fingerprint,
finding_uuid: vulnerability.uuid,
vulnerability_data: { vulnerability_data: {
...vulnerability, ...vulnerability,
target_branch: targetBranch, target_branch: targetBranch,
......
...@@ -204,6 +204,7 @@ export const dismissVulnerability = ({ state, dispatch }, comment) => { ...@@ -204,6 +204,7 @@ export const dismissVulnerability = ({ state, dispatch }, comment) => {
feedback_type: FEEDBACK_TYPE_DISMISSAL, feedback_type: FEEDBACK_TYPE_DISMISSAL,
pipeline_id: state.pipelineId, pipeline_id: state.pipelineId,
project_fingerprint: state.modal.vulnerability.project_fingerprint, project_fingerprint: state.modal.vulnerability.project_fingerprint,
finding_uuid: state.modal.vulnerability.uuid,
vulnerability_data: state.modal.vulnerability, vulnerability_data: state.modal.vulnerability,
}, },
}) })
...@@ -367,6 +368,7 @@ export const createNewIssue = ({ state, dispatch }) => { ...@@ -367,6 +368,7 @@ export const createNewIssue = ({ state, dispatch }) => {
feedback_type: FEEDBACK_TYPE_ISSUE, feedback_type: FEEDBACK_TYPE_ISSUE,
category: state.modal.vulnerability.category, category: state.modal.vulnerability.category,
project_fingerprint: state.modal.vulnerability.project_fingerprint, project_fingerprint: state.modal.vulnerability.project_fingerprint,
finding_uuid: state.modal.vulnerability.uuid,
pipeline_id: state.pipelineId, pipeline_id: state.pipelineId,
vulnerability_data: state.modal.vulnerability, vulnerability_data: state.modal.vulnerability,
}, },
...@@ -398,6 +400,7 @@ export const createMergeRequest = ({ state, dispatch }) => { ...@@ -398,6 +400,7 @@ export const createMergeRequest = ({ state, dispatch }) => {
feedback_type: FEEDBACK_TYPE_MERGE_REQUEST, feedback_type: FEEDBACK_TYPE_MERGE_REQUEST,
category, category,
project_fingerprint, project_fingerprint,
finding_uuid: vulnerability.uuid,
vulnerability_data: vulnerability, vulnerability_data: vulnerability,
}, },
}) })
......
# frozen_string_literal: true # frozen_string_literal: true
module VulnerabilitiesHelper module VulnerabilitiesHelper
FINDING_FIELDS = %i[metadata identifiers name issue_feedback merge_request_feedback project project_fingerprint scanner].freeze FINDING_FIELDS = %i[metadata identifiers name issue_feedback merge_request_feedback project project_fingerprint scanner uuid].freeze
def vulnerability_details_json(vulnerability, pipeline) def vulnerability_details_json(vulnerability, pipeline)
vulnerability_details(vulnerability, pipeline).to_json vulnerability_details(vulnerability, pipeline).to_json
......
...@@ -38,10 +38,11 @@ RSpec.describe VulnerabilitiesHelper do ...@@ -38,10 +38,11 @@ RSpec.describe VulnerabilitiesHelper do
:issue_feedback, :issue_feedback,
:project, :project,
:remediations, :remediations,
:solution) :solution,
:uuid)
end end
let(:desired_serializer_fields) { %i[metadata identifiers name issue_feedback merge_request_feedback project project_fingerprint scanner] } let(:desired_serializer_fields) { %i[metadata identifiers name issue_feedback merge_request_feedback project project_fingerprint scanner uuid] }
before do before do
vulnerability_serializer_stub = instance_double("VulnerabilitySerializer") vulnerability_serializer_stub = instance_double("VulnerabilitySerializer")
...@@ -247,7 +248,8 @@ RSpec.describe VulnerabilitiesHelper do ...@@ -247,7 +248,8 @@ RSpec.describe VulnerabilitiesHelper do
response: kind_of(Grape::Entity::Exposure::NestingExposure::OutputBuilder), response: kind_of(Grape::Entity::Exposure::NestingExposure::OutputBuilder),
evidence_source: anything, evidence_source: anything,
assets: kind_of(Array), assets: kind_of(Array),
supporting_messages: kind_of(Array) supporting_messages: kind_of(Array),
uuid: kind_of(String)
) )
expect(subject[:location]['blob_path']).to match(kind_of(String)) expect(subject[:location]['blob_path']).to match(kind_of(String))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment