@@ -167,6 +167,8 @@ def main_code():
167167
168168 # Variable to track if we need to override files with facts file
169169 facts_file_to_submit = None
170+ # Variable to track SBOM files to submit when using --reach-use-only-pregenerated-sboms
171+ sbom_files_to_submit = None
170172
171173 # Git setup
172174 is_repo = False
@@ -230,12 +232,14 @@ def main_code():
230232 # Run reachability analysis if enabled
231233 if config .reach :
232234 from socketsecurity .core .tools .reachability import ReachabilityAnalyzer
233-
235+
234236 log .info ("Starting reachability analysis..." )
235-
237+
236238 # Find manifest files in scan paths (excluding .socket.facts.json to avoid circular dependency)
237239 log .info ("Finding manifest files for reachability analysis..." )
238240 manifest_files = []
241+
242+ # Always find all manifest files for the tar hash upload
239243 for scan_path in scan_paths :
240244 scan_manifests = core .find_files (scan_path )
241245 # Filter out .socket.facts.json files from manifest upload
@@ -289,7 +293,8 @@ def main_code():
289293 concurrency = config .reach_concurrency ,
290294 additional_params = config .reach_additional_params ,
291295 allow_unverified = config .allow_unverified ,
292- enable_debug = config .enable_debug
296+ enable_debug = config .enable_debug ,
297+ use_only_pregenerated_sboms = config .reach_use_only_pregenerated_sboms
293298 )
294299
295300 log .info (f"Reachability analysis completed successfully" )
@@ -301,6 +306,17 @@ def main_code():
301306 if config .only_facts_file :
302307 facts_file_to_submit = os .path .abspath (output_path )
303308 log .info (f"Only-facts-file mode: will submit only { facts_file_to_submit } " )
309+
310+ # If reach-use-only-pregenerated-sboms mode, submit CDX, SPDX, and facts file
311+ if config .reach_use_only_pregenerated_sboms :
312+ # Find only CDX and SPDX files for the final scan submission
313+ sbom_files_to_submit = []
314+ for scan_path in scan_paths :
315+ sbom_files_to_submit .extend (core .find_sbom_files (scan_path ))
316+ # Use relative path for facts file
317+ if os .path .exists (output_path ):
318+ sbom_files_to_submit .append (output_path )
319+ log .info (f"Pre-generated SBOMs mode: will submit { len (sbom_files_to_submit )} files (CDX, SPDX, and facts file)" )
304320
305321 except Exception as e :
306322 log .error (f"Reachability analysis failed: { str (e )} " )
@@ -331,6 +347,12 @@ def main_code():
331347 files_explicitly_specified = True
332348 log .debug (f"Overriding files to only submit facts file: { facts_file_to_submit } " )
333349
350+ # Override files if reach-use-only-pregenerated-sboms mode is active
351+ if sbom_files_to_submit :
352+ specified_files = sbom_files_to_submit
353+ files_explicitly_specified = True
354+ log .debug (f"Overriding files to submit only SBOM files (CDX, SPDX, and facts): { sbom_files_to_submit } " )
355+
334356 # Determine files to check based on the new logic
335357 files_to_check = []
336358 force_api_mode = False
@@ -452,7 +474,7 @@ def main_code():
452474 log .info ("Push initiated flow" )
453475 if scm .check_event_type () == "diff" :
454476 log .info ("Starting comment logic for PR/MR event" )
455- diff = core .create_new_diff (scan_paths , params , no_change = should_skip_scan , save_files_list_path = config .save_submitted_files_list , save_manifest_tar_path = config .save_manifest_tar , base_paths = base_paths )
477+ diff = core .create_new_diff (scan_paths , params , no_change = should_skip_scan , save_files_list_path = config .save_submitted_files_list , save_manifest_tar_path = config .save_manifest_tar , base_paths = base_paths , explicit_files = sbom_files_to_submit )
456478 comments = scm .get_comments_for_pr ()
457479 log .debug ("Removing comment alerts" )
458480
@@ -505,14 +527,14 @@ def main_code():
505527 )
506528 else :
507529 log .info ("Starting non-PR/MR flow" )
508- diff = core .create_new_diff (scan_paths , params , no_change = should_skip_scan , save_files_list_path = config .save_submitted_files_list , save_manifest_tar_path = config .save_manifest_tar , base_paths = base_paths )
530+ diff = core .create_new_diff (scan_paths , params , no_change = should_skip_scan , save_files_list_path = config .save_submitted_files_list , save_manifest_tar_path = config .save_manifest_tar , base_paths = base_paths , explicit_files = sbom_files_to_submit )
509531
510532 output_handler .handle_output (diff )
511-
533+
512534 elif config .enable_diff and not force_api_mode :
513535 # New logic: --enable-diff forces diff mode even with --integration api (no SCM)
514536 log .info ("Diff mode enabled without SCM integration" )
515- diff = core .create_new_diff (scan_paths , params , no_change = should_skip_scan , save_files_list_path = config .save_submitted_files_list , save_manifest_tar_path = config .save_manifest_tar , base_paths = base_paths )
537+ diff = core .create_new_diff (scan_paths , params , no_change = should_skip_scan , save_files_list_path = config .save_submitted_files_list , save_manifest_tar_path = config .save_manifest_tar , base_paths = base_paths , explicit_files = sbom_files_to_submit )
516538 output_handler .handle_output (diff )
517539
518540 elif config .enable_diff and force_api_mode :
@@ -530,12 +552,13 @@ def main_code():
530552 no_change = should_skip_scan ,
531553 save_files_list_path = config .save_submitted_files_list ,
532554 save_manifest_tar_path = config .save_manifest_tar ,
533- base_paths = base_paths
555+ base_paths = base_paths ,
556+ explicit_files = sbom_files_to_submit
534557 )
535558 log .info (f"Full scan created with ID: { diff .id } " )
536559 log .info (f"Full scan report URL: { diff .report_url } " )
537560 output_handler .handle_output (diff )
538-
561+
539562 else :
540563 if force_api_mode :
541564 log .info ("No Manifest files changed, creating Socket Report" )
@@ -550,7 +573,8 @@ def main_code():
550573 no_change = should_skip_scan ,
551574 save_files_list_path = config .save_submitted_files_list ,
552575 save_manifest_tar_path = config .save_manifest_tar ,
553- base_paths = base_paths
576+ base_paths = base_paths ,
577+ explicit_files = sbom_files_to_submit
554578 )
555579 log .info (f"Full scan created with ID: { diff .id } " )
556580 log .info (f"Full scan report URL: { diff .report_url } " )
@@ -561,7 +585,8 @@ def main_code():
561585 no_change = should_skip_scan ,
562586 save_files_list_path = config .save_submitted_files_list ,
563587 save_manifest_tar_path = config .save_manifest_tar ,
564- base_paths = base_paths
588+ base_paths = base_paths ,
589+ explicit_files = sbom_files_to_submit
565590 )
566591 output_handler .handle_output (diff )
567592
0 commit comments