Commit 973fac66 authored by Fernando's avatar Fernando

Refactor HTTP Request/Response into methods

* Refactor common computed prop logic into methods
parent 94b08103
...@@ -66,38 +66,13 @@ export default { ...@@ -66,38 +66,13 @@ export default {
)?.response; )?.response;
}, },
getConstructedRequest() { getConstructedRequest() {
const { body, method, url, headers = [] } = this.vulnerability.request; return this.constructRequest(this.vulnerability.request);
const headerLines = this.getHeadersAsCodeBlockLines(headers);
return method && url && headerLines
? [`${method} ${url}\n`, headerLines, '\n\n', body].join('')
: '';
}, },
getConstructedResponse() { getConstructedResponse() {
const { return this.constructResponse(this.vulnerability.response);
body,
status_code: statusCode,
reason_phrase: reasonPhrase,
headers = [],
} = this.vulnerability.response;
const headerLines = this.getHeadersAsCodeBlockLines(headers);
return statusCode && reasonPhrase && headerLines
? [`${statusCode} ${reasonPhrase}\n`, headerLines, '\n\n', body].join('')
: '';
}, },
getConstructedRecordedResponse() { getConstructedRecordedResponse() {
const { return this.constructResponse(this.recordedMessage);
body,
status_code: statusCode,
reason_phrase: reasonPhrase,
headers = [],
} = this.recordedMessage;
const headerLines = this.getHeadersAsCodeBlockLines(headers);
return statusCode && reasonPhrase && headerLines
? [`${statusCode} ${reasonPhrase}\n`, headerLines, '\n\n', body].join('')
: '';
}, },
requestData() { requestData() {
if (!this.vulnerability.request) { if (!this.vulnerability.request) {
...@@ -167,6 +142,22 @@ export default { ...@@ -167,6 +142,22 @@ export default {
? headers.map(({ name, value }) => `${name}: ${value}`).join('\n') ? headers.map(({ name, value }) => `${name}: ${value}`).join('\n')
: ''; : '';
}, },
constructResponse(response) {
const { body, status_code: statusCode, reason_phrase: reasonPhrase, headers = [] } = response;
const headerLines = this.getHeadersAsCodeBlockLines(headers);
return statusCode && reasonPhrase && headerLines
? [`${statusCode} ${reasonPhrase}\n`, headerLines, '\n\n', body].join('')
: '';
},
constructRequest(request) {
const { body, method, url, headers = [] } = request;
const headerLines = this.getHeadersAsCodeBlockLines(headers);
return method && url && headerLines
? [`${method} ${url}\n`, headerLines, '\n\n', body].join('')
: '';
},
}, },
}; };
</script> </script>
......
import { s__, __ } from '~/locale'; import { s__ } from '~/locale';
export const VULNERABILITY_STATE_OBJECTS = { export const VULNERABILITY_STATE_OBJECTS = {
detected: { detected: {
...@@ -67,5 +67,5 @@ export const REGEXES = { ...@@ -67,5 +67,5 @@ export const REGEXES = {
}; };
export const SUPPORTING_MESSAGE_TYPES = { export const SUPPORTING_MESSAGE_TYPES = {
RECORDED: __('Recorded'), RECORDED: s__('VulnerabilityManagement|Recorded'),
}; };
...@@ -21945,9 +21945,6 @@ msgstr "" ...@@ -21945,9 +21945,6 @@ msgstr ""
msgid "Reconfigure" msgid "Reconfigure"
msgstr "" msgstr ""
msgid "Recorded"
msgstr ""
msgid "Recover hidden stage" msgid "Recover hidden stage"
msgstr "" msgstr ""
...@@ -29649,6 +29646,9 @@ msgstr "" ...@@ -29649,6 +29646,9 @@ msgstr ""
msgid "VulnerabilityManagement|Needs triage" msgid "VulnerabilityManagement|Needs triage"
msgstr "" msgstr ""
msgid "VulnerabilityManagement|Recorded"
msgstr ""
msgid "VulnerabilityManagement|Something went wrong while trying to delete the comment. Please try again later." msgid "VulnerabilityManagement|Something went wrong while trying to delete the comment. Please try again later."
msgstr "" msgstr ""
......
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