@@ -207,6 +207,8 @@ def main_code():
207207 if dirs_to_include :
208208 core .config .excluded_dirs = set (core .config .excluded_dirs ) - dirs_to_include
209209 log .debug (f"Re-including normally-excluded directories in scan: { sorted (dirs_to_include )} " )
210+ if config .excluded_ecosystems :
211+ core .config .excluded_ecosystems = list (config .excluded_ecosystems )
210212
211213 # Check for required dependencies if reachability analysis is enabled
212214 if config .reach :
@@ -292,6 +294,9 @@ def main_code():
292294 facts_file_to_submit = None
293295 # Variable to track SBOM files to submit when using --reach-use-only-pregenerated-sboms
294296 sbom_files_to_submit = None
297+ # Manifest results retained from the --sub-path routing pre-check. Reusing
298+ # these avoids walking every selected sub-path again during scan creation.
299+ discovered_scan_files = None
295300
296301 # Git setup
297302 is_repo = False
@@ -534,14 +539,18 @@ def main_code():
534539 # Override file checking to look in the scan paths instead
535540 # Get manifest files from all scan paths
536541 try :
537- all_scan_files = []
542+ discovered_scan_files = []
538543 for scan_path in scan_paths :
539544 scan_files = core .find_files (scan_path )
540- all_scan_files .extend (scan_files )
541- has_supported_files = len (all_scan_files ) > 0
542- log .debug (f"Found { len (all_scan_files )} manifest files across { len (scan_paths )} scan paths" )
545+ discovered_scan_files .extend (scan_files )
546+ has_supported_files = len (discovered_scan_files ) > 0
547+ log .debug (
548+ f"Found { len (discovered_scan_files )} manifest files across "
549+ f"{ len (scan_paths )} scan paths"
550+ )
543551 except Exception as e :
544552 log .debug (f"Error finding files in scan paths: { e } " )
553+ discovered_scan_files = None
545554 has_supported_files = False
546555
547556 # Case 3: If no supported files or files are empty, force API mode (no PR comments)
@@ -564,8 +573,6 @@ def main_code():
564573 org_slug = core .config .org_slug
565574 if config .repo_is_public :
566575 core .config .repo_visibility = "public"
567- if config .excluded_ecosystems and len (config .excluded_ecosystems ) > 0 :
568- core .config .excluded_ecosystems = config .excluded_ecosystems
569576 integration_type = config .integration_type
570577 integration_org_slug = config .integration_org_slug or org_slug
571578 try :
@@ -613,6 +620,12 @@ def main_code():
613620 diff .diff_url = ""
614621 diff .report_url = ""
615622
623+ scan_explicit_files = (
624+ sbom_files_to_submit
625+ if sbom_files_to_submit is not None
626+ else discovered_scan_files
627+ )
628+
616629 # Handle SCM-specific flows
617630 log .debug (f"Flow decision: scm={ scm is not None } , force_diff_mode={ force_diff_mode } , force_api_mode={ force_api_mode } , enable_diff={ config .enable_diff } " )
618631
@@ -684,7 +697,7 @@ def _is_unprocessed(c):
684697 log .info ("Push initiated flow" )
685698 if scm .check_event_type () == "diff" :
686699 log .info ("Starting comment logic for PR/MR event" )
687- 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 )
700+ 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 = scan_explicit_files )
688701 comments = scm .get_comments_for_pr ()
689702
690703 # FIXME: this overwrites diff.new_alerts, which was previously populated by Core.create_issue_alerts
@@ -807,14 +820,14 @@ def _is_unprocessed(c):
807820 )
808821 else :
809822 log .info ("Starting non-PR/MR flow" )
810- 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 )
823+ 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 = scan_explicit_files )
811824
812825 output_handler .handle_output (diff )
813826
814827 elif (config .enable_diff or force_diff_mode ) and not force_api_mode :
815828 # New logic: --enable-diff or force_diff_mode (from --ignore-commit-files in git repos) forces diff mode
816829 log .info ("Diff mode enabled without SCM integration" )
817- 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 )
830+ 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 = scan_explicit_files )
818831 output_handler .handle_output (diff )
819832
820833 elif (config .enable_diff or force_diff_mode ) and force_api_mode :
@@ -834,15 +847,18 @@ def _is_unprocessed(c):
834847 save_files_list_path = config .save_submitted_files_list ,
835848 save_manifest_tar_path = config .save_manifest_tar ,
836849 base_paths = base_paths ,
837- explicit_files = sbom_files_to_submit
850+ explicit_files = scan_explicit_files
838851 )
839852 log .info (f"Full scan created with ID: { diff .id } " )
840853 log .info (f"Full scan report URL: { diff .report_url } " )
841854 output_handler .handle_output (diff )
842855
843856 else :
844857 if force_api_mode :
845- log .info ("No Manifest files changed, creating Socket Report" )
858+ log .info (
859+ "No supported manifest detected in the changed-file set; "
860+ "creating a full Socket report"
861+ )
846862 serializable_params = {
847863 key : value if isinstance (value , (int , float , str , list , dict , bool , type (None ))) else str (value )
848864 for key , value in params .__dict__ .items ()
@@ -855,7 +871,7 @@ def _is_unprocessed(c):
855871 save_files_list_path = config .save_submitted_files_list ,
856872 save_manifest_tar_path = config .save_manifest_tar ,
857873 base_paths = base_paths ,
858- explicit_files = sbom_files_to_submit
874+ explicit_files = scan_explicit_files
859875 )
860876 log .info (f"Full scan created with ID: { diff .id } " )
861877 log .info (f"Full scan report URL: { diff .report_url } " )
@@ -868,7 +884,7 @@ def _is_unprocessed(c):
868884 save_files_list_path = config .save_submitted_files_list ,
869885 save_manifest_tar_path = config .save_manifest_tar ,
870886 base_paths = base_paths ,
871- explicit_files = sbom_files_to_submit
887+ explicit_files = scan_explicit_files
872888 )
873889 output_handler .handle_output (diff )
874890
0 commit comments