Moving Security reports logic to the backend
And taking the opportunity to refactor the security reports store
Sam Beckham
@samdbeckham
HEAD
BASE
Current Branch
Default Branch
compare
parse
parse
result.json
result.json
result.json
Security Dashboard
Security Reports
filters
projects
vulnerabilities
Security Dashboard
Security Reports
vulnerabilities
Security Reports
SAST
DAST
Dependency
Container
Licenses
vulnerabilities
Dismiss
Vulnerability
// ee/.../vue_shared/security_reports/store/mediator.js
import * as types from './mutation_types';
const updateIssueActionsMap = {
sast: 'sast/updateVulnerability',
dependency_scanning: 'updateDependencyScanningIssue',
container_scanning: 'updateContainerScanningIssue',
dast: 'updateDastIssue',
};
export default function configureMediator(store) {
store.subscribe(({ type, payload }) => {
switch (type) {
case types.RECEIVE_DISMISS_VULNERABILITY_SUCCESS:
if (updateIssueActionsMap[payload.category]) {
store.dispatch(
updateIssueActionsMap[payload.category],
payload
);
}
break;
default:
}
});
}
Security Dashboard
import * as filtersMutationTypes from './modules/filters/mutation_types';
import * as projectsMutationTypes from './modules/projects/mutation_types';
import { BASE_FILTERS } from './modules/filters/constants';
export default function configureModerator(store) {
store.subscribe(({ type, payload }) => {
switch (type) {
case `projects/${projectsMutationTypes.RECEIVE_PROJECTS_SUCCESS}`:
store.dispatch('filters/setFilterOptions', {
filterId: 'project_id',
options: [
BASE_FILTERS.project_id,
...payload.projects.map(project => ({
name: project.name,
id: project.id.toString(),
})),
],
});
break;
case `filters/${filtersMutationTypes.SET_ALL_FILTERS}`:
case `filters/${filtersMutationTypes.SET_FILTER}`: {
const activeFilters = store.getters['filters/activeFilters'];
store.dispatch('vulnerabilities/fetchVulnerabilities', activeFilters);
store.dispatch('vulnerabilities/fetchVulnerabilitiesCount', activeFilters);
store.dispatch('vulnerabilities/fetchVulnerabilitiesHistory', activeFilters);
break;
}
default:
}
});
}
filters
projects
vulnerabilities
Moving Security reports to the backend
By Sam Beckham
Moving Security reports to the backend
- 1,047