Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

πŸ”€ Sync from master

Alicia Sykes902feaa1066e
diff --cc src/components/Widgets/CveVulnerabilities.vue
index a14df14d,3e54e016..94df6c64
--- a/src/components/Widgets/CveVulnerabilities.vue
+++ b/src/components/Widgets/CveVulnerabilities.vue
@@@ -33,75 -30,80 +33,82 @@@ export default
data() {
return {
cveList: null,
+ total: 10,
};
},
- filters: {
- formatDate(date) {
- return timestampToDate(date);
- },
- formatDescription(description) {
- return truncateStr(description, 350);
- },
- },
computed: {
- /* Get sort order, defaults to publish date */
- sortBy() {
- const usersChoice = this.options.sortBy;
- let sortCode;
- switch (usersChoice) {
- case ('publish-date'): sortCode = 1; break;
- case ('last-update'): sortCode = 2; break;
- case ('cve-code'): sortCode = 3; break;
- default: sortCode = 1;
- }
- return `&orderby=${sortCode}`;
- },
- /* The minimum CVE score to fetch/ show, defaults to 4 */
- minScore() {
- const usersChoice = this.options.minScore;
- let minScoreVal = 4;
- if (usersChoice && (usersChoice >= 0 || usersChoice <= 10)) {
- minScoreVal = usersChoice;
- }
- return `&cvssscoremin=${minScoreVal}`;
- },
- vendorId() {
- return (this.options.vendorId) ? `&vendor_id=${this.options.vendorId}` : '';
- },
- productId() {
- return (this.options.productId) ? `&product_id=${this.options.productId}` : '';
- },
- /* Should only show results with exploits, defaults to false */
- hasExploit() {
- const shouldShow = this.options.hasExploit ? 1 : 0;
- return `&hasexp=${shouldShow}`;
- },
- /* The number of results to fetch/ show, defaults to 10 */
- limit() {
- const usersChoice = this.options.limit;
- let numResults = 10;
- if (usersChoice && (usersChoice >= 5 || usersChoice <= 30)) {
- numResults = usersChoice;
- }
- return `&numrows=${numResults}`;
+ endpointTotal() {
+ let apiUrl = `${widgetApiEndpoints.cveVulnerabilities}?resultsPerPage=1&startIndex=1&noRejected`;
+ apiUrl = this.appendQuery(apiUrl, this.options, 'cveTag', 'cveTag');
+ apiUrl = this.appendQuery(apiUrl, this.options, 'cvssV2Severity', 'cvssV2Severity');
+ apiUrl = this.appendQuery(apiUrl, this.options, 'cvssV3Severity', 'cvssV3Severity');
+ apiUrl = this.appendQuery(apiUrl, this.options, 'cvssV4Severity', 'cvssV4Severity');
+ apiUrl = this.appendQuery(apiUrl, this.options, 'keywordSearch', 'keywordSearch');
+ apiUrl = this.appendQuery(apiUrl, this.options, 'sourceIdentifier', 'sourceIdentifier');
+
+ return apiUrl;
},
- endpoint() {
- return `${widgetApiEndpoints.cveVulnerabilities}?${this.sortBy}${this.limit}`
- + `${this.minScore}${this.vendorId}${this.productId}${this.hasExploit}`;
+ endpointPage() {
+ const page = Math.max(this.total - (this.options.limit ?? 5), 1);
+ let apiUrl = `${widgetApiEndpoints.cveVulnerabilities}`
+ + `?resultsPerPage=${(this.options.limit ?? 5)}`
+ + `&startIndex=${page}`
+ + '&noRejected';
+
+ apiUrl = this.appendQuery(apiUrl, this.options, 'cveTag', 'cveTag');
+ apiUrl = this.appendQuery(apiUrl, this.options, 'cvssV2Severity', 'cvssV2Severity');
+ apiUrl = this.appendQuery(apiUrl, this.options, 'cvssV3Severity', 'cvssV3Severity');
+ apiUrl = this.appendQuery(apiUrl, this.options, 'cvssV4Severity', 'cvssV4Severity');
+ apiUrl = this.appendQuery(apiUrl, this.options, 'keywordSearch', 'keywordSearch');
+ apiUrl = this.appendQuery(apiUrl, this.options, 'sourceIdentifier', 'sourceIdentifier');
+
+ return apiUrl;
},
proxyReqEndpoint() {
- const baseUrl = process.env.VUE_APP_DOMAIN || window.location.origin;
+ const baseUrl = import.meta.env.VITE_APP_DOMAIN || window.location.origin;
return `${baseUrl}${serviceEndpoints.corsProxy}`;
},
},
methods: {
+ formatDate(date) {
+ return timestampToDate(date);
+ },
+ formatDescription(description) {
+ return truncateStr(description, 350);
+ },
+ formatExploitCount(numExploits) {
+ if (!numExploits) return 'Number of exploits not known';
+ if (numExploits === '0') return 'No published exploits';
+ return `${numExploits} known exploit${numExploits !== '1' ? 's' : ''}`;
+ },
- /* Make GET request to CoinGecko API endpoint */
+ appendQuery(url = '', opts = {}, property = '', paramUrl = '') {
+ const allowedKeys = [
+ 'cveTag',
+ 'cvssV2Severity',
+ 'cvssV3Severity',
+ 'cvssV4Severity',
+ 'keywordSearch',
+ 'sourceIdentifier',
+ ];
+
+ if (allowedKeys.includes(property)) {
+ // eslint-disable-next-line no-prototype-builtins
+ if (opts.hasOwnProperty(property)) {
+ return `${url}&${paramUrl}=${opts[property]}`;
+ }
+ }
+
+ return url;
+ },
-
+ /* Make GET request to NIST NVD API endpoint */
fetchData() {
this.defaultTimeout = 12000;
- this.makeRequest(this.endpoint).then(this.processData);
+ this.makeRequest(this.endpointTotal)
+ .then(sample => {
+ this.total = sample.totalResults;
+ this.makeRequest(this.endpointPage)
+ .then(this.processData);
+ });
},
/* Assign data variables to the returned data */
processData(data) {