Commit d43a1ed5 authored by nmccorrison's avatar nmccorrison

Added DAST path to display on vulnerabilities list

Previously the path/URL wasn't displayed for DAST items
parent 4d105437
......@@ -213,7 +213,7 @@ export default {
},
methods: {
createLocationString(location) {
const { image, file, startLine } = location;
const { image, file, startLine, path } = location;
if (image) {
return image;
......@@ -223,6 +223,10 @@ export default {
return `${file} ${sprintf(__('(line: %{startLine})'), { startLine })}`;
}
if (path) {
return path;
}
return file;
},
deselectVulnerability(vulnerabilityId) {
......@@ -253,7 +257,7 @@ export default {
return identifiers?.length > 1;
},
shouldShowVulnerabilityPath(item) {
return Boolean(item.location.image || item.location.file);
return Boolean(item.location.image || item.location.file || item.location.path);
},
toggleAllVulnerabilities() {
if (this.hasSelectedAllVulnerabilities) {
......
......@@ -37,6 +37,10 @@ fragment Vulnerability on Vulnerability {
file
startLine
}
... on VulnerabilityLocationDast {
hostname
path
}
}
project {
nameWithNamespace
......
......@@ -97,6 +97,19 @@ export const generateVulnerabilities = () => [
},
scanner: {},
},
{
id: 'id_5',
title: 'Vulnerability 5',
severity: 'high',
state: 'DETECTED',
location: {
path: '/v1/trees'
},
project: {
nameWithNamespace: 'Administrator / Security reports',
},
scanner: {},
},
];
export const vulnerabilities = generateVulnerabilities();
......@@ -234,6 +234,16 @@ describe('Vulnerability list component', () => {
expect(cellText).toEqual(project.nameWithNamespace);
expect(cellText).not.toContain('(line: ');
});
it('should display the vulnerability locations for path', () => {
const { id, project, location } = newVulnerabilities[5];
const cell = findDataCell(`location-${id}`);
expect(cell.text()).toContain(project.nameWithNamespace);
expect(findLocationTextWrapper(cell).props()).toEqual({
text: location.path,
position: 'middle',
});
});
});
describe('when displayed on a project level dashboard', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment