Commit dfb7e090 authored by Vitaly Slobodin's avatar Vitaly Slobodin

Merge branch '292890-artifact-download-reproduction-assets' into 'master'

Show Vuln reproduction assset download links

See merge request gitlab-org/gitlab!50748
parents f3b09ebf f691fb58
...@@ -58,6 +58,9 @@ export default { ...@@ -58,6 +58,9 @@ export default {
namespace() { namespace() {
return this.vulnLocation?.operating_system; return this.vulnLocation?.operating_system;
}, },
assets() {
return this.asNonEmptyListOrNull(this.vulnerability.assets);
},
links() { links() {
return this.asNonEmptyListOrNull(this.vulnerability.links); return this.asNonEmptyListOrNull(this.vulnerability.links);
}, },
...@@ -258,5 +261,21 @@ export default { ...@@ -258,5 +261,21 @@ export default {
<span v-if="hasMoreValues(i, links)">,&nbsp;</span> <span v-if="hasMoreValues(i, links)">,&nbsp;</span>
</span> </span>
</vulnerability-detail> </vulnerability-detail>
<vulnerability-detail v-if="assets" :label="s__('Vulnerability|Reproduction Assets')">
<span v-for="(asset, i) in assets" :key="i">
<gl-link
v-if="asset.url"
ref="assetsLink"
class="gl-word-break-all"
:href="asset.url"
target="_blank"
rel="nofollow"
>
{{ s__('Vulnerability|Download') }} {{ asset.name }}
</gl-link>
<span v-else> {{ asset.name }} </span>
<span v-if="hasMoreValues(i, assets)">,&nbsp;</span>
</span>
</vulnerability-detail>
</div> </div>
</template> </template>
...@@ -377,5 +377,24 @@ export default { ...@@ -377,5 +377,24 @@ export default {
</detail-item> </detail-item>
</ul> </ul>
</template> </template>
<template v-if="vulnerability.assets && vulnerability.assets.length">
<h3>{{ s__('Vulnerability|Reproduction Assets') }}</h3>
<ul>
<li
v-for="(asset, index) in vulnerability.assets"
:key="`${index}:${asset.url}`"
class="gl-ml-0! gl-list-style-position-inside"
>
<component
:is="asset.url ? 'gl-link' : 'span'"
v-bind="asset.url && { href: asset.url, target: '_blank' }"
data-testid="asset"
>
{{ asset.name }}
</component>
</li>
</ul>
</template>
</div> </div>
</template> </template>
---
title: Show Vulnerability reproduction asset downloads
merge_request: 50748
author:
type: added
...@@ -182,5 +182,7 @@ exports[`VulnerabilityDetails component pin test renders correctly 1`] = ` ...@@ -182,5 +182,7 @@ exports[`VulnerabilityDetails component pin test renders correctly 1`] = `
<!----> <!---->
</span> </span>
</vulnerability-detail-stub> </vulnerability-detail-stub>
<!---->
</div> </div>
`; `;
...@@ -112,6 +112,7 @@ describe('VulnerabilityDetails component', () => { ...@@ -112,6 +112,7 @@ describe('VulnerabilityDetails component', () => {
}, },
links: [{ url: badUrl }], links: [{ url: badUrl }],
identifiers: [{ name: 'BAD_URL', url: badUrl }], identifiers: [{ name: 'BAD_URL', url: badUrl }],
assets: [{ name: 'BAD_URL', url: badUrl }],
}); });
componentFactory(vulnerability); componentFactory(vulnerability);
...@@ -125,6 +126,10 @@ describe('VulnerabilityDetails component', () => { ...@@ -125,6 +126,10 @@ describe('VulnerabilityDetails component', () => {
expectSafeLink({ link: findLink('identifiers'), href: 'about:blank', text: 'BAD_URL' }); expectSafeLink({ link: findLink('identifiers'), href: 'about:blank', text: 'BAD_URL' });
}); });
it('for the assets field', () => {
expectSafeLink({ link: findLink('assets'), href: 'about:blank', text: 'Download BAD_URL' });
});
it('for the file field', () => { it('for the file field', () => {
expectSafeLink({ expectSafeLink({
link: findLink('file'), link: findLink('file'),
......
...@@ -124,6 +124,41 @@ describe('Vulnerability Details', () => { ...@@ -124,6 +124,41 @@ describe('Vulnerability Details', () => {
identifiersData.forEach(checkIdentifier); identifiersData.forEach(checkIdentifier);
}); });
it('shows the vulnerability assets if they exist', () => {
const assetsData = [
{ name: 'Postman Collection', url: 'http://example.com/postman' },
{ name: 'HTTP Messages', url: 'http://example.com/http-messages' },
{ name: 'Foo' },
{ name: 'Bar' },
];
createWrapper({
assets: assetsData,
});
const assets = getAllById('asset');
expect(assets).toHaveLength(assetsData.length);
const checkIdentifier = ({ name, url }, index) => {
const asset = assets.at(index);
expect(asset.text()).toBe(name);
if (url) {
expect(asset.is(GlLink)).toBe(true);
expect(asset.attributes()).toMatchObject({
target: '_blank',
href: url,
});
} else {
expect(asset.is(GlLink)).toBe(false);
}
};
assetsData.forEach(checkIdentifier);
});
describe('file link', () => { describe('file link', () => {
const file = () => getById('file').find(GlLink); const file = () => getById('file').find(GlLink);
......
...@@ -31240,6 +31240,9 @@ msgstr "" ...@@ -31240,6 +31240,9 @@ msgstr ""
msgid "Vulnerability|Detected" msgid "Vulnerability|Detected"
msgstr "" msgstr ""
msgid "Vulnerability|Download"
msgstr ""
msgid "Vulnerability|Evidence" msgid "Vulnerability|Evidence"
msgstr "" msgstr ""
...@@ -31267,6 +31270,9 @@ msgstr "" ...@@ -31267,6 +31270,9 @@ msgstr ""
msgid "Vulnerability|Project" msgid "Vulnerability|Project"
msgstr "" msgstr ""
msgid "Vulnerability|Reproduction Assets"
msgstr ""
msgid "Vulnerability|Request" msgid "Vulnerability|Request"
msgstr "" msgstr ""
......
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