@@ -196,11 +196,13 @@ def create_bom(bom_file, src_dir=".", options=None):
196
196
# For binaries, generate an sbom with blint directly
197
197
techniques = options .get ("techniques" ) or []
198
198
lifecycles = options .get ("lifecycles" ) or []
199
+ project_type = options .get ("project_type" ) or []
199
200
bom_engine = options .get ("bom_engine" , "" )
200
201
# Detect if blint needs to be used for the given project type, technique, and lifecycle.
201
202
if bom_engine == "BlintGenerator" or "binary-analysis" in techniques or "post-build" in lifecycles :
202
203
return create_blint_bom (bom_file , src_dir , options = options )
203
204
cdxgen_server = options .get ("cdxgen_server" )
205
+ cdxgen_lib = CdxgenGenerator
204
206
# Generate SBOM by calling cdxgen server
205
207
if cdxgen_server or bom_engine == "CdxgenServerGenerator" :
206
208
if not cdxgen_server :
@@ -210,9 +212,15 @@ def create_bom(bom_file, src_dir=".", options=None):
210
212
cdxgen_lib = CdxgenServerGenerator
211
213
else :
212
214
# Prefer the new image based generators if docker command is available in auto mode
213
- cdxgen_lib = CdxgenImageBasedGenerator if bom_engine == "CdxgenImageBasedGenerator" or (
214
- bom_engine == "auto" and shutil .which (os .getenv ("DOCKER_CMD" , "docker" ))) else CdxgenGenerator
215
- with console .status (f"Generating BOM for the directory { src_dir } with cdxgen." , spinner = SPINNER ):
215
+ if bom_engine == "CdxgenImageBasedGenerator" :
216
+ cdxgen_lib = CdxgenImageBasedGenerator
217
+ elif bom_engine == "auto" :
218
+ # Prefer local CLI while scanning container images
219
+ if any ([t in ("docker" , "podman" , "oci" ) for t in project_type ]):
220
+ cdxgen_lib = CdxgenGenerator
221
+ elif shutil .which (os .getenv ("DOCKER_CMD" , "docker" )):
222
+ cdxgen_lib = CdxgenImageBasedGenerator
223
+ with console .status (f"Generating BOM for the source { src_dir } with cdxgen." , spinner = SPINNER ):
216
224
bom_result = cdxgen_lib (src_dir , bom_file , logger = LOG , options = options ).generate ()
217
225
if not bom_result .success :
218
226
LOG .info ("The cdxgen invocation was unsuccessful. Try generating the BOM separately." )
@@ -232,7 +240,7 @@ def create_blint_bom(bom_file, src_dir=".", options=None):
232
240
if options is None :
233
241
options = {}
234
242
blint_lib = BlintGenerator (src_dir , bom_file , logger = LOG , options = options )
235
- with console .status (f"Generating BOM for the directory { src_dir } with blint." , spinner = SPINNER ):
243
+ with console .status (f"Generating BOM for the source { src_dir } with blint." , spinner = SPINNER ):
236
244
bom_result = blint_lib .generate ()
237
245
if not bom_result .success :
238
246
LOG .info ("The blint invocation was unsuccessful. Try generating the BOM separately." )
0 commit comments