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
893aa265
Commit
893aa265
authored
May 27, 2021
by
Fernando
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add file-location component for generic security reports
Changelog: added MR: EE: true
parent
235a261d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
1 deletion
+71
-1
ee/app/assets/javascripts/vulnerabilities/components/generic_report/types/constants.js
...nerabilities/components/generic_report/types/constants.js
+2
-0
ee/app/assets/javascripts/vulnerabilities/components/generic_report/types/file_location.vue
...ilities/components/generic_report/types/file_location.vue
+28
-0
ee/spec/frontend/vulnerabilities/generic_report/report_item_spec.js
...ontend/vulnerabilities/generic_report/report_item_spec.js
+6
-1
ee/spec/frontend/vulnerabilities/generic_report/types/file_location_spec.js
...ulnerabilities/generic_report/types/file_location_spec.js
+35
-0
No files found.
ee/app/assets/javascripts/vulnerabilities/components/generic_report/types/constants.js
View file @
893aa265
...
...
@@ -8,6 +8,7 @@ export const REPORT_TYPES = {
text
:
'
text
'
,
value
:
'
value
'
,
moduleLocation
:
'
module-location
'
,
fileLocation
:
'
file-location
'
,
};
const
REPORT_TYPE_TO_COMPONENT_MAP
=
{
...
...
@@ -18,6 +19,7 @@ const REPORT_TYPE_TO_COMPONENT_MAP = {
[
REPORT_TYPES
.
text
]:
()
=>
import
(
'
./value.vue
'
),
[
REPORT_TYPES
.
value
]:
()
=>
import
(
'
./value.vue
'
),
[
REPORT_TYPES
.
moduleLocation
]:
()
=>
import
(
'
./module_location.vue
'
),
[
REPORT_TYPES
.
fileLocation
]:
()
=>
import
(
'
./file_location.vue
'
),
};
export
const
getComponentNameForType
=
(
reportType
)
=>
...
...
ee/app/assets/javascripts/vulnerabilities/components/generic_report/types/file_location.vue
0 → 100644
View file @
893aa265
<
script
>
export
default
{
inheritAttrs
:
false
,
props
:
{
fileName
:
{
type
:
String
,
required
:
true
,
},
lineStart
:
{
type
:
Number
,
required
:
true
,
},
lineEnd
:
{
type
:
Number
,
required
:
false
,
default
:
null
,
},
},
computed
:
{
lineStr
()
{
return
this
.
lineEnd
?
`
${
this
.
lineStart
}
-
${
this
.
lineEnd
}
`
:
this
.
lineStart
;
},
},
};
</
script
>
<
template
>
<span>
{{
fileName
}}
:
{{
lineStr
}}
</span>
</
template
>
ee/spec/frontend/vulnerabilities/generic_report/report_item_spec.js
View file @
893aa265
...
...
@@ -26,9 +26,14 @@ const TEST_DATA = {
value
:
15
,
},
[
REPORT_TYPES
.
moduleName
]:
{
'
module-name
'
:
'
foo.c
'
,
moduleName
:
'
foo.c
'
,
offset
:
15
,
},
[
REPORT_TYPES
.
fileLocation
]:
{
fileName
:
'
index.js
'
,
lineStart
:
'
1
'
,
lineEnd
:
'
2
'
,
},
};
describe
(
'
ee/vulnerabilities/components/generic_report/report_item.vue
'
,
()
=>
{
...
...
ee/spec/frontend/vulnerabilities/generic_report/types/file_location_spec.js
0 → 100644
View file @
893aa265
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
FileLocation
from
'
ee/vulnerabilities/components/generic_report/types/file_location.vue
'
;
describe
(
'
ee/vulnerabilities/components/generic_report/types/file_location.vue
'
,
()
=>
{
let
wrapper
;
describe
.
each
`
fileName | lineStart | lineEnd | value
${
'
foo.c
'
}
|
${
4
}
|
${
undefined
}
|
${
'
foo.c:4
'
}
${
'
bar.go
'
}
|
${
2
}
|
${
5
}
|
${
'
bar.go:2-5
'
}
`
(
'
with value of type "$fieldType"
'
,
({
fileName
,
lineStart
,
lineEnd
,
value
})
=>
{
const
createWrapper
=
()
=>
{
return
shallowMount
(
FileLocation
,
{
propsData
:
{
type
:
'
file-location
'
,
fileName
,
lineStart
,
lineEnd
,
},
});
};
beforeEach
(()
=>
{
wrapper
=
createWrapper
();
});
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
(
`renders
${
fileName
}
file location`
,
()
=>
{
expect
(
wrapper
.
text
()).
toBe
(
value
.
toString
());
});
});
});
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