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