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 ability to specify a custom SBOM generator #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/bashbrew/cmd-build.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func cmdBuild(c *cli.Context) error {
defer archive.Close()

if builder == "buildkit" {
err = dockerBuildxBuild(tags, entry.ArchFile(arch), archive, platform)
err = dockerBuildxBuild(tags, entry.ArchFile(arch), archive, platform, entry.SbomGenerator)
} else {
// TODO use "meta.StageNames" to do "docker build --target" so we can tag intermediate stages too for cache (streaming "git archive" directly to "docker build" makes that a little hard to accomplish without re-streaming)
err = dockerBuild(tags, entry.ArchFile(arch), archive, platform)
Expand Down
7 changes: 5 additions & 2 deletions cmd/bashbrew/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ const (
buildxBuilderEnv = "BUILDX_BUILDER"
)

func dockerBuildxBuild(tags []string, file string, context io.Reader, platform string) error {
func dockerBuildxBuild(tags []string, file string, context io.Reader, platform string, sbomGenerator string) error {
dockerfileSyntax, ok := os.LookupEnv(dockerfileSyntaxEnv)
if !ok {
return fmt.Errorf("missing %q", dockerfileSyntaxEnv)
Expand All @@ -316,7 +316,10 @@ func dockerBuildxBuild(tags []string, file string, context io.Reader, platform s
if buildxBuilder {
args = append(args, "--provenance", "mode=max")
}
if sbomGenerator, ok := os.LookupEnv(sbomGeneratorEnv); ok {
if sbomGenerator == "" {
sbomGenerator, _ = os.LookupEnv(sbomGeneratorEnv)
}
if sbomGenerator != "" {
if buildxBuilder {
args = append(args, "--sbom", "generator="+sbomGenerator)
} else {
Expand Down
13 changes: 7 additions & 6 deletions manifest/rfc2822.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ type Manifest2822Entry struct {

Architectures []string `delim:"," strip:"\n\r\t "`

GitRepo string
GitFetch string
GitCommit string
Directory string
File string
Builder string
GitRepo string
GitFetch string
GitCommit string
Directory string
File string
Builder string
SbomGenerator string

// architecture-specific versions of the above fields
ArchValues map[string]string
Expand Down
Loading