Skip to content

Commit

Permalink
Feature: Enable lucene index rebuild through UI
Browse files Browse the repository at this point in the history
  • Loading branch information
syalioune committed Nov 29, 2022
1 parent 0594b53 commit 122a8bc
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@
"component_device": "Device",
"component_firmware": "Firmware",
"component_file": "File",
"dates": "Dates"
"dates": "Dates",
"reindex": "Rebuild indexe(s)"
},
"admin": {
"configuration": "Configuration",
Expand Down Expand Up @@ -599,7 +600,17 @@
"jira_username": "Jira user (service account). The user must be provisioned to the appropriate jira instance and permitted to create issues.",
"jira_password": "Jira password",
"jira_ticket_type": "Jira ticket type",
"jira_project_key": "Jira project key"
"jira_project_key": "Jira project key",
"reindex_projects": "Projects",
"reindex_components": "Components",
"reindex_service_components": "Service components",
"reindex_vulnerabilities": "Vulnerabilities",
"reindex_licenses": "Licenses",
"reindex_cpes": "CPE",
"reindex_vulnerable_software": "Vulnerable software",
"reindex_submitted": "Reindex request submitted",
"reindex_error": "Error encountered while submitting reindex request",
"reindex_description": "Rebuild the lucenes indexes used by Dependency Track to perform full text search or fuzzy match. TODO (Be more explicit)"
},
"condition": {
"warning": "Warning",
Expand Down
5 changes: 5 additions & 0 deletions src/views/administration/AdminMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
component: 'TaskScheduler',
name: this.$t('admin.task_scheduler'),
href: "#taskSchedulerTab"
},
{
component: 'Search',
name: this.$t('message.search'),
href: "#searchTab"
}
]
},
Expand Down
3 changes: 2 additions & 1 deletion src/views/administration/Administration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import Jira from "./configuration/JiraConfig";
import InternalComponents from "./configuration/InternalComponents";
import TaskScheduler from "./configuration/TaskScheduler.vue";
import Search from "./configuration/Search.vue";
// Analyzer plugins
import InternalAnalyzer from "./analyzers/InternalAnalyzer";
import OssIndexAnalyzer from "./analyzers/OssIndexAnalyzer";
Expand Down Expand Up @@ -64,7 +65,7 @@
components: {
EventBus,
AdminMenu,
General, BomFormats, Email, Jira, InternalComponents, TaskScheduler,
General, BomFormats, Email, Jira, InternalComponents, TaskScheduler, Search,
InternalAnalyzer, OssIndexAnalyzer, VulnDbAnalyzer, SnykAnalyzer,
VulnSourceNvd, VulnSourceGitHubAdvisories, VulnSourceOSVAdvisories,
Cargo, Composer, Gem, GoModules, Hex, Maven, Npm, Nuget, Python,
Expand Down
71 changes: 71 additions & 0 deletions src/views/administration/configuration/Search.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<template>
<b-card no-body :header="header">
<b-card-body>
<p>{{ $t('admin.reindex_description') }}</p>
<br/>
<c-switch id="project" color="primary" v-model="type.project" label v-bind="labelIcon" />{{$t('admin.reindex_projects')}}
<br/>
<c-switch id="component" color="primary" v-model="type.component" label v-bind="labelIcon" />{{$t('admin.reindex_components')}}
<br/>
<c-switch id="vulnerability" color="primary" v-model="type.vulnerability" label v-bind="labelIcon" />{{$t('admin.reindex_vulnerabilities')}}
<br/>
<c-switch id="vulnerablesoftware" color="primary" v-model="type.vulnerablesoftware" label v-bind="labelIcon" />{{$t('admin.reindex_vulnerable_software')}}
<br/>
<c-switch id="servicecomponent" color="primary" v-model="type.servicecomponent" label v-bind="labelIcon" />{{$t('admin.reindex_service_components')}}
<br/>
<c-switch id="license" color="primary" v-model="type.license" label v-bind="labelIcon" />{{$t('admin.reindex_licenses')}}
<br/>
<c-switch id="cpe" color="primary" v-model="type.cpe" label v-bind="labelIcon" />{{$t('admin.reindex_cpes')}}
<br/>
</b-card-body>
<b-card-footer>
<b-button size="md" class="px-4" variant="outline-primary" @click="reindex">{{ $t('message.reindex') }}</b-button>
</b-card-footer>
</b-card>
</template>

<script>
import { Switch as cSwitch } from '@coreui/vue';
export default {
props: {
header: String
},
components: {
cSwitch,
},
data() {
return {
type: {
project: false,
component: false,
vulnerability: false,
vulnerablesofware: false,
license: false,
cpe: false,
servicecomponent:false
},
labelIcon: {
dataOn: '\u2713',
dataOff: '\u2715'
}
}
},
methods: {
reindex: function() {
let url = `${this.$api.BASE_URL}/${this.$api.URL_SEARCH}/reindex`;
let params = new URLSearchParams();
Object.entries(this.type).forEach(([key, value]) => {
if(value) {
params.append('type', key.toUpperCase());
}
});
this.axios.post(url, null, { params: params }).then((response) => {
this.$toastr.s(this.$t('admin.reindex_submitted'));
}).catch((error) => {
this.$toastr.s(this.$t('admin.reindex_error'));
});
}
}
}
</script>

0 comments on commit 122a8bc

Please sign in to comment.