Skip to content

Commit 2429993

Browse files
committed
Add support for additional CLI parameters
1 parent f78092a commit 2429993

File tree

6 files changed

+39
-4
lines changed

6 files changed

+39
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
- uses: actions/checkout@v3
2424
- name: Component detection
2525
uses: jhutchings1/component-detection-action@v0.0.1
26-
```
26+
```

action.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ inputs:
99
description: 'The path to the directory containing the environment files to upload. Defaults to Actions working directory.'
1010
required: false
1111
default: '.'
12+
directoryExclusionList:
13+
description: 'Filters out specific directories following a minimatch pattern.'
14+
required: false
15+
ignoreDirectories:
16+
description: 'Filters out specific directories, providing individual directory paths separated by semicolon. Obsolete in favor of DirectoryExclusionList's glob syntax.'
17+
required: false
18+
detectorArgs:
19+
description: 'Comma separated list of properties that can affect the detectors execution, like EnableIfDefaultOff that allows a specific detector that is in beta to run, the format for this property is DetectorId=EnableIfDefaultOff, for example Pip=EnableIfDefaultOff.'
20+
required: false
21+
dockerImagesToScan:
22+
description: 'Comma separated list of docker image names or hashes to execute container scanning on, ex: ubuntu:16.04,56bab49eef2ef07505f6a1b0d5bd3a601dfc3c76ad4460f24c91d6fa298369ab'
23+
required: false
24+
detectorsFilter:
25+
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.'
26+
required: false
1227
runs:
1328
using: 'node16'
1429
main: 'dist/index.js'

componentDetection.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,22 @@ export default class ComponentDetection {
4949
core.info("Running component-detection");
5050

5151
try {
52-
await exec.exec(`${this.componentDetectionPath} scan --SourceDirectory ${path} --ManifestFile ${this.outputPath}`);
52+
await exec.exec(`${this.componentDetectionPath} scan --SourceDirectory ${path} --ManifestFile ${this.outputPath} ${this.getComponentDetectionParameters()}`);
5353
} catch (error: any) {
5454
core.error(error);
5555
}
5656
}
5757

58+
private static getComponentDetectionParameters(): string {
59+
var parameters = "";
60+
parameters += (core.getInput('directoryExclusionList')) ? ` --DirectoryExclusionList ${core.getInput('directoryExclusionList')}` : "";
61+
parameters += (core.getInput('ignoreDirectories')) ? ` --IgnoreDirectories ${core.getInput('ignoreDirectories')}` : "";
62+
parameters += (core.getInput('detectorArgs')) ? ` --DetectorArgs ${core.getInput('detectorArgs')}` : "";
63+
parameters += (core.getInput('detectorsFilter')) ? ` --DetectorsFilter ${core.getInput('detectorsFilter')}` : "";
64+
parameters += (core.getInput('dockerImagesToScan')) ? ` --DockerImagesToScan ${core.getInput('dockerImagesToScan')}` : "";
65+
return parameters;
66+
}
67+
5868
private static async getManifestsFromResults(): Promise<Manifest[]| undefined> {
5969
core.info("Getting manifests from results");
6070
// Parse the result file and add the packages to the package cache

dist/componentDetection.d.ts

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)