@@ -11,6 +11,7 @@ import (
11
11
"net/http"
12
12
"os"
13
13
"path/filepath"
14
+ "slices"
14
15
"strconv"
15
16
"strings"
16
17
"syscall"
@@ -171,6 +172,13 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
171
172
UnsetEnvs []string `schema:"unsetenv"`
172
173
UnsetLabels []string `schema:"unsetlabel"`
173
174
Volumes []string `schema:"volume"`
175
+ SBOMOutput string `schema:"sbom-output"`
176
+ SBOMPURLOutput string `schema:"sbom-purl-output"`
177
+ ImageSBOMOutput string `schema:"sbom-image-output"`
178
+ ImageSBOMPURLOutput string `schema:"sbom-image-purl-output"`
179
+ ImageSBOM string `schema:"sbom-scanner-image"`
180
+ SBOMCommands string `schema:"sbom-scanner-command"`
181
+ SBOMMergeStrategy string `schema:"sbom-merge-strategy"`
174
182
}{
175
183
Dockerfile : "Dockerfile" ,
176
184
IdentityLabel : true ,
@@ -693,6 +701,46 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
693
701
}
694
702
}
695
703
704
+ var sbomScanOptions []buildahDefine.SBOMScanOptions
705
+ if query .ImageSBOM != "" ||
706
+ query .SBOMOutput != "" ||
707
+ query .ImageSBOMOutput != "" ||
708
+ query .SBOMPURLOutput != "" ||
709
+ query .ImageSBOMPURLOutput != "" ||
710
+ len (query .SBOMCommands ) > 0 ||
711
+ query .SBOMMergeStrategy != "" {
712
+ sbomScanOption := & buildahDefine.SBOMScanOptions {
713
+ SBOMOutput : query .SBOMOutput ,
714
+ PURLOutput : query .SBOMPURLOutput ,
715
+ ImageSBOMOutput : query .ImageSBOMOutput ,
716
+ ImagePURLOutput : query .ImageSBOMPURLOutput ,
717
+ Image : query .ImageSBOM ,
718
+ MergeStrategy : buildahDefine .SBOMMergeStrategy (query .SBOMMergeStrategy ),
719
+ PullPolicy : pullPolicy ,
720
+ }
721
+
722
+ if _ , found := r .URL .Query ()["sbom-scanner-command" ]; found {
723
+ var m = []string {}
724
+ if err := json .Unmarshal ([]byte (query .SBOMCommands ), & m ); err != nil {
725
+ utils .BadRequest (w , "sbom-scanner-command" , query .SBOMCommands , err )
726
+ return
727
+ }
728
+ sbomScanOption .Commands = m
729
+ }
730
+
731
+ if ! slices .Contains (sbomScanOption .ContextDir , contextDirectory ) {
732
+ sbomScanOption .ContextDir = append (sbomScanOption .ContextDir , contextDirectory )
733
+ }
734
+
735
+ for _ , abc := range additionalBuildContexts {
736
+ if ! abc .IsURL && ! abc .IsImage {
737
+ sbomScanOption .ContextDir = append (sbomScanOption .ContextDir , abc .Value )
738
+ }
739
+ }
740
+
741
+ sbomScanOptions = append (sbomScanOptions , * sbomScanOption )
742
+ }
743
+
696
744
buildOptions := buildahDefine.BuildOptions {
697
745
AddCapabilities : addCaps ,
698
746
AdditionalBuildContexts : additionalBuildContexts ,
@@ -772,6 +820,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
772
820
Target : query .Target ,
773
821
UnsetEnvs : query .UnsetEnvs ,
774
822
UnsetLabels : query .UnsetLabels ,
823
+ SBOMScanOptions : sbomScanOptions ,
775
824
}
776
825
777
826
platforms := query .Platform
0 commit comments