Skip to content

Commit

Permalink
Allow type "file:..."
Browse files Browse the repository at this point in the history
Signed-off-by: Malte Poll <mp@edgeless.systems>
  • Loading branch information
malt3 committed Oct 1, 2022
1 parent 6218d4f commit cdc29e7
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 20 deletions.
2 changes: 1 addition & 1 deletion action.yml
Expand Up @@ -7,7 +7,7 @@ branding:
inputs:
path:
required: false
description: "A path on the filesystem to scan"
description: "A path on the filesystem to scan. Can be a file or directory."
default: "."

image:
Expand Down
13 changes: 11 additions & 2 deletions dist/attachReleaseAssets/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions dist/downloadSyft/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions dist/runSyftAction/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -67,6 +67,6 @@
"pretty-quick": "^3.1.3",
"ts-jest": "^29.0.1",
"type-fest": "^2.19.0",
"typescript": "^4.8.3"
"typescript": "^4.8.4"
}
}
6 changes: 3 additions & 3 deletions src/Syft.ts
@@ -1,7 +1,7 @@
/**
* Used for filesystem directory input to Syft
* Used for filesystem directory/file input to Syft
*/
export interface SyftDirectoryInput {
export interface SyftPathInput {
path: string;
}

Expand All @@ -24,7 +24,7 @@ export interface SyftImageInput {
* Syft invocation options
*/
export interface SyftOptions {
input: SyftDirectoryInput | SyftRegistryInput | SyftImageInput;
input: SyftPathInput | SyftRegistryInput | SyftImageInput;
format:
| "spdx"
| "spdx-tag-value"
Expand Down
18 changes: 16 additions & 2 deletions src/github/SyftGithubAction.ts
Expand Up @@ -133,10 +133,24 @@ async function executeSyft({
} else {
args = [...args, `${input.image}`];
}
} else if ("path" in input && input.path) {
} else if (
"path" in input &&
input.path &&
fs.existsSync(input.path) &&
fs.lstatSync(input.path).isDirectory()
) {
args = [...args, `dir:${input.path}`];
} else if (
"path" in input &&
input.path &&
fs.existsSync(input.path) &&
fs.lstatSync(input.path).isFile()
) {
args = [...args, `file:${input.path}`];
} else {
throw new Error("Invalid input, no image or path specified");
throw new Error(
"Invalid input, no image or path specified or path does not exist"
);
}

args = [...args, "-o", format];
Expand Down

0 comments on commit cdc29e7

Please sign in to comment.