Skip to content

Commit

Permalink
Merge pull request #368 from GSA/lc/1339-third-party-service-url
Browse files Browse the repository at this point in the history
1339: Filter out file load URLs
  • Loading branch information
luke-at-flexion committed Sep 17, 2024
2 parents 63a061a + 2dbe2a4 commit 830fbdd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions libs/core-scanner/src/scans/third-party.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const buildThirdPartyResult = async (
const url = mainResponse && mainResponse.url();
const thirdPartyResult = await thirdPartyServices(logger, outboundRequests, url);
const thirdPartyUrlResult = await thirdPartyServicesUrls(logger, outboundRequests, url);
timer.log({}, 'third-party-scan.timer', `Third-party scan completed in [{metricValue}ms]`);
timer.log({}, 'scanner.page.primary.scan.third-party.duration.total', `Third-party scan completed in [{metricValue}ms]`);
return {
thirdPartyServiceDomains: thirdPartyResult.domains,
thirdPartyServiceCount: thirdPartyResult.count,
Expand All @@ -35,7 +35,7 @@ export function thirdPartyServices ( parentLogger: Logger, outboundRequests: HTT
}
}
const deduped = uniq(thirdPartyDomains).filter(Boolean).sort();
logCount(logger, { thirdPartyServiceCount: deduped.length }, 'third-party-services.id', 'Third-party services count: {metricValue}');
logCount(logger, { thirdPartyServicesCount: deduped.length }, 'scanner.page.primary.scan.third-party.unique_external_domains.count', 'Third-party services count: {metricValue}');
return {
domains: deduped.join(','),
count: deduped.length,
Expand All @@ -57,11 +57,14 @@ export function thirdPartyServicesUrls ( parentLogger: Logger, outboundRequests:
const url = request && new URL(request.url());
if (parsedUrl.hostname != url.hostname && !request.isNavigationRequest()) {
const fullUrl = removeQueryParameters(url.toString());
thirdPartyDomains.push(fullUrl);
const isFileLoad = fullUrl.startsWith('data:') || fullUrl.startsWith('blob:');
if( !isFileLoad) {
thirdPartyDomains.push(fullUrl);
}
}
}
const deduped = uniq(thirdPartyDomains).filter(Boolean).sort();
logCount(logger, { thirdPartyServicesUrls: deduped.length }, 'third-party-services-url.id', 'Third-party services url count: {metricValue}');
logCount(logger, { thirdPartyServicesUrlsCount: deduped.length }, 'scanner.page.primary.scan.third-party.unique_external_urls.count', 'Third-party services url count: {metricValue}');
return deduped.join(',')
};

Expand Down

0 comments on commit 830fbdd

Please sign in to comment.