From c5740eb2599ab6ceec0dd141f3ca864bee71e716 Mon Sep 17 00:00:00 2001 From: Lewis Jones Date: Thu, 12 Jun 2025 11:46:07 +0100 Subject: [PATCH] Pass detectorCategories As we want to use for specific ecosystems. --- action.yml | 8 +++++--- componentDetection.ts | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/action.yml b/action.yml index edba751..ce36389 100644 --- a/action.yml +++ b/action.yml @@ -5,7 +5,7 @@ inputs: description: "GitHub Personal Access Token (PAT). Defaults to PAT provided by Actions runner." required: false default: ${{ github.token }} - filePath: + filePath: description: 'The path to the directory containing the environment files to upload. Defaults to Actions working directory.' required: false default: '.' @@ -18,12 +18,14 @@ inputs: dockerImagesToScan: description: 'Comma separated list of docker image names or hashes to execute container scanning on, ex: ubuntu:16.04,56bab49eef2ef07505f6a1b0d5bd3a601dfc3c76ad4460f24c91d6fa298369ab' required: false - detectorsFilter: + detectorsFilter: description: 'A comma separated list with the identifiers of the specific detectors to be used. This is meant to be used for testing purposes only.' required: false + detectorsCategories: + description: 'A comma separated list with the categories of components that are going to be scanned. The detectors that are going to run are the ones that belongs to the categories. The possible values are: Npm, NuGet, Maven, RubyGems, Cargo, Pip, GoMod, CocoaPods, Linux.' + required: false correlator: description: 'An optional identifier to distinguish between multiple dependency snapshots of the same type.' - type: string required: false runs: using: 'node20' diff --git a/componentDetection.ts b/componentDetection.ts index cdc8349..7652f70 100644 --- a/componentDetection.ts +++ b/componentDetection.ts @@ -22,7 +22,7 @@ export default class ComponentDetection { public static componentDetectionPath = process.platform === "win32" ? './component-detection.exe' : './component-detection'; public static outputPath = './output.json'; - // This is the default entry point for this class. + // This is the default entry point for this class. static async scanAndGetManifests(path: string): Promise { await this.downloadLatestRelease(); await this.runComponentDetection(path); @@ -61,6 +61,7 @@ export default class ComponentDetection { parameters += (core.getInput('directoryExclusionList')) ? ` --DirectoryExclusionList ${core.getInput('directoryExclusionList')}` : ""; parameters += (core.getInput('detectorArgs')) ? ` --DetectorArgs ${core.getInput('detectorArgs')}` : ""; parameters += (core.getInput('detectorsFilter')) ? ` --DetectorsFilter ${core.getInput('detectorsFilter')}` : ""; + parameters += (core.getInput('detectorsCategories')) ? ` --DetectorCategories ${core.getInput('detectorsCategories')}` : ""; parameters += (core.getInput('dockerImagesToScan')) ? ` --DockerImagesToScan ${core.getInput('dockerImagesToScan')}` : ""; return parameters; } @@ -86,7 +87,7 @@ export default class ComponentDetection { } const packageUrl = ComponentDetection.makePackageUrl(component.component.packageUrl); - + // Skip if the packageUrl is empty (indicates an invalid or missing packageUrl) if (!packageUrl) { core.debug(`Skipping component with invalid packageUrl: ${component.component.id}`); @@ -110,15 +111,15 @@ export default class ComponentDetection { core.debug(`Skipping referrer without packageUrl for component: ${pkg.id}`); return; } - + const referrerUrl = ComponentDetection.makePackageUrl(referrer.packageUrl); - + // Skip if the generated packageUrl is empty if (!referrerUrl) { core.debug(`Skipping referrer with invalid packageUrl for component: ${pkg.id}`); return; } - + try { const referrerPackage = packageCache.lookupPackage(referrerUrl); if (referrerPackage) { @@ -195,10 +196,10 @@ export default class ComponentDetection { private static async getLatestReleaseURL(): Promise { let githubToken = core.getInput('token') || process.env.GITHUB_TOKEN || ""; - const githubAPIURL = 'https://api.github.com' + const githubAPIURL = 'https://api.github.com' let ghesMode = github.context.apiUrl != githubAPIURL; - // If the we're running in GHES, then use an empty string as the token + // If the we're running in GHES, then use an empty string as the token if (ghesMode) { githubToken = ""; } @@ -213,7 +214,7 @@ export default class ComponentDetection { const repo = "component-detection"; core.debug("Attempting to download latest release from " + githubAPIURL); - try { + try { const latestRelease = await octokit.request("GET /repos/{owner}/{repo}/releases/latest", {owner, repo}); var downloadURL: string = ""; @@ -229,7 +230,7 @@ export default class ComponentDetection { core.error(error); core.debug(error.message); core.debug(error.stack); - throw new Error("Failed to download latest release"); + throw new Error("Failed to download latest release"); } } }