diff --git a/ee/app/assets/javascripts/security_dashboard/components/shared/vulnerability_details_graphql/index.vue b/ee/app/assets/javascripts/security_dashboard/components/shared/vulnerability_details_graphql/index.vue index 09c5a2968eee0635f58483495a800aa6c2d7cb4b..a25bab810f515daeb6f8c6fa6d493817cd918ce9 100644 --- a/ee/app/assets/javascripts/security_dashboard/components/shared/vulnerability_details_graphql/index.vue +++ b/ee/app/assets/javascripts/security_dashboard/components/shared/vulnerability_details_graphql/index.vue @@ -8,6 +8,7 @@ import CodeBlock from '~/vue_shared/components/code_block.vue'; import GenericReportSection from 'ee/vulnerabilities/components/generic_report/report_section_graphql.vue'; import SafeHtml from '~/vue_shared/directives/safe_html'; import { getHttpString } from 'ee/vue_shared/security_reports/components/helpers'; +import { SUPPORTING_MESSAGE_TYPES } from 'ee/vulnerabilities/constants'; import { REPORT_TYPES_TO_HUMAN_READABLE } from './constants'; import DetailsSection from './details_section.vue'; import DetailsSectionListItem from './details_section_list_item.vue'; @@ -30,6 +31,7 @@ export default { requestResponseHeading: s__('Vulnerability|Request/Response'), requestLabel: s__('Vulnerability|Sent request:'), responseLabel: s__('Vulnerability|Actual response:'), + recordedResponseLabel: s__('Vulnerability|Unmodified response:'), additionalInfoHeading: s__('Vulnerability|Additional Info'), assertLabel: s__('Vulnerability|Assert:'), }, @@ -141,6 +143,12 @@ export default { evidenceSummary() { return this.evidence?.summary; }, + recordedResponseString() { + const recordedResponse = this.evidence?.supportingMessages?.find( + (msg) => msg.name === SUPPORTING_MESSAGE_TYPES.RECORDED, + )?.response; + return getHttpString(recordedResponse); + }, }, }; </script> @@ -264,7 +272,7 @@ export default { </details-section> <details-section - v-if="requestString || responseString" + v-if="requestString || responseString || recordedResponseString" :heading="$options.i18n.requestResponseHeading" data-testid="request-response-section" > @@ -277,6 +285,14 @@ export default { <code-block class="gl-mt-3" :code="requestString" max-height="225px" /> </details-section-list-item> + <details-section-list-item + v-if="recordedResponseString" + :label="$options.i18n.recordedResponseLabel" + data-testid="recorded-response-item" + > + <code-block class="gl-mt-3" :code="recordedResponseString" max-height="225px" /> + </details-section-list-item> + <details-section-list-item v-if="responseString" :label="$options.i18n.responseLabel" diff --git a/ee/app/assets/javascripts/security_dashboard/graphql/queries/security_report_finding.query.graphql b/ee/app/assets/javascripts/security_dashboard/graphql/queries/security_report_finding.query.graphql index e8591d8f1ef6fe27c8787f632c06643f159174f0..d882895661305d270c28def0b96606b3517fac82 100644 --- a/ee/app/assets/javascripts/security_dashboard/graphql/queries/security_report_finding.query.graphql +++ b/ee/app/assets/javascripts/security_dashboard/graphql/queries/security_report_finding.query.graphql @@ -67,6 +67,18 @@ query getSecurityReportFinding($projectFullPath: ID!, $pipelineIid: ID!, $findin value } } + supportingMessages { + name + response { + body + reasonPhrase + statusCode + headers { + name + value + } + } + } source { name } diff --git a/ee/spec/frontend/security_dashboard/components/pipeline/mock_data.js b/ee/spec/frontend/security_dashboard/components/pipeline/mock_data.js index 7547d2a75848d5e0fac379fa87960c5623b318b8..ed4dfc7161f28a66aab36395fb75c0b5e1b35809 100644 --- a/ee/spec/frontend/security_dashboard/components/pipeline/mock_data.js +++ b/ee/spec/frontend/security_dashboard/components/pipeline/mock_data.js @@ -521,6 +521,20 @@ export const pipelineSecurityReportFinding = { { name: 'response headers name - 2', value: 'response headers value - 2' }, ], }, + supportingMessages: [ + { + name: 'Recorded', + response: { + body: 'response body', + statusCode: '200', + reasonPhrase: 'response reasonPhrase', + headers: [ + { name: 'response headers name - 1', value: 'response headers value - 1' }, + { name: 'response headers name - 2', value: 'response headers value - 2' }, + ], + }, + }, + ], source: { name: 'Status Code', }, diff --git a/ee/spec/frontend/security_dashboard/components/shared/vulnerability_details_graphql/index_spec.js b/ee/spec/frontend/security_dashboard/components/shared/vulnerability_details_graphql/index_spec.js index a764ac4afcd19fa59033b9559a169e740d5f4931..c45ce918730b6bd5a0651f8b477c34123943c59f 100644 --- a/ee/spec/frontend/security_dashboard/components/shared/vulnerability_details_graphql/index_spec.js +++ b/ee/spec/frontend/security_dashboard/components/shared/vulnerability_details_graphql/index_spec.js @@ -210,6 +210,7 @@ describe('ee/security_dashboard/components/shared/vulnerability_details_graphql/ const findRequestResponseSection = () => wrapper.findByTestId('request-response-section'); const findRequestItem = () => wrapper.findByTestId('request-item'); const findResponseItem = () => wrapper.findByTestId('response-item'); + const findRecordedResponseItem = () => wrapper.findByTestId('recorded-response-item'); const request = { url: 'http://example.com/requestUrl', body: 'request body', @@ -230,17 +231,25 @@ describe('ee/security_dashboard/components/shared/vulnerability_details_graphql/ ], }; + const supportingMessages = [ + { + name: 'Recorded', + response, + }, + ]; + describe.each` - type | data | component - ${'request'} | ${request} | ${findRequestItem} - ${'response'} | ${response} | ${findResponseItem} - `('with $type information', ({ type, data, component }) => { + type | evidence | data | component + ${'request'} | ${request} | ${request} | ${findRequestItem} + ${'response'} | ${response} | ${response} | ${findResponseItem} + ${'supportingMessages'} | ${supportingMessages} | ${supportingMessages[0].response} | ${findRecordedResponseItem} + `('with $type information', ({ type, evidence, data, component }) => { beforeEach(() => { createComponent({ propsData: { ...TEST_VULNERABILITY, evidence: { - [type]: data, + [type]: evidence, }, }, }); @@ -262,6 +271,7 @@ describe('ee/security_dashboard/components/shared/vulnerability_details_graphql/ expect(findRequestItem().exists()).toBe(false); expect(findResponseItem().exists()).toBe(false); + expect(findRecordedResponseItem().exists()).toBe(false); }); }); }); diff --git a/locale/gitlab.pot b/locale/gitlab.pot index d0c4d7f101a25bede43ba59f9fd97bfdadf3b16a..8f198fa7914abe306be47fedb49b4285e3e4fa40 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -48913,6 +48913,9 @@ msgstr "" msgid "Vulnerability|Unmodified Response" msgstr "" +msgid "Vulnerability|Unmodified response:" +msgstr "" + msgid "Vulnerability|View training" msgstr ""