Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8911c985
Commit
8911c985
authored
Jan 28, 2021
by
Fernando Arias
Committed by
Brandon Labuschagne
Jan 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show request/reply empty body
* Update unit tests
parent
578ab1bb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
7 deletions
+55
-7
ee/app/assets/javascripts/vue_shared/security_reports/components/helpers.js
...scripts/vue_shared/security_reports/components/helpers.js
+14
-1
ee/changelogs/unreleased/284677-api-fuzzing-empty-body-bug-fix.yml
...logs/unreleased/284677-api-fuzzing-empty-body-bug-fix.yml
+5
-0
ee/spec/frontend/vue_shared/security_reports/components/vulnerability_details_spec.js
...security_reports/components/vulnerability_details_spec.js
+9
-3
ee/spec/frontend/vulnerabilities/details_spec.js
ee/spec/frontend/vulnerabilities/details_spec.js
+27
-3
No files found.
ee/app/assets/javascripts/vue_shared/security_reports/components/helpers.js
View file @
8911c985
import
{
EMPTY_BODY_MESSAGE
}
from
'
./constants
'
;
import
{
EMPTY_BODY_MESSAGE
}
from
'
./constants
'
;
export
const
bodyWithFallBack
=
(
body
)
=>
body
||
EMPTY_BODY_MESSAGE
;
/**
* A helper function which validates the passed
* in body string.
*
* It returns an empty string if the body has explicitly
* been passed in as an empty string, a fallback
* message if the body is null / undefined, else
* it will return the original body string.
*
* @param {String} body the body message
*
* @return {String} the validated body message
*/
export
const
bodyWithFallBack
=
(
body
)
=>
(
body
===
''
?
''
:
body
||
EMPTY_BODY_MESSAGE
);
ee/changelogs/unreleased/284677-api-fuzzing-empty-body-bug-fix.yml
0 → 100644
View file @
8911c985
---
title
:
Show Response fields for vulnerabilties sourced from DAST
merge_request
:
51948
author
:
type
:
fixed
ee/spec/frontend/vue_shared/security_reports/components/vulnerability_details_spec.js
View file @
8911c985
...
@@ -174,7 +174,9 @@ describe('VulnerabilityDetails component', () => {
...
@@ -174,7 +174,9 @@ describe('VulnerabilityDetails component', () => {
});
});
describe
.
each
([
describe
.
each
([
[
''
,
EMPTY_BODY_MESSAGE
],
[
''
,
''
],
[
undefined
,
EMPTY_BODY_MESSAGE
],
[
null
,
EMPTY_BODY_MESSAGE
],
[
USER_NOT_FOUND_MESSAGE
,
USER_NOT_FOUND_MESSAGE
],
[
USER_NOT_FOUND_MESSAGE
,
USER_NOT_FOUND_MESSAGE
],
])(
'
with request information and body set to: %s
'
,
(
body
,
renderedBody
)
=>
{
])(
'
with request information and body set to: %s
'
,
(
body
,
renderedBody
)
=>
{
let
vulnerability
;
let
vulnerability
;
...
@@ -234,7 +236,9 @@ describe('VulnerabilityDetails component', () => {
...
@@ -234,7 +236,9 @@ describe('VulnerabilityDetails component', () => {
});
});
describe
.
each
([
describe
.
each
([
[
''
,
EMPTY_BODY_MESSAGE
],
[
''
,
''
],
[
undefined
,
EMPTY_BODY_MESSAGE
],
[
null
,
EMPTY_BODY_MESSAGE
],
[
USER_NOT_FOUND_MESSAGE
,
USER_NOT_FOUND_MESSAGE
],
[
USER_NOT_FOUND_MESSAGE
,
USER_NOT_FOUND_MESSAGE
],
])(
'
with response information and body set to: %s
'
,
(
body
,
renderedBody
)
=>
{
])(
'
with response information and body set to: %s
'
,
(
body
,
renderedBody
)
=>
{
let
vulnerability
;
let
vulnerability
;
...
@@ -281,7 +285,9 @@ describe('VulnerabilityDetails component', () => {
...
@@ -281,7 +285,9 @@ describe('VulnerabilityDetails component', () => {
});
});
describe
.
each
([
describe
.
each
([
[
''
,
EMPTY_BODY_MESSAGE
],
[
''
,
''
],
[
undefined
,
EMPTY_BODY_MESSAGE
],
[
null
,
EMPTY_BODY_MESSAGE
],
[
USER_NOT_FOUND_MESSAGE
,
USER_NOT_FOUND_MESSAGE
],
[
USER_NOT_FOUND_MESSAGE
,
USER_NOT_FOUND_MESSAGE
],
])(
'
with recorded response information and body set to: %s
'
,
(
body
,
renderedBody
)
=>
{
])(
'
with recorded response information and body set to: %s
'
,
(
body
,
renderedBody
)
=>
{
let
vulnerability
;
let
vulnerability
;
...
...
ee/spec/frontend/vulnerabilities/details_spec.js
View file @
8911c985
...
@@ -242,6 +242,12 @@ describe('Vulnerability Details', () => {
...
@@ -242,6 +242,12 @@ describe('Vulnerability Details', () => {
isCode
:
true
,
isCode
:
true
,
};
};
const
EXPECT_REQUEST_WITH_EMPTY_STRING
=
{
label
:
'
Sent request:
'
,
content
:
'
GET http://www.gitlab.com
\n
Name1: Value1
\n
Name2: Value2
'
,
isCode
:
true
,
};
const
EXPECT_RESPONSE
=
{
const
EXPECT_RESPONSE
=
{
label
:
'
Actual response:
'
,
label
:
'
Actual response:
'
,
content
:
'
500 INTERNAL SERVER ERROR
\n
Name1: Value1
\n
Name2: Value2
\n\n
[{"user_id":1,}]
'
,
content
:
'
500 INTERNAL SERVER ERROR
\n
Name1: Value1
\n
Name2: Value2
\n\n
[{"user_id":1,}]
'
,
...
@@ -255,6 +261,12 @@ describe('Vulnerability Details', () => {
...
@@ -255,6 +261,12 @@ describe('Vulnerability Details', () => {
isCode
:
true
,
isCode
:
true
,
};
};
const
EXPECT_RESPONSE_WITH_EMPTY_STRING
=
{
label
:
'
Actual response:
'
,
content
:
'
500 INTERNAL SERVER ERROR
\n
Name1: Value1
\n
Name2: Value2
'
,
isCode
:
true
,
};
const
EXPECT_RECORDED_RESPONSE
=
{
const
EXPECT_RECORDED_RESPONSE
=
{
label
:
'
Unmodified response:
'
,
label
:
'
Unmodified response:
'
,
content
:
'
200 OK
\n
Name1: Value1
\n
Name2: Value2
\n\n
[{"user_id":1,}]
'
,
content
:
'
200 OK
\n
Name1: Value1
\n
Name2: Value2
\n\n
[{"user_id":1,}]
'
,
...
@@ -267,6 +279,12 @@ describe('Vulnerability Details', () => {
...
@@ -267,6 +279,12 @@ describe('Vulnerability Details', () => {
isCode
:
true
,
isCode
:
true
,
};
};
const
EXPECT_RECORDED_RESPONSE_WITH_EMPTY_STRING
=
{
label
:
'
Unmodified response:
'
,
content
:
'
200 OK
\n
Name1: Value1
\n
Name2: Value2
'
,
isCode
:
true
,
};
const
getTextContent
=
(
el
)
=>
el
.
textContent
.
trim
();
const
getTextContent
=
(
el
)
=>
el
.
textContent
.
trim
();
const
getLabel
=
(
el
)
=>
getTextContent
(
getByTestId
(
el
,
'
label
'
));
const
getLabel
=
(
el
)
=>
getTextContent
(
getByTestId
(
el
,
'
label
'
));
const
getContent
=
(
el
)
=>
getTextContent
(
getByTestId
(
el
,
'
value
'
));
const
getContent
=
(
el
)
=>
getTextContent
(
getByTestId
(
el
,
'
value
'
));
...
@@ -293,7 +311,9 @@ describe('Vulnerability Details', () => {
...
@@ -293,7 +311,9 @@ describe('Vulnerability Details', () => {
${{
method
:
'
GET
'
,
url
:
'
http://www.gitlab.com
'
}
} |
${
null
}
${{
method
:
'
GET
'
,
url
:
'
http://www.gitlab.com
'
}
} |
${
null
}
${{
method
:
'
GET
'
,
url
:
'
http://www.gitlab.com
'
,
body
:
'
[{"user_id":1,}]
'
}
} |
${
null
}
${{
method
:
'
GET
'
,
url
:
'
http://www.gitlab.com
'
,
body
:
'
[{"user_id":1,}]
'
}
} |
${
null
}
${{
headers
:
TEST_HEADERS
,
method
:
'
GET
'
,
url
:
'
http://www.gitlab.com
'
,
body
:
'
[{"user_id":1,}]
'
}
} |
${[
EXPECT_REQUEST
]}
${{
headers
:
TEST_HEADERS
,
method
:
'
GET
'
,
url
:
'
http://www.gitlab.com
'
,
body
:
'
[{"user_id":1,}]
'
}
} |
${[
EXPECT_REQUEST
]}
${{
headers
:
TEST_HEADERS
,
method
:
'
GET
'
,
url
:
'
http://www.gitlab.com
'
,
body
:
''
}
} |
${[
EXPECT_REQUEST_WITHOUT_BODY
]}
${{
headers
:
TEST_HEADERS
,
method
:
'
GET
'
,
url
:
'
http://www.gitlab.com
'
,
body
:
null
}
} |
${[
EXPECT_REQUEST_WITHOUT_BODY
]}
${{
headers
:
TEST_HEADERS
,
method
:
'
GET
'
,
url
:
'
http://www.gitlab.com
'
,
body
:
undefined
}
} |
${[
EXPECT_REQUEST_WITHOUT_BODY
]}
${{
headers
:
TEST_HEADERS
,
method
:
'
GET
'
,
url
:
'
http://www.gitlab.com
'
,
body
:
''
}
} |
${[
EXPECT_REQUEST_WITH_EMPTY_STRING
]}
`
(
'
shows request data for $request
'
,
({
request
,
expectedData
})
=>
{
`
(
'
shows request data for $request
'
,
({
request
,
expectedData
})
=>
{
createWrapper
({
request
});
createWrapper
({
request
});
expect
(
getSectionData
(
'
request
'
)).
toEqual
(
expectedData
);
expect
(
getSectionData
(
'
request
'
)).
toEqual
(
expectedData
);
...
@@ -307,7 +327,9 @@ describe('Vulnerability Details', () => {
...
@@ -307,7 +327,9 @@ describe('Vulnerability Details', () => {
${{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
}
} |
${
null
}
${{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
}
} |
${
null
}
${{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
,
statusCode
:
'
500
'
}
} |
${
null
}
${{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
,
statusCode
:
'
500
'
}
} |
${
null
}
${{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
,
statusCode
:
'
500
'
,
reasonPhrase
:
'
INTERNAL SERVER ERROR
'
}
} |
${[
EXPECT_RESPONSE
]}
${{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
,
statusCode
:
'
500
'
,
reasonPhrase
:
'
INTERNAL SERVER ERROR
'
}
} |
${[
EXPECT_RESPONSE
]}
${{
headers
:
TEST_HEADERS
,
body
:
''
,
statusCode
:
'
500
'
,
reasonPhrase
:
'
INTERNAL SERVER ERROR
'
}
} |
${[
EXPECT_RESPONSE_WITHOUT_BODY
]}
${{
headers
:
TEST_HEADERS
,
body
:
null
,
statusCode
:
'
500
'
,
reasonPhrase
:
'
INTERNAL SERVER ERROR
'
}
} |
${[
EXPECT_RESPONSE_WITHOUT_BODY
]}
${{
headers
:
TEST_HEADERS
,
body
:
undefined
,
statusCode
:
'
500
'
,
reasonPhrase
:
'
INTERNAL SERVER ERROR
'
}
} |
${[
EXPECT_RESPONSE_WITHOUT_BODY
]}
${{
headers
:
TEST_HEADERS
,
body
:
''
,
statusCode
:
'
500
'
,
reasonPhrase
:
'
INTERNAL SERVER ERROR
'
}
} |
${[
EXPECT_RESPONSE_WITH_EMPTY_STRING
]}
`
(
'
shows response data for $response
'
,
({
response
,
expectedData
})
=>
{
`
(
'
shows response data for $response
'
,
({
response
,
expectedData
})
=>
{
createWrapper
({
response
});
createWrapper
({
response
});
expect
(
getSectionData
(
'
response
'
)).
toEqual
(
expectedData
);
expect
(
getSectionData
(
'
response
'
)).
toEqual
(
expectedData
);
...
@@ -324,7 +346,9 @@ describe('Vulnerability Details', () => {
...
@@ -324,7 +346,9 @@ describe('Vulnerability Details', () => {
${[{},
{
response
:
{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
,
status_code
:
'
200
'
}
}]}
|
$
{
null
}
${[{},
{
response
:
{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
,
status_code
:
'
200
'
}
}]}
|
$
{
null
}
${[{},
{
response
:
{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
,
status_code
:
'
200
'
,
reason_phrase
:
'
OK
'
}
}]}
|
$
{
null
}
${[{},
{
response
:
{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
,
status_code
:
'
200
'
,
reason_phrase
:
'
OK
'
}
}]}
|
$
{
null
}
${[{},
{
name
:
SUPPORTING_MESSAGE_TYPES
.
RECORDED
,
response
:
{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
,
statusCode
:
'
200
'
,
reasonPhrase
:
'
OK
'
}
}]}
|
$
{[
EXPECT_RECORDED_RESPONSE
]}
${[{},
{
name
:
SUPPORTING_MESSAGE_TYPES
.
RECORDED
,
response
:
{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
,
statusCode
:
'
200
'
,
reasonPhrase
:
'
OK
'
}
}]}
|
$
{[
EXPECT_RECORDED_RESPONSE
]}
${[{},
{
name
:
SUPPORTING_MESSAGE_TYPES
.
RECORDED
,
response
:
{
headers
:
TEST_HEADERS
,
body
:
''
,
statusCode
:
'
200
'
,
reasonPhrase
:
'
OK
'
}
}]}
|
$
{[
EXPECT_RECORDED_RESPONSE_WITHOUT_BODY
]}
${[{},
{
name
:
SUPPORTING_MESSAGE_TYPES
.
RECORDED
,
response
:
{
headers
:
TEST_HEADERS
,
body
:
null
,
statusCode
:
'
200
'
,
reasonPhrase
:
'
OK
'
}
}]}
|
$
{[
EXPECT_RECORDED_RESPONSE_WITHOUT_BODY
]}
${[{},
{
name
:
SUPPORTING_MESSAGE_TYPES
.
RECORDED
,
response
:
{
headers
:
TEST_HEADERS
,
body
:
undefined
,
statusCode
:
'
200
'
,
reasonPhrase
:
'
OK
'
}
}]}
|
$
{[
EXPECT_RECORDED_RESPONSE_WITHOUT_BODY
]}
${[{},
{
name
:
SUPPORTING_MESSAGE_TYPES
.
RECORDED
,
response
:
{
headers
:
TEST_HEADERS
,
body
:
''
,
statusCode
:
'
200
'
,
reasonPhrase
:
'
OK
'
}
}]}
|
$
{[
EXPECT_RECORDED_RESPONSE_WITH_EMPTY_STRING
]}
`
(
'
shows response data for $supporting_messages
'
,
({
supportingMessages
,
expectedData
})
=>
{
`
(
'
shows response data for $supporting_messages
'
,
({
supportingMessages
,
expectedData
})
=>
{
createWrapper
({
supportingMessages
});
createWrapper
({
supportingMessages
});
expect
(
getSectionData
(
'
recorded-response
'
)).
toEqual
(
expectedData
);
expect
(
getSectionData
(
'
recorded-response
'
)).
toEqual
(
expectedData
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment