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
f5d98989
Commit
f5d98989
authored
Jun 12, 2021
by
Daniel Tian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use standard filter for scanner filter on non-project level vuln report
Changelog: changed EE: true
parent
59d04e93
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
17 deletions
+53
-17
ee/app/assets/javascripts/security_dashboard/components/pipeline/filters.vue
...cripts/security_dashboard/components/pipeline/filters.vue
+2
-2
ee/app/assets/javascripts/security_dashboard/components/shared/filters/filters_layout.vue
...ty_dashboard/components/shared/filters/filters_layout.vue
+20
-3
ee/app/assets/javascripts/security_dashboard/helpers.js
ee/app/assets/javascripts/security_dashboard/helpers.js
+7
-2
ee/spec/frontend/security_dashboard/components/pipeline/filters_spec.js
...nd/security_dashboard/components/pipeline/filters_spec.js
+3
-3
ee/spec/frontend/security_dashboard/components/shared/filters/filters_layout_spec.js
...ashboard/components/shared/filters/filters_layout_spec.js
+18
-4
ee/spec/frontend/security_dashboard/components/shared/filters/scanner_filter_spec.js
...ashboard/components/shared/filters/scanner_filter_spec.js
+3
-3
No files found.
ee/app/assets/javascripts/security_dashboard/components/pipeline/filters.vue
View file @
f5d98989
<
script
>
<
script
>
import
{
GlToggle
}
from
'
@gitlab/ui
'
;
import
{
GlToggle
}
from
'
@gitlab/ui
'
;
import
{
mapState
,
mapActions
}
from
'
vuex
'
;
import
{
mapState
,
mapActions
}
from
'
vuex
'
;
import
{
severityFilter
,
pipeline
ScannerFilter
}
from
'
ee/security_dashboard/helpers
'
;
import
{
severityFilter
,
standard
ScannerFilter
}
from
'
ee/security_dashboard/helpers
'
;
import
{
DISMISSAL_STATES
}
from
'
ee/security_dashboard/store/modules/filters/constants
'
;
import
{
DISMISSAL_STATES
}
from
'
ee/security_dashboard/store/modules/filters/constants
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
}
from
'
~/locale
'
;
import
StandardFilter
from
'
../shared/filters/standard_filter.vue
'
;
import
StandardFilter
from
'
../shared/filters/standard_filter.vue
'
;
...
@@ -16,7 +16,7 @@ export default {
...
@@ -16,7 +16,7 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
filterConfigs
:
[
severityFilter
,
pipeline
ScannerFilter
],
filterConfigs
:
[
severityFilter
,
standard
ScannerFilter
],
};
};
},
},
computed
:
{
computed
:
{
...
...
ee/app/assets/javascripts/security_dashboard/components/shared/filters/filters_layout.vue
View file @
f5d98989
...
@@ -3,7 +3,8 @@ import { debounce } from 'lodash';
...
@@ -3,7 +3,8 @@ import { debounce } from 'lodash';
import
{
import
{
stateFilter
,
stateFilter
,
severityFilter
,
severityFilter
,
scannerFilter
,
vendorScannerFilter
,
standardScannerFilter
,
activityFilter
,
activityFilter
,
getProjectFilter
,
getProjectFilter
,
}
from
'
ee/security_dashboard/helpers
'
;
}
from
'
ee/security_dashboard/helpers
'
;
...
@@ -25,6 +26,9 @@ export default {
...
@@ -25,6 +26,9 @@ export default {
};
};
},
},
computed
:
{
computed
:
{
isProjectDashboard
()
{
return
this
.
dashboardType
===
DASHBOARD_TYPES
.
PROJECT
;
},
isPipeline
()
{
isPipeline
()
{
return
this
.
dashboardType
===
DASHBOARD_TYPES
.
PIPELINE
;
return
this
.
dashboardType
===
DASHBOARD_TYPES
.
PIPELINE
;
},
},
...
@@ -46,7 +50,8 @@ export default {
...
@@ -46,7 +50,8 @@ export default {
this
.
$emit
(
'
filterChange
'
,
this
.
filterQuery
);
this
.
$emit
(
'
filterChange
'
,
this
.
filterQuery
);
}),
}),
},
},
scannerFilter
,
vendorScannerFilter
,
standardScannerFilter
,
activityFilter
,
activityFilter
,
};
};
</
script
>
</
script
>
...
@@ -62,7 +67,19 @@ export default {
...
@@ -62,7 +67,19 @@ export default {
:data-testid=
"filter.id"
:data-testid=
"filter.id"
@
filter-changed=
"updateFilterQuery"
@
filter-changed=
"updateFilterQuery"
/>
/>
<scanner-filter
:filter=
"$options.scannerFilter"
@
filter-changed=
"updateFilterQuery"
/>
<scanner-filter
v-if=
"isProjectDashboard"
:filter=
"$options.vendorScannerFilter"
@
filter-changed=
"updateFilterQuery"
/>
<standard-filter
v-else
:filter=
"$options.standardScannerFilter"
:data-testid=
"$options.standardScannerFilter.id"
@
filter-changed=
"updateFilterQuery"
/>
<activity-filter
<activity-filter
v-if=
"!isPipeline"
v-if=
"!isPipeline"
:filter=
"$options.activityFilter"
:filter=
"$options.activityFilter"
...
...
ee/app/assets/javascripts/security_dashboard/helpers.js
View file @
f5d98989
...
@@ -43,7 +43,10 @@ export const createScannerOption = (vendor, reportType) => {
...
@@ -43,7 +43,10 @@ export const createScannerOption = (vendor, reportType) => {
};
};
};
};
export
const
pipelineScannerFilter
=
{
// This is used on the pipeline security tab, group-level report, and instance-level report. It's
// used by the scanner filter that shows a flat list of scan types (DAST, SAST, etc) with no vendor
// grouping.
export
const
standardScannerFilter
=
{
name
:
s__
(
'
SecurityReports|Scanner
'
),
name
:
s__
(
'
SecurityReports|Scanner
'
),
id
:
'
reportType
'
,
id
:
'
reportType
'
,
options
:
parseOptions
(
REPORT_TYPES
),
options
:
parseOptions
(
REPORT_TYPES
),
...
@@ -51,7 +54,9 @@ export const pipelineScannerFilter = {
...
@@ -51,7 +54,9 @@ export const pipelineScannerFilter = {
defaultOptions
:
[],
defaultOptions
:
[],
};
};
export
const
scannerFilter
=
{
// This is used on the project-level report. It's used by the scanner filter that shows a list of
// scan types (DAST, SAST, etc) that's grouped by vendor.
export
const
vendorScannerFilter
=
{
name
:
s__
(
'
SecurityReports|Scanner
'
),
name
:
s__
(
'
SecurityReports|Scanner
'
),
id
:
'
scanner
'
,
id
:
'
scanner
'
,
options
:
Object
.
keys
(
REPORT_TYPES
).
map
((
x
)
=>
createScannerOption
(
DEFAULT_SCANNER
,
x
)),
options
:
Object
.
keys
(
REPORT_TYPES
).
map
((
x
)
=>
createScannerOption
(
DEFAULT_SCANNER
,
x
)),
...
...
ee/spec/frontend/security_dashboard/components/pipeline/filters_spec.js
View file @
f5d98989
...
@@ -2,7 +2,7 @@ import { GlToggle } from '@gitlab/ui';
...
@@ -2,7 +2,7 @@ import { GlToggle } from '@gitlab/ui';
import
{
shallowMount
,
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
,
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
Filters
from
'
ee/security_dashboard/components/pipeline/filters.vue
'
;
import
Filters
from
'
ee/security_dashboard/components/pipeline/filters.vue
'
;
import
{
pipeline
ScannerFilter
}
from
'
ee/security_dashboard/helpers
'
;
import
{
standard
ScannerFilter
}
from
'
ee/security_dashboard/helpers
'
;
import
createStore
from
'
ee/security_dashboard/store
'
;
import
createStore
from
'
ee/security_dashboard/store
'
;
import
state
from
'
ee/security_dashboard/store/modules/filters/state
'
;
import
state
from
'
ee/security_dashboard/store/modules/filters/state
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
...
@@ -75,8 +75,8 @@ describe('Filter component', () => {
...
@@ -75,8 +75,8 @@ describe('Filter component', () => {
// scanner filter item.
// scanner filter item.
mock
.
mockClear
();
mock
.
mockClear
();
const
filterId
=
pipeline
ScannerFilter
.
id
;
const
filterId
=
standard
ScannerFilter
.
id
;
const
optionId
=
pipeline
ScannerFilter
.
options
[
2
].
id
;
const
optionId
=
standard
ScannerFilter
.
options
[
2
].
id
;
const
option
=
wrapper
.
findByTestId
(
`
${
filterId
}
:
${
optionId
}
`
);
const
option
=
wrapper
.
findByTestId
(
`
${
filterId
}
:
${
optionId
}
`
);
option
.
vm
.
$emit
(
'
click
'
);
option
.
vm
.
$emit
(
'
click
'
);
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
...
...
ee/spec/frontend/security_dashboard/components/shared/filters/filters_layout_spec.js
View file @
f5d98989
...
@@ -3,7 +3,7 @@ import ActivityFilter from 'ee/security_dashboard/components/shared/filters/acti
...
@@ -3,7 +3,7 @@ import ActivityFilter from 'ee/security_dashboard/components/shared/filters/acti
import
Filters
from
'
ee/security_dashboard/components/shared/filters/filters_layout.vue
'
;
import
Filters
from
'
ee/security_dashboard/components/shared/filters/filters_layout.vue
'
;
import
ScannerFilter
from
'
ee/security_dashboard/components/shared/filters/scanner_filter.vue
'
;
import
ScannerFilter
from
'
ee/security_dashboard/components/shared/filters/scanner_filter.vue
'
;
import
StandardFilter
from
'
ee/security_dashboard/components/shared/filters/standard_filter.vue
'
;
import
StandardFilter
from
'
ee/security_dashboard/components/shared/filters/standard_filter.vue
'
;
import
{
getProjectFilter
}
from
'
ee/security_dashboard/helpers
'
;
import
{
getProjectFilter
,
standardScannerFilter
}
from
'
ee/security_dashboard/helpers
'
;
import
{
DASHBOARD_TYPES
}
from
'
ee/security_dashboard/store/constants
'
;
import
{
DASHBOARD_TYPES
}
from
'
ee/security_dashboard/store/constants
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
...
@@ -16,7 +16,8 @@ describe('First class vulnerability filters component', () => {
...
@@ -16,7 +16,8 @@ describe('First class vulnerability filters component', () => {
];
];
const
findStandardFilters
=
()
=>
wrapper
.
findAllComponents
(
StandardFilter
);
const
findStandardFilters
=
()
=>
wrapper
.
findAllComponents
(
StandardFilter
);
const
findScannerFilter
=
()
=>
wrapper
.
findComponent
(
ScannerFilter
);
const
findStandardScannerFilter
=
()
=>
wrapper
.
findByTestId
(
standardScannerFilter
.
id
);
const
findVendorScannerFilter
=
()
=>
wrapper
.
findComponent
(
ScannerFilter
);
const
findActivityFilter
=
()
=>
wrapper
.
findComponent
(
ActivityFilter
);
const
findActivityFilter
=
()
=>
wrapper
.
findComponent
(
ActivityFilter
);
const
findProjectFilter
=
()
=>
wrapper
.
findByTestId
(
getProjectFilter
([]).
id
);
const
findProjectFilter
=
()
=>
wrapper
.
findByTestId
(
getProjectFilter
([]).
id
);
...
@@ -34,7 +35,6 @@ describe('First class vulnerability filters component', () => {
...
@@ -34,7 +35,6 @@ describe('First class vulnerability filters component', () => {
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
});
describe
(
'
on render without project filter
'
,
()
=>
{
describe
(
'
on render without project filter
'
,
()
=>
{
...
@@ -44,7 +44,6 @@ describe('First class vulnerability filters component', () => {
...
@@ -44,7 +44,6 @@ describe('First class vulnerability filters component', () => {
it
(
'
should render the default filters
'
,
()
=>
{
it
(
'
should render the default filters
'
,
()
=>
{
expect
(
findStandardFilters
()).
toHaveLength
(
2
);
expect
(
findStandardFilters
()).
toHaveLength
(
2
);
expect
(
findScannerFilter
().
exists
()).
toBe
(
true
);
expect
(
findActivityFilter
().
exists
()).
toBe
(
true
);
expect
(
findActivityFilter
().
exists
()).
toBe
(
true
);
expect
(
findProjectFilter
().
exists
()).
toBe
(
false
);
expect
(
findProjectFilter
().
exists
()).
toBe
(
false
);
});
});
...
@@ -83,4 +82,19 @@ describe('First class vulnerability filters component', () => {
...
@@ -83,4 +82,19 @@ describe('First class vulnerability filters component', () => {
expect
(
findActivityFilter
().
exists
()).
toBe
(
false
);
expect
(
findActivityFilter
().
exists
()).
toBe
(
false
);
});
});
});
});
describe
(
'
scanner filter
'
,
()
=>
{
it
.
each
`
type | dashboardType
${
'
vendor
'
}
|
${
DASHBOARD_TYPES
.
PROJECT
}
${
'
standard
'
}
|
${
DASHBOARD_TYPES
.
GROUP
}
${
'
standard
'
}
|
${
DASHBOARD_TYPES
.
INSTANCE
}
${
'
standard
'
}
|
${
DASHBOARD_TYPES
.
PIPELINE
}
`
(
'
shows the $type scanner filter on the $dashboardType report
'
,
({
type
,
dashboardType
})
=>
{
wrapper
=
createComponent
({
provide
:
{
dashboardType
}
});
expect
(
findStandardScannerFilter
().
exists
()).
toBe
(
type
===
'
standard
'
);
expect
(
findVendorScannerFilter
().
exists
()).
toBe
(
type
===
'
vendor
'
);
});
});
});
});
ee/spec/frontend/security_dashboard/components/shared/filters/scanner_filter_spec.js
View file @
f5d98989
...
@@ -5,7 +5,7 @@ import VueRouter from 'vue-router';
...
@@ -5,7 +5,7 @@ import VueRouter from 'vue-router';
import
FilterItem
from
'
ee/security_dashboard/components/shared/filters/filter_item.vue
'
;
import
FilterItem
from
'
ee/security_dashboard/components/shared/filters/filter_item.vue
'
;
import
ScannerFilter
from
'
ee/security_dashboard/components/shared/filters/scanner_filter.vue
'
;
import
ScannerFilter
from
'
ee/security_dashboard/components/shared/filters/scanner_filter.vue
'
;
import
{
DEFAULT_SCANNER
,
SCANNER_ID_PREFIX
}
from
'
ee/security_dashboard/constants
'
;
import
{
DEFAULT_SCANNER
,
SCANNER_ID_PREFIX
}
from
'
ee/security_dashboard/constants
'
;
import
{
s
cannerFilter
}
from
'
ee/security_dashboard/helpers
'
;
import
{
vendorS
cannerFilter
}
from
'
ee/security_dashboard/helpers
'
;
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
localVue
.
use
(
VueRouter
);
localVue
.
use
(
VueRouter
);
...
@@ -40,7 +40,7 @@ describe('Scanner Filter component', () => {
...
@@ -40,7 +40,7 @@ describe('Scanner Filter component', () => {
let
filter
;
let
filter
;
const
createWrapper
=
({
scanners
=
customScanners
}
=
{})
=>
{
const
createWrapper
=
({
scanners
=
customScanners
}
=
{})
=>
{
filter
=
cloneDeep
(
s
cannerFilter
);
filter
=
cloneDeep
(
vendorS
cannerFilter
);
wrapper
=
shallowMount
(
ScannerFilter
,
{
wrapper
=
shallowMount
(
ScannerFilter
,
{
localVue
,
localVue
,
...
@@ -122,7 +122,7 @@ describe('Scanner Filter component', () => {
...
@@ -122,7 +122,7 @@ describe('Scanner Filter component', () => {
it
(
'
emits filter-changed event with expected data for selected options
'
,
async
()
=>
{
it
(
'
emits filter-changed event with expected data for selected options
'
,
async
()
=>
{
const
ids
=
[
'
GitLab.SAST
'
,
'
Custom.SAST
'
,
'
GitLab.API_FUZZING
'
,
'
GitLab.COVERAGE_FUZZING
'
];
const
ids
=
[
'
GitLab.SAST
'
,
'
Custom.SAST
'
,
'
GitLab.API_FUZZING
'
,
'
GitLab.COVERAGE_FUZZING
'
];
router
.
replace
({
query
:
{
[
s
cannerFilter
.
id
]:
ids
}
});
router
.
replace
({
query
:
{
[
vendorS
cannerFilter
.
id
]:
ids
}
});
const
selectedScanners
=
customScanners
.
filter
((
x
)
=>
const
selectedScanners
=
customScanners
.
filter
((
x
)
=>
ids
.
includes
(
`
${
x
.
vendor
}
.
${
x
.
report_type
}
`
),
ids
.
includes
(
`
${
x
.
vendor
}
.
${
x
.
report_type
}
`
),
);
);
...
...
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