Skip to content
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
4 changes: 3 additions & 1 deletion internal/artifacts/sbom.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
7 changes: 5 additions & 2 deletions internal/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down