diff --git a/internal/artifacts/sbom.go b/internal/artifacts/sbom.go index 70f7d837..2ae938f7 100644 --- a/internal/artifacts/sbom.go +++ b/internal/artifacts/sbom.go @@ -145,7 +145,8 @@ func cleanEnv(sbomTmpDir string) error { // generateSBomFile - generate all modules sbom and merge in to one, then mv it to sbom target path func generateSBomFile(loc *dir.Loc, mtaObj *mta.MTA, - sbomPath, sbomName, sbomType, sbomSuffix, sbomTmpDir string) error { + sbomPath, sbomName, sbomType, sbomSuffix, sbomTmpDir string, +) error { // (1) generation sbom for modules under sbom tmp dir err := generateSBomFiles(loc, mtaObj, sbomTmpDir, sbomType, sbomSuffix) if err != nil { @@ -457,6 +458,7 @@ func generateSBomFiles(loc *dir.Loc, mtaObj *mta.MTA, sBomFileTmpDir string, sbo } // if sbomGenCmds is empty, module builder maybe "custom" or unknow builder, skip the module and continue if len(sbomGenCmds) == 0 { + // ToDo: consider breaking the build in case no command is available logs.Logger.Infof(genSBomSkipModuleMsg, moduleName) continue } diff --git a/internal/commands/commands.go b/internal/commands/commands.go index bccbab3b..034bb3bc 100644 --- a/internal/commands/commands.go +++ b/internal/commands/commands.go @@ -330,7 +330,8 @@ func moduleCmd(mta *mta.MTA, moduleName string) (*mta.Module, []string, string, // GetModuleSBomGenCommands - get sbom generate command for module // if unknow sbom gen builder or custom builder, empty [][]string and nil error will be return func GetModuleSBomGenCommands(loc *dir.Loc, module *mta.Module, - sbomFileName string, sbomFileType string, sbomFileSuffix string) ([][]string, error) { + sbomFileName string, sbomFileType string, sbomFileSuffix string, +) ([][]string, error) { var cmd string var cmds []string var commandList [][]string @@ -358,6 +359,7 @@ func GetModuleSBomGenCommands(loc *dir.Loc, module *mta.Module, "-DincludeRuntimeScope=true -DincludeSystemScope=true -DincludeTestScope=false -DincludeLicenseText=false " + "-DoutputFormat=" + sbomFileType + " -DoutputName=" + sbomFileName + ".bom" cmds = append(cmds, cmd) + // allow custom creation of an SBOM for e.g. a custom builder case "custom": // first check if custom SBOM creation commands are provided customSbomGenCmds, ok := module.BuildParams["sbom-create-commands"].([]string) @@ -398,7 +400,8 @@ func GetModuleSBomGenCommands(loc *dir.Loc, module *mta.Module, // GetSBomsMergeCommand - generate merge sbom file command under sbom tmp dir // if empty sbomFileNames, return empty commandList, nil error func GetSBomsMergeCommand(loc *dir.Loc, cyclonedx_cli string, mtaObj *mta.MTA, sbomTmpDir string, sbomFileNames []string, - sbomName, sbomType, sbomSuffix string) ([][]string, error) { + sbomName, sbomType, sbomSuffix string, +) ([][]string, error) { var cmd string var cmds []string var commandList [][]string