From eb58fb681f5a1d0d29b28bab85853bb7545937df Mon Sep 17 00:00:00 2001 From: Zachary Keeping Date: Wed, 29 Nov 2023 17:26:33 +1100 Subject: [PATCH 1/3] Fix whitelisted URLs count and update ignore URL binding --- api/functions/index.js | 2 +- docker/utils.js | 12 +++++------- .../components/misccomponents/UpdateIgnoreUrl.svelte | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/api/functions/index.js b/api/functions/index.js index e1be6ca8..b63cb770 100644 --- a/api/functions/index.js +++ b/api/functions/index.js @@ -279,7 +279,7 @@ app.post('/scanresult/:api/:buildId', async (req, res) => { ...lhrSummary, ...atrSummary, totalScanned, - whiteListed, + totalWhitelisted: whiteListed.length, scanDuration, url, cloc, diff --git a/docker/utils.js b/docker/utils.js index 4e290d61..a62cfdc2 100644 --- a/docker/utils.js +++ b/docker/utils.js @@ -436,23 +436,21 @@ exports.processBrokenLinks = ( whitelistedUrls .filter( (ig) => - ig.ignoreOn === ignoreOn && + (ig.ignoreOn === "all" || ig.ignoreOn === ignoreOn) && (+ig.ignoreDuration === -1 || diffInDaysToNow(new Date(ig.effectiveFrom)) < +ig.ignoreDuration) ) .map((ig) => ig.urlToIgnore) - .filter((ignorePattern) => minimatch(url, ignorePattern)).length > 0 + .filter((ignorePattern) => + minimatch(url.src, ignorePattern) || minimatch(url.dst, ignorePattern) + ).length > 0 ); }; // return the URL only const all = badUrls - .filter( - (url) => - isInIgnoredList(url.dst, "all", whitelistedUrls) || - isInIgnoredList(url.dst, startUrl, whitelistedUrls) - ) + .filter((url) => isInIgnoredList(url, startUrl)) .map((x) => x.dst); return [...new Set(all)]; }; diff --git a/ui/src/components/misccomponents/UpdateIgnoreUrl.svelte b/ui/src/components/misccomponents/UpdateIgnoreUrl.svelte index 35250aba..b75a735e 100644 --- a/ui/src/components/misccomponents/UpdateIgnoreUrl.svelte +++ b/ui/src/components/misccomponents/UpdateIgnoreUrl.svelte @@ -152,7 +152,7 @@ class="hidden" id="radio2" bind:group={ignoreOn} - value={url} + value={scanUrl} disabled={editing} />