Skip to content

Commit

Permalink
Merge pull request #759 from SSWConsulting/scan-result-limit
Browse files Browse the repository at this point in the history
Set a scan result limit for Days Unfixed
  • Loading branch information
tombui99 authored Nov 9, 2023
2 parents 89b521f + 1453804 commit 0501766
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions api/functions/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ exports.getConfig = (api) =>
exports.getScanDetails = async (runId) => {
const scan = await exports.getSummaryById(runId);
let filter;
const filterDays = 90;
const startDate = new Date(scan.buildDate);
startDate.setDate(startDate.getDate() - filterDays);

if (scan.scanResultVersion === 2) {
filter = `PartitionKey eq '${scan.apiKey}-${slug(scan.url)}'`;
filter = `PartitionKey eq '${scan.apiKey}-${slug(scan.url)}' and buildDate ge datetime'${startDate.toISOString()}' and buildDate le datetime'${scan.buildDate.toISOString()}'`;
} else {
filter = odata`PartitionKey eq ${scan.partitionKey} and src ge ${scan.url} and src le ${incrementString(scan.url)}`;
filter = odata`PartitionKey eq ${scan.partitionKey} and src ge ${scan.url} and src le ${incrementString(scan.url)} and buildDate ge datetime'${startDate.toISOString()}' and buildDate le datetime'${scan.buildDate.toISOString()}'`;
}

const entity = new TableClient(azureUrl, TABLE.ScanResults, credential).listEntities({
Expand Down Expand Up @@ -256,7 +259,7 @@ exports.getSummaryById = (runId) =>

let summary = await getSummary(`PartitionKey eq '${doc.apikey}-${doc.runId}'`);

if (!summary) {
if (!summary || summary.scanResultVersion !== 2) {
summary = await getSummary(odata`PartitionKey eq ${doc.apikey} and runId eq ${doc.runId}`);
}

Expand Down

0 comments on commit 0501766

Please sign in to comment.