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 { ...@@ -213,7 +213,7 @@ export default {
}, },
methods: { methods: {
createLocationString(location) { createLocationString(location) {
const { image, file, startLine } = location; const { image, file, startLine, path } = location;
if (image) { if (image) {
return image; return image;
...@@ -223,6 +223,10 @@ export default { ...@@ -223,6 +223,10 @@ export default {
return `${file} ${sprintf(__('(line: %{startLine})'), { startLine })}`; return `${file} ${sprintf(__('(line: %{startLine})'), { startLine })}`;
} }
if (path) {
return path;
}
return file; return file;
}, },
deselectVulnerability(vulnerabilityId) { deselectVulnerability(vulnerabilityId) {
...@@ -253,7 +257,7 @@ export default { ...@@ -253,7 +257,7 @@ export default {
return identifiers?.length > 1; return identifiers?.length > 1;
}, },
shouldShowVulnerabilityPath(item) { shouldShowVulnerabilityPath(item) {
return Boolean(item.location.image || item.location.file); return Boolean(item.location.image || item.location.file || item.location.path);
}, },
toggleAllVulnerabilities() { toggleAllVulnerabilities() {
if (this.hasSelectedAllVulnerabilities) { if (this.hasSelectedAllVulnerabilities) {
......
...@@ -37,6 +37,10 @@ fragment Vulnerability on Vulnerability { ...@@ -37,6 +37,10 @@ fragment Vulnerability on Vulnerability {
file file
startLine startLine
} }
... on VulnerabilityLocationDast {
hostname
path
}
} }
project { project {
nameWithNamespace nameWithNamespace
......
...@@ -97,6 +97,19 @@ export const generateVulnerabilities = () => [ ...@@ -97,6 +97,19 @@ export const generateVulnerabilities = () => [
}, },
scanner: {}, 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(); export const vulnerabilities = generateVulnerabilities();
...@@ -234,6 +234,16 @@ describe('Vulnerability list component', () => { ...@@ -234,6 +234,16 @@ describe('Vulnerability list component', () => {
expect(cellText).toEqual(project.nameWithNamespace); expect(cellText).toEqual(project.nameWithNamespace);
expect(cellText).not.toContain('(line: '); 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', () => { 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