Skip to content

Commit 550b6f2

Browse files
committed
Pass detectorCategories
As we want to use for specific ecosystems.
1 parent 07208f2 commit 550b6f2

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

action.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
description: "GitHub Personal Access Token (PAT). Defaults to PAT provided by Actions runner."
66
required: false
77
default: ${{ github.token }}
8-
filePath:
8+
filePath:
99
description: 'The path to the directory containing the environment files to upload. Defaults to Actions working directory.'
1010
required: false
1111
default: '.'
@@ -18,12 +18,14 @@ inputs:
1818
dockerImagesToScan:
1919
description: 'Comma separated list of docker image names or hashes to execute container scanning on, ex: ubuntu:16.04,56bab49eef2ef07505f6a1b0d5bd3a601dfc3c76ad4460f24c91d6fa298369ab'
2020
required: false
21-
detectorsFilter:
21+
detectorsFilter:
2222
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.'
2323
required: false
24+
detectorsCategories:
25+
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.'
26+
required: false
2427
correlator:
2528
description: 'An optional identifier to distinguish between multiple dependency snapshots of the same type.'
26-
type: string
2729
required: false
2830
runs:
2931
using: 'node20'

componentDetection.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default class ComponentDetection {
2222
public static componentDetectionPath = process.platform === "win32" ? './component-detection.exe' : './component-detection';
2323
public static outputPath = './output.json';
2424

25-
// This is the default entry point for this class.
25+
// This is the default entry point for this class.
2626
static async scanAndGetManifests(path: string): Promise<Manifest[] | undefined> {
2727
await this.downloadLatestRelease();
2828
await this.runComponentDetection(path);
@@ -61,6 +61,7 @@ export default class ComponentDetection {
6161
parameters += (core.getInput('directoryExclusionList')) ? ` --DirectoryExclusionList ${core.getInput('directoryExclusionList')}` : "";
6262
parameters += (core.getInput('detectorArgs')) ? ` --DetectorArgs ${core.getInput('detectorArgs')}` : "";
6363
parameters += (core.getInput('detectorsFilter')) ? ` --DetectorsFilter ${core.getInput('detectorsFilter')}` : "";
64+
parameters += (core.getInput('detectorsCategories')) ? ` --DetectorCategories ${core.getInput('detectorsCategories')}` : "";
6465
parameters += (core.getInput('dockerImagesToScan')) ? ` --DockerImagesToScan ${core.getInput('dockerImagesToScan')}` : "";
6566
return parameters;
6667
}
@@ -86,7 +87,7 @@ export default class ComponentDetection {
8687
}
8788

8889
const packageUrl = ComponentDetection.makePackageUrl(component.component.packageUrl);
89-
90+
9091
// Skip if the packageUrl is empty (indicates an invalid or missing packageUrl)
9192
if (!packageUrl) {
9293
core.debug(`Skipping component with invalid packageUrl: ${component.component.id}`);
@@ -110,15 +111,15 @@ export default class ComponentDetection {
110111
core.debug(`Skipping referrer without packageUrl for component: ${pkg.id}`);
111112
return;
112113
}
113-
114+
114115
const referrerUrl = ComponentDetection.makePackageUrl(referrer.packageUrl);
115-
116+
116117
// Skip if the generated packageUrl is empty
117118
if (!referrerUrl) {
118119
core.debug(`Skipping referrer with invalid packageUrl for component: ${pkg.id}`);
119120
return;
120121
}
121-
122+
122123
try {
123124
const referrerPackage = packageCache.lookupPackage(referrerUrl);
124125
if (referrerPackage) {
@@ -195,10 +196,10 @@ export default class ComponentDetection {
195196
private static async getLatestReleaseURL(): Promise<string> {
196197
let githubToken = core.getInput('token') || process.env.GITHUB_TOKEN || "";
197198

198-
const githubAPIURL = 'https://api.github.com'
199+
const githubAPIURL = 'https://api.github.com'
199200

200201
let ghesMode = github.context.apiUrl != githubAPIURL;
201-
// If the we're running in GHES, then use an empty string as the token
202+
// If the we're running in GHES, then use an empty string as the token
202203
if (ghesMode) {
203204
githubToken = "";
204205
}
@@ -213,7 +214,7 @@ export default class ComponentDetection {
213214
const repo = "component-detection";
214215
core.debug("Attempting to download latest release from " + githubAPIURL);
215216

216-
try {
217+
try {
217218
const latestRelease = await octokit.request("GET /repos/{owner}/{repo}/releases/latest", {owner, repo});
218219

219220
var downloadURL: string = "";
@@ -229,7 +230,7 @@ export default class ComponentDetection {
229230
core.error(error);
230231
core.debug(error.message);
231232
core.debug(error.stack);
232-
throw new Error("Failed to download latest release");
233+
throw new Error("Failed to download latest release");
233234
}
234235
}
235236
}

0 commit comments

Comments
 (0)