Commit 712e3a8e authored by Fernando's avatar Fernando

Add API Fuzzing responses

* Add sent and response fields
parent 153a0527
...@@ -53,25 +53,43 @@ export default { ...@@ -53,25 +53,43 @@ export default {
properties: {}, properties: {},
}; };
}, },
getConstructedRequest() {
const { body, method, url, headers = [] } = this.vulnerability.request;
const headerLines = this.getHeadersAsCodeBlockLines(headers);
return [`${method} ${url}\n`, headerLines, '\n\n', body].join('');
},
getConstructedResponse() {
const {
body,
status_code: statusCode,
reason_phrase: reasonPhrase,
headers = [],
} = this.vulnerability.response;
const headerLines = this.getHeadersAsCodeBlockLines(headers);
return [`${reasonPhrase} ${statusCode}\n`, headerLines, '\n\n', body].join('');
},
getConstructedRecordedResponse() {
const {
body,
status_code: statusCode,
reason_phrase: reasonPhrase,
headers = [],
} = this.vulnerability.supporting_messages[1].response;
const headerLines = this.getHeadersAsCodeBlockLines(headers);
return [`${reasonPhrase} ${statusCode}\n`, headerLines, '\n\n', body].join('');
},
requestData() { requestData() {
if (!this.vulnerability.request) { if (!this.vulnerability.request) {
return []; return [];
} }
const { method, url, headers = [] } = this.vulnerability.request;
return [ return [
{ {
label: __('%{labelStart}Method:%{labelEnd} %{method}'), label: __('%{labelStart}Sent request:%{labelEnd} %{headers}'),
content: method, content: this.getConstructedRequest,
},
{
label: __('%{labelStart}URL:%{labelEnd} %{url}'),
content: url,
},
{
label: __('%{labelStart}Headers:%{labelEnd} %{headers}'),
content: this.getHeadersAsCodeBlockLines(headers),
isCode: true, isCode: true,
}, },
].filter(x => x.content); ].filter(x => x.content);
...@@ -81,20 +99,23 @@ export default { ...@@ -81,20 +99,23 @@ export default {
return []; return [];
} }
const {
status_code: statusCode,
reason_phrase: reasonPhrase,
headers = [],
} = this.vulnerability.response;
return [ return [
{ {
label: __('%{labelStart}Status:%{labelEnd} %{status}'), label: __('%{labelStart}Actual response:%{labelEnd} %{headers}'),
content: statusCode && reasonPhrase ? `${statusCode} ${reasonPhrase}` : '', content: this.getConstructedResponse,
isCode: true,
}, },
].filter(x => x.content);
},
recordedResponseData() {
if (!this.vulnerability.supporting_messages[1].response) {
return [];
}
return [
{ {
label: __('%{labelStart}Headers:%{labelEnd} %{headers}'), label: __('%{labelStart}Unmodified Response%{labelEnd} %{headers}'),
content: this.getHeadersAsCodeBlockLines(headers), content: this.getConstructedRecordedResponse,
isCode: true, isCode: true,
}, },
].filter(x => x.content); ].filter(x => x.content);
...@@ -248,7 +269,7 @@ export default { ...@@ -248,7 +269,7 @@ export default {
</template> </template>
<section v-if="requestData.length" data-testid="request"> <section v-if="requestData.length" data-testid="request">
<h3>{{ s__('Vulnerability|Request') }}</h3> <h3>{{ s__('Vulnerability|Request/Response') }}</h3>
<ul> <ul>
<detail-item <detail-item
v-for="({ label, isCode, content }, index) in requestData" v-for="({ label, isCode, content }, index) in requestData"
...@@ -263,20 +284,44 @@ export default { ...@@ -263,20 +284,44 @@ export default {
</ul> </ul>
</section> </section>
<section v-if="responseData.length" data-testid="response"> <div v-if="responseData.length || recordedResponseData.length" class="row">
<h3>{{ s__('Vulnerability|Response') }}</h3> <section
<ul> v-if="responseData.length"
<detail-item :class="recordedResponseData.length ? 'col-6' : 'col'"
v-for="({ label, isCode, content }, index) in responseData" data-testid="response"
:key="`${index}:${label}`" >
:sprintf-message="label" <ul>
> <detail-item
<code-block v-if="isCode" class="mt-1" :code="content" max-height="225px" /> v-for="({ label, isCode, content }, index) in responseData"
<template v-else> :key="`${index}:${label}`"
{{ content }} :sprintf-message="label"
</template> >
</detail-item> <code-block v-if="isCode" class="mt-1" :code="content" max-height="225px" />
</ul> <template v-else>
</section> {{ content }}
</template>
</detail-item>
</ul>
</section>
<section
v-if="recordedResponseData.length"
:class="responseData.length ? 'col-6' : 'col'"
data-testid="response"
>
<ul>
<detail-item
v-for="({ label, isCode, content }, index) in recordedResponseData"
:key="`${index}:${label}`"
:sprintf-message="label"
>
<code-block v-if="isCode" class="mt-1" :code="content" max-height="225px" />
<template v-else>
{{ content }}
</template>
</detail-item>
</ul>
</section>
</div>
</div> </div>
</template> </template>
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