From a2404e02454bc43c113a038cdbf6bf52cffac289 Mon Sep 17 00:00:00 2001 From: Keith Zantow Date: Mon, 31 Oct 2022 15:02:59 -0400 Subject: [PATCH] fix: file input not being passed properly to syft invocation Signed-off-by: Keith Zantow --- dist/attachReleaseAssets/index.js | 1 + dist/downloadSyft/index.js | 1 + dist/runSyftAction/index.js | 1 + src/github/SyftGithubAction.ts | 1 + tests/SyftGithubAction.test.ts | 48 +++++++++++++++++++++++++++++++ 5 files changed, 52 insertions(+) diff --git a/dist/attachReleaseAssets/index.js b/dist/attachReleaseAssets/index.js index 206f92e2..01fe839a 100644 --- a/dist/attachReleaseAssets/index.js +++ b/dist/attachReleaseAssets/index.js @@ -24208,6 +24208,7 @@ function runSyftAction() { const output = yield executeSyft({ input: { path: core.getInput("path"), + file: core.getInput("file"), image: core.getInput("image"), }, format: getSbomFormat(), diff --git a/dist/downloadSyft/index.js b/dist/downloadSyft/index.js index 93ec8b0b..f322a5cb 100644 --- a/dist/downloadSyft/index.js +++ b/dist/downloadSyft/index.js @@ -24256,6 +24256,7 @@ function runSyftAction() { const output = yield executeSyft({ input: { path: core.getInput("path"), + file: core.getInput("file"), image: core.getInput("image"), }, format: getSbomFormat(), diff --git a/dist/runSyftAction/index.js b/dist/runSyftAction/index.js index 84893e66..ad7d90ab 100644 --- a/dist/runSyftAction/index.js +++ b/dist/runSyftAction/index.js @@ -24208,6 +24208,7 @@ function runSyftAction() { const output = yield executeSyft({ input: { path: core.getInput("path"), + file: core.getInput("file"), image: core.getInput("image"), }, format: getSbomFormat(), diff --git a/src/github/SyftGithubAction.ts b/src/github/SyftGithubAction.ts index 384ff6d2..f76f49d0 100644 --- a/src/github/SyftGithubAction.ts +++ b/src/github/SyftGithubAction.ts @@ -339,6 +339,7 @@ export async function runSyftAction(): Promise { const output = await executeSyft({ input: { path: core.getInput("path"), + file: core.getInput("file"), image: core.getInput("image"), }, format: getSbomFormat(), diff --git a/tests/SyftGithubAction.test.ts b/tests/SyftGithubAction.test.ts index 5c6ca700..e12b4e37 100644 --- a/tests/SyftGithubAction.test.ts +++ b/tests/SyftGithubAction.test.ts @@ -53,6 +53,54 @@ describe("Action", () => { expect(assets.length).toBe(0); }); + it("runs with image input", async () => { + setData({ + inputs: { + image: "some-image:latest", + }, + }); + + await action.runSyftAction(); + + const { args } = data.execArgs; + + expect(args).toBeDefined() + expect(args.length > 2).toBeTruthy(); + expect(args[2]).toBe("some-image:latest") + }); + + it("runs with path input", async () => { + setData({ + inputs: { + path: "some-path", + }, + }); + + await action.runSyftAction(); + + const { args } = data.execArgs; + + expect(args).toBeDefined() + expect(args.length > 2).toBeTruthy(); + expect(args[2]).toBe("dir:some-path") + }); + + it("runs with file input", async () => { + setData({ + inputs: { + file: "some-file.jar", + }, + }); + + await action.runSyftAction(); + + const { args } = data.execArgs; + + expect(args).toBeDefined() + expect(args.length > 2).toBeTruthy(); + expect(args[2]).toBe("file:some-file.jar") + }); + it("runs with release uploads inputs", async () => { const outputFile = `${fs.mkdtempSync( path.join(os.tmpdir(), "sbom-action-")