Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config input #430

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ and uploading them as workflow artifacts and release assets.
| `upload-release-assets` | Upload release assets | `true` |
| `syft-version` | The version of Syft to use | |
| `github-token` | Authorized secret GitHub Personal Access Token. | `github.token` |
| `config ` | Syft configuration file to use. | |

### anchore/sbom-action/publish-sbom

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ inputs:
description: "Upload release assets"
default: "true"

config:
required: false
description: "Configuration file to use"

runs:
using: "node16"
main: "dist/runSyftAction/index.js"
4 changes: 4 additions & 0 deletions dist/attachReleaseAssets/index.js

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

4 changes: 4 additions & 0 deletions dist/downloadSyft/index.js

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

4 changes: 4 additions & 0 deletions dist/runSyftAction/index.js

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

1 change: 1 addition & 0 deletions src/Syft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ export interface SyftOptions {
| "text"
| "json";
uploadToDependencySnapshotAPI: boolean;
configFile: string;
}
5 changes: 5 additions & 0 deletions src/github/SyftGithubAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ async function executeSyft({
args = [...args, "-o", `github=${githubDependencySnapshotFile}`];
}

if (opts.configFile) {
args = [...args, "-c", opts.configFile];
}

// Execute in a group so the syft output is collapsed in the GitHub log
core.info(`[command]${cmd} ${args.join(" ")}`);

Expand Down Expand Up @@ -367,6 +371,7 @@ export async function runSyftAction(): Promise<void> {
},
format: getSbomFormat(),
uploadToDependencySnapshotAPI: uploadToSnapshotAPI(),
configFile: core.getInput("config"),
});

core.info(`SBOM scan completed in: ${(Date.now() - start) / 1000}s`);
Expand Down
15 changes: 15 additions & 0 deletions tests/SyftGithubAction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,19 @@ describe("Action", () => {
expect(mapToWSLPath("D:\\Some\\Path")).toBe("/mnt/d/Some/Path");
expect(mapToWSLPath("C:\\Some\\Path")).toBe("/mnt/c/Some/Path");
});

it("calls with config", async () => {
setData({
inputs: {
image: "some-image:latest",
config: "syft-config.yaml",
}
});

await action.runSyftAction();
const { cmd, args, env } = data.execArgs;

expect(args).toContain("-c");
expect(args).toContain("syft-config.yaml");
});
});