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
1e5704bf
Commit
1e5704bf
authored
Nov 09, 2020
by
Fernando
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests
* Update existing tests and add new ones
parent
8e76c5c8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
37 deletions
+93
-37
ee/app/assets/javascripts/vulnerabilities/components/details.vue
...assets/javascripts/vulnerabilities/components/details.vue
+19
-7
ee/app/assets/javascripts/vulnerabilities/constants.js
ee/app/assets/javascripts/vulnerabilities/constants.js
+5
-1
ee/spec/frontend/vulnerabilities/details_spec.js
ee/spec/frontend/vulnerabilities/details_spec.js
+47
-19
locale/gitlab.pot
locale/gitlab.pot
+22
-10
No files found.
ee/app/assets/javascripts/vulnerabilities/components/details.vue
View file @
1e5704bf
<
script
>
import
{
GlLink
,
GlSprintf
,
GlTooltipDirective
,
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
SUPPORTING_MESSAGE_TYPES
}
from
'
ee/vulnerabilities/constants
'
;
import
SeverityBadge
from
'
ee/vue_shared/security_reports/components/severity_badge.vue
'
;
import
CodeBlock
from
'
~/vue_shared/components/code_block.vue
'
;
import
{
__
}
from
'
~/locale
'
;
...
...
@@ -63,7 +64,9 @@ export default {
const
{
body
,
method
,
url
,
headers
=
[]
}
=
this
.
vulnerability
.
request
;
const
headerLines
=
this
.
getHeadersAsCodeBlockLines
(
headers
);
return
[
`
${
method
}
${
url
}
\n`
,
headerLines
,
'
\n\n
'
,
body
].
join
(
''
);
return
method
&&
url
&&
headerLines
?
[
`
${
method
}
${
url
}
\n`
,
headerLines
,
'
\n\n
'
,
body
].
join
(
''
)
:
''
;
},
getConstructedResponse
()
{
const
{
...
...
@@ -74,7 +77,9 @@ export default {
}
=
this
.
vulnerability
.
response
;
const
headerLines
=
this
.
getHeadersAsCodeBlockLines
(
headers
);
return
[
`
${
reasonPhrase
}
${
statusCode
}
\n`
,
headerLines
,
'
\n\n
'
,
body
].
join
(
''
);
return
statusCode
&&
reasonPhrase
&&
headerLines
?
[
`
${
reasonPhrase
}
${
statusCode
}
\n`
,
headerLines
,
'
\n\n
'
,
body
].
join
(
''
)
:
''
;
},
getConstructedRecordedResponse
()
{
const
{
...
...
@@ -82,10 +87,12 @@ export default {
status_code
:
statusCode
,
reason_phrase
:
reasonPhrase
,
headers
=
[],
}
=
this
.
vulnerability
.
supporting_messages
[
1
].
response
;
}
=
this
.
vulnerability
?
.
supporting_messages
[
1
].
response
;
const
headerLines
=
this
.
getHeadersAsCodeBlockLines
(
headers
);
return
[
`
${
reasonPhrase
}
${
statusCode
}
\n`
,
headerLines
,
'
\n\n
'
,
body
].
join
(
''
);
return
statusCode
&&
reasonPhrase
&&
headerLines
?
[
`
${
reasonPhrase
}
${
statusCode
}
\n`
,
headerLines
,
'
\n\n
'
,
body
].
join
(
''
)
:
''
;
},
requestData
()
{
if
(
!
this
.
vulnerability
.
request
)
{
...
...
@@ -114,13 +121,18 @@ export default {
].
filter
(
x
=>
x
.
content
);
},
recordedResponseData
()
{
if
(
!
this
.
vulnerability
.
supporting_messages
[
1
].
response
)
{
if
(
!
(
this
.
vulnerability
?.
supporting_messages
&&
this
.
vulnerability
.
supporting_messages
[
1
]?.
name
===
SUPPORTING_MESSAGE_TYPES
.
RECORDED
)
)
{
return
[];
}
return
[
{
label
:
__
(
'
%{labelStart}Unmodified
Response
%{labelEnd} %{headers}
'
),
label
:
__
(
'
%{labelStart}Unmodified
response:
%{labelEnd} %{headers}
'
),
content
:
this
.
getConstructedRecordedResponse
,
isCode
:
true
,
},
...
...
@@ -294,7 +306,7 @@ export default {
<section
v-if=
"recordedResponseData.length"
:class=
"responseData.length ? 'col-6' : 'col'"
data-testid=
"response"
data-testid=
"re
corded-re
sponse"
>
<ul>
<detail-item
...
...
ee/app/assets/javascripts/vulnerabilities/constants.js
View file @
1e5704bf
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
,
__
}
from
'
~/locale
'
;
export
const
VULNERABILITY_STATE_OBJECTS
=
{
detected
:
{
...
...
@@ -65,3 +65,7 @@ export const REGEXES = {
ISSUE_FORMAT
:
/^#
?(\d
+
)
$/
,
// Matches '123' and '#123'.
LINK_FORMAT
:
/
\/(
.+
\/
.+
)\/
-
\/
issues
\/(\d
+
)
/
,
// Matches '/username/project/-/issues/123'.
};
export
const
SUPPORTING_MESSAGE_TYPES
=
{
RECORDED
:
__
(
'
Recorded
'
),
};
ee/spec/frontend/vulnerabilities/details_spec.js
View file @
1e5704bf
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
getAllByRole
,
getByTestId
}
from
'
@testing-library/dom
'
;
import
{
GlLink
}
from
'
@gitlab/ui
'
;
import
{
SUPPORTING_MESSAGE_TYPES
}
from
'
ee/vulnerabilities/constants
'
;
import
SeverityBadge
from
'
ee/vue_shared/security_reports/components/severity_badge.vue
'
;
import
VulnerabilityDetails
from
'
ee/vulnerabilities/components/details.vue
'
;
...
...
@@ -173,10 +174,21 @@ describe('Vulnerability Details', () => {
describe
(
'
http data
'
,
()
=>
{
const
TEST_HEADERS
=
[{
name
:
'
Name1
'
,
value
:
'
Value1
'
},
{
name
:
'
Name2
'
,
value
:
'
Value2
'
}];
const
TEST_URL
=
'
http://foo.bar/test
'
;
const
EXPECT_HEADERS
=
{
label
:
'
Headers:
'
,
content
:
'
Name1: Value1
\n
Name2: Value2
'
,
const
EXPECT_REQUEST
=
{
label
:
'
Sent request:
'
,
content
:
'
GET http://www.gitlab.com
\n
Name1: Value1
\n
Name2: Value2
\n\n
[{"user_id":1,}]
'
,
isCode
:
true
,
};
const
EXPECT_RESPONSE
=
{
label
:
'
Actual response:
'
,
content
:
'
INTERNAL SERVER ERROR 500
\n
Name1: Value1
\n
Name2: Value2
\n\n
[{"user_id":1,}]
'
,
isCode
:
true
,
};
const
EXPECT_RECORDED_RESPONSE
=
{
label
:
'
Unmodified response:
'
,
content
:
'
OK 200
\n
Name1: Value1
\n
Name2: Value2
\n\n
[{"user_id":1,}]
'
,
isCode
:
true
,
};
...
...
@@ -201,11 +213,11 @@ describe('Vulnerability Details', () => {
request | expectedData
${
null
}
|
${
null
}
${{}}
|
$
{
null
}
${{
headers
:
TEST_HEADERS
}
}
|
${[
EXPECT_HEADERS
]
}
${{
headers
:
TEST_HEADERS
,
method
:
'
GET
'
}
} |
${[{
label
:
'
Method:
'
,
content
:
'
GET
'
},
EXPECT_HEADERS
]
}
${{
headers
:
TEST_HEADERS
,
method
:
'
GET
'
,
url
:
TEST_URL
}
} |
${[{
label
:
'
Method:
'
,
content
:
'
GET
'
},
{
label
:
'
URL:
'
,
content
:
TEST_URL
},
EXPECT_HEADERS
]
}
${{
url
:
TEST_URL
}
} |
${[{
label
:
'
URL:
'
,
content
:
TEST_URL
}]
}
${{
method
:
'
GET
'
}
} |
${[{
label
:
'
Method:
'
,
content
:
'
GET
'
}
]}
${{
headers
:
TEST_HEADERS
}
}
|
${
null
}
${{
method
:
'
GET
'
}
} |
${
null
}
${{
method
:
'
GET
'
,
url
:
'
http://www.gitlab.com
'
}
} |
${
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
]}
`
(
'
shows request data for $request
'
,
({
request
,
expectedData
})
=>
{
createWrapper
({
request
});
expect
(
getSectionData
(
'
request
'
)).
toEqual
(
expectedData
);
...
...
@@ -215,13 +227,29 @@ describe('Vulnerability Details', () => {
response | expectedData
${
null
}
|
${
null
}
${{}}
|
$
{
null
}
${{
headers
:
TEST_HEADERS
}
}
|
${[
EXPECT_HEADERS
]
}
${{
headers
:
TEST_HEADERS
,
status_code
:
200
}
} |
${[
EXPECT_HEADERS
]
}
${{
headers
:
TEST_HEADERS
,
status_code
:
200
,
reason_phrase
:
'
OK
'
}
} |
${[{
label
:
'
Status:
'
,
content
:
'
200 OK
'
},
EXPECT_HEADERS
]
}
${{
status_code
:
400
,
reason_phrase
:
'
Something bad
'
}
} |
${[{
label
:
'
Status:
'
,
content
:
'
400 Something bad
'
}
]}
${{
headers
:
TEST_HEADERS
}
}
|
${
null
}
${{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
}
} |
${
null
}
${{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
,
status_code
:
'
500
'
}
} |
${
null
}
${{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
,
status_code
:
'
500
'
,
reason_phrase
:
'
INTERNAL SERVER ERROR
'
}
} |
${[
EXPECT_RESPONSE
]}
`
(
'
shows response data for $response
'
,
({
response
,
expectedData
})
=>
{
createWrapper
({
response
});
expect
(
getSectionData
(
'
response
'
)).
toEqual
(
expectedData
);
});
it
.
each
`
supporting_messages | expectedData
${
null
}
|
${
null
}
${[]}
|
${
null
}
${[{}]}
|
${
null
}
${[{},
{
response
:
{}
}]}
|
$
{
null
}
${[{},
{
response
:
{
headers
:
TEST_HEADERS
}
}]}
|
$
{
null
}
${[{},
{
response
:
{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
}
}]}
|
$
{
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
}
${[{},
{
name
:
SUPPORTING_MESSAGE_TYPES
.
RECORDED
,
response
:
{
headers
:
TEST_HEADERS
,
body
:
'
[{"user_id":1,}]
'
,
status_code
:
'
200
'
,
reason_phrase
:
'
OK
'
}
}]}
|
$
{[
EXPECT_RECORDED_RESPONSE
]}
`
(
'
shows response data for $supporting_messages
'
,
({
supporting_messages
,
expectedData
})
=>
{
createWrapper
({
supporting_messages
});
expect
(
getSectionData
(
'
recorded-response
'
)).
toEqual
(
expectedData
);
});
});
});
locale/gitlab.pot
View file @
1e5704bf
...
...
@@ -532,6 +532,12 @@ msgstr ""
msgid "%{issuesSize} with a limit of %{maxIssueCount}"
msgstr ""
msgid "%{labelStart}Actual response:%{labelEnd} %{headers}"
msgstr ""
msgid "%{labelStart}Assert:%{labelEnd} %{assert}"
msgstr ""
msgid "%{labelStart}Class:%{labelEnd} %{class}"
msgstr ""
...
...
@@ -547,9 +553,6 @@ msgstr ""
msgid "%{labelStart}File:%{labelEnd} %{file}"
msgstr ""
msgid "%{labelStart}Headers:%{labelEnd} %{headers}"
msgstr ""
msgid "%{labelStart}Image:%{labelEnd} %{image}"
msgstr ""
...
...
@@ -565,13 +568,13 @@ msgstr ""
msgid "%{labelStart}Scanner:%{labelEnd} %{scanner}"
msgstr ""
msgid "%{labelStart}Se
verity:%{labelEnd} %{severity
}"
msgid "%{labelStart}Se
nt request:%{labelEnd} %{headers
}"
msgstr ""
msgid "%{labelStart}S
tatus:%{labelEnd} %{status
}"
msgid "%{labelStart}S
everity:%{labelEnd} %{severity
}"
msgstr ""
msgid "%{labelStart}U
RL:%{labelEnd} %{url
}"
msgid "%{labelStart}U
nmodified response:%{labelEnd} %{headers
}"
msgstr ""
msgid "%{label_for_message} unavailable"
...
...
@@ -1799,6 +1802,9 @@ msgstr ""
msgid "Adding new applications is disabled in your GitLab instance. Please contact your GitLab administrator to get the permission"
msgstr ""
msgid "Additional Info"
msgstr ""
msgid "Additional Metadata"
msgstr ""
...
...
@@ -29694,6 +29700,9 @@ msgstr ""
msgid "Vulnerability|Activity"
msgstr ""
msgid "Vulnerability|Actual received response is the one received when this fault was detected"
msgstr ""
msgid "Vulnerability|Class"
msgstr ""
...
...
@@ -29742,10 +29751,7 @@ msgstr ""
msgid "Vulnerability|Project"
msgstr ""
msgid "Vulnerability|Request"
msgstr ""
msgid "Vulnerability|Response"
msgid "Vulnerability|Request/Response"
msgstr ""
msgid "Vulnerability|Scanner"
...
...
@@ -29760,6 +29766,9 @@ msgstr ""
msgid "Vulnerability|Status"
msgstr ""
msgid "Vulnerability|The unmodified response is the original response that had no mutations done to the request"
msgstr ""
msgid "Wait for the file to load to copy its contents"
msgstr ""
...
...
@@ -31240,6 +31249,9 @@ msgstr ""
msgid "ciReport|(is loading, errors when loading results)"
msgstr ""
msgid "ciReport|API Fuzzing"
msgstr ""
msgid "ciReport|All projects"
msgstr ""
...
...
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