Skip to content

Commit 73ab6fe

Browse files
committed
user-enabled list of ecosystem
Signed-off-by: Sahiba Mittal <[email protected]>
1 parent 7181829 commit 73ab6fe

File tree

4 files changed

+120
-19
lines changed

4 files changed

+120
-19
lines changed

src/i18n/locales/en.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@
390390
"nvd": "NVD",
391391
"national_vulnerability_database": "National Vulnerability Database",
392392
"github_advisories": "GitHub Advisories",
393-
"osv_advisories": "Google OSV Advisories",
393+
"osv_advisories": "Google OSV Advisories (Beta)",
394394
"repositories": "Repositories",
395395
"cargo": "Cargo",
396396
"composer": "Composer",
@@ -455,7 +455,7 @@
455455
"vulnsource_nvd_feeds_url": "NVD Feeds URL",
456456
"vulnsource_github_advisories_enable": "Enable GitHub Advisory mirroring",
457457
"vulnsource_github_advisories_desc": "GitHub Advisories (GHSA) is a database of CVEs and GitHub-originated security advisories affecting the open source world. Dependency-Track integrates with GHSA by mirroring advisories via GitHub's public GraphQL API. The mirror is refreshed daily, or upon restart of the Dependency-Track instance. A personal access token (PAT) is required in order to authenticate with GitHub, but no scopes need to be assigned to it.",
458-
"vulnsource_osv_advisories_enable": "Enable Google OSV Advisory mirroring",
458+
"vulnsource_osv_advisories_enable": "Select ecosystem to enable Google OSV Advisory mirroring",
459459
"vulnsource_osv_advisories_desc": "Google OSV is a distributed vulnerability and triage infrastructure for open source projects aimed at helping both open source maintainers and consumers of open source. It serves as an aggregator of vulnerability databases that have adopted the OpenSSF Vulnerability format.",
460460
"registered_email_address": "Registered email address",
461461
"api_token": "API token",

src/shared/api.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@
5252
"URL_LICENSE_GROUP": "api/v1/licenseGroup",
5353
"URL_ACL_MAPPING": "api/v1/acl/mapping",
5454
"URL_ACL_TEAM": "api/v1/acl/team",
55-
"URL_VEX": "api/v1/vex"
55+
"URL_VEX": "api/v1/vex",
56+
"URL_OSV_ECOSYSTEM": "api/v1/integration/osv/ecosystem"
5657
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<template>
2+
<b-modal id="ecosystemModal" size="lg" hide-header-close no-stacking :title="$t('admin.select_ecosystem')">
3+
<bootstrap-table
4+
ref="table"
5+
:columns="columns"
6+
:data="data"
7+
:options="options">
8+
</bootstrap-table>
9+
<template v-slot:modal-footer="{ cancel }">
10+
<b-button size="md" variant="secondary" @click="cancel()">{{ $t('message.cancel') }}</b-button>
11+
<b-button size="md" variant="primary" @click="$emit('selection', $refs.table.getSelections())">{{ $t('message.select') }}</b-button>
12+
</template>
13+
</b-modal>
14+
</template>
15+
16+
<script>
17+
import xssFilters from "xss-filters";
18+
import common from "../../../shared/common";
19+
20+
export default {
21+
mixins: [],
22+
data() {
23+
return {
24+
labelIcon: {
25+
dataOn: '\u2713',
26+
dataOff: '\u2715'
27+
},
28+
columns: [
29+
{
30+
field: "state",
31+
checkbox: true,
32+
align: "center"
33+
},
34+
{
35+
title: this.$t('message.name'),
36+
field: "name",
37+
sortable: true,
38+
formatter(value) {
39+
return xssFilters.inHTMLData(common.valueWithDefault(value, ""));
40+
}
41+
}
42+
],
43+
data: [],
44+
options: {
45+
search: true,
46+
showColumns: true,
47+
showRefresh: true,
48+
pagination: true,
49+
silentSort: false,
50+
sidePagination: 'client',
51+
queryParamsType: 'pageSize',
52+
pageList: '[10, 25, 50, 100]',
53+
pageSize: 10,
54+
icons: {
55+
refresh: 'fa-refresh'
56+
},
57+
responseHandler: function (res, xhr) {
58+
res.total = xhr.getResponseHeader("X-Total-Count");
59+
return res.map(ecosystem => ({
60+
name: ecosystem
61+
}));
62+
},
63+
url: `${this.$api.BASE_URL}/${this.$api.URL_OSV_ECOSYSTEM}`
64+
}
65+
};
66+
}
67+
}
68+
</script>

src/views/administration/vuln-sources/VulnSourceOSVAdvisories.vue

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,78 @@
99
label
1010
v-bind="labelIcon"
1111
v-model="vulnsourceEnabled"
12+
@change="handleVulnsourceEnabled"
13+
:disabled="enabledEcosystems.length === 0"
1214
/>
1315
{{$t('admin.vulnsource_osv_advisories_enable')}}
1416
<hr/>
1517
{{ $t('admin.vulnsource_osv_advisories_desc') }}
1618
</b-card-body>
17-
<b-card-footer>
18-
<b-button
19-
@click="saveChanges"
20-
class="px-4"
21-
variant="outline-primary">
22-
{{ $t('message.update') }}
23-
</b-button>
24-
</b-card-footer>
19+
<b-card-body>
20+
<b-form-group label="Ecosystems">
21+
<div class="list-group" style="width: 40%">
22+
<span v-for="ecosystem in enabledEcosystems" :key="ecosystem">
23+
<actionable-list-group-item :value="ecosystem" :delete-icon="true" @actionClicked="removeEcosystem(ecosystem)"/>
24+
</span>
25+
<actionable-list-group-item :add-icon="true" @actionClicked="$root.$emit('bv::show::modal', 'ecosystemModal')"/>
26+
</div>
27+
</b-form-group>
28+
<hr/>
29+
</b-card-body>
30+
<ecosystem-modal v-on:selection="updateEcosystem"/>
2531
</b-card>
2632
</template>
27-
2833
<script>
34+
2935
import { Switch as cSwitch } from '@coreui/vue';
30-
import common from "../../../shared/common";
3136
import configPropertyMixin from "../mixins/configPropertyMixin";
37+
import EcosystemModal from "./EcosystemModal";
38+
import ActionableListGroupItem from '../../components/ActionableListGroupItem.vue';
3239
3340
export default {
3441
mixins: [configPropertyMixin],
3542
props: {
3643
header: String
3744
},
3845
components: {
39-
cSwitch
40-
},
46+
cSwitch,
47+
EcosystemModal,
48+
ActionableListGroupItem
49+
},
4150
data() {
4251
return {
4352
vulnsourceEnabled: false,
53+
ecosystemConfig: null,
54+
enabledEcosystems: [],
4455
labelIcon: {
4556
dataOn: '\u2713',
4657
dataOff: '\u2715'
4758
},
4859
}
4960
},
5061
methods: {
51-
saveChanges: function() {
62+
removeEcosystem: function(ecosystem) {
63+
this.enabledEcosystems = this.enabledEcosystems.filter(e => e !== ecosystem);
64+
this.vulnsourceEnabled = this.enabledEcosystems.length !== 0;
5265
this.updateConfigProperties([
53-
{groupName: 'vuln-source', propertyName: 'google.osv.enabled', propertyValue: this.vulnsourceEnabled}
66+
{groupName: 'vuln-source', propertyName: 'google.osv.enabled', propertyValue: this.enabledEcosystems.join(";")}
5467
]);
68+
},
69+
updateEcosystem: function(ecosystems) {
70+
this.$root.$emit('bv::hide::modal', 'ecosystemModal');
71+
for(let i=0; i<ecosystems.length; i++) {
72+
let ecosystem = ecosystems[i];
73+
this.enabledEcosystems.push(ecosystem.name);
74+
}
75+
this.vulnsourceEnabled = this.enabledEcosystems.length !== 0;
76+
this.updateConfigProperties([
77+
{groupName: 'vuln-source', propertyName: 'google.osv.enabled', propertyValue: this.enabledEcosystems.join(";")}
78+
]);
79+
},
80+
handleVulnsourceEnabled: function(vulnsourceEnabled) {
81+
if (vulnsourceEnabled === false) {
82+
this.enabledEcosystems = [];
83+
}
5584
}
5685
},
5786
created () {
@@ -61,10 +90,13 @@ export default {
6190
let item = configItems[i];
6291
switch (item.propertyName) {
6392
case "google.osv.enabled":
64-
this.vulnsourceEnabled = common.toBoolean(item.propertyValue); break;
93+
this.ecosystemConfig = item.propertyValue;
94+
this.vulnsourceEnabled = this.ecosystemConfig != null;
95+
break;
6596
}
6697
}
98+
this.enabledEcosystems = this.ecosystemConfig.split(';').map(ecosystem => ecosystem.trim());
6799
});
68100
}
69101
}
70-
</script>
102+
</script>

0 commit comments

Comments
 (0)