4646all_new_alerts = False
4747security_policy = {}
4848log = logging .getLogger ("socketdev" )
49+ # log_format = "%(asctime)s %(funcName)20s() %(message)s"
50+ # logging.basicConfig(format=log_format)
4951log .addHandler (logging .NullHandler ())
5052
5153socket_globs = {
@@ -396,29 +398,35 @@ def find_files(path: str, files: list = None) -> list:
396398 :param files: override finding the manifest files using the glob matcher
397399 :return:
398400 """
399- all_files = []
400401 files_provided = False
402+ log .debug ("Starting Find Files" )
403+ start_time = time .time ()
401404 if files is not None and len (files ) > 0 :
402405 files_provided = True
403406 for ecosystem in socket_globs :
407+ if files is None :
408+ files = []
404409 patterns = socket_globs [ecosystem ]
405410 for file_name in patterns :
406411 pattern = patterns [file_name ]["pattern" ]
407412 file_path = f"{ path } /**/{ pattern } "
413+
408414 if not files_provided :
409- files = glob (file_path , recursive = True )
415+ log .debug (f"Globbing { file_path } " )
416+ glob_start = time .time ()
417+ test = glob (file_path , recursive = True )
418+ files = files + test
419+ glob_end = time .time ()
420+ glob_total_time = glob_end - glob_start
421+ log .debug (f"Glob for pattern { file_path } took { glob_total_time :.2f} seconds" )
410422 else :
423+ log .debug ("Files found from commit" )
411424 files = Core .match_supported_files (path , files )
412- for file in files :
413- if platform .system () == "Windows" :
414- file = file .replace ("\\ " , "/" )
415- if path not in file :
416- file = f"{ path } /{ file } "
417- found_path , file_name = file .rsplit ("/" , 1 )
418- details = (found_path , file_name )
419- if details not in all_files :
420- all_files .append (details )
421- return all_files
425+ log .debug ("Finished Find Files" )
426+ end_time = time .time ()
427+ total_time = end_time - start_time
428+ log .info (f"Found { len (files )} in { total_time :.2f} seconds" )
429+ return files
422430
423431 @staticmethod
424432 def create_full_scan (files : list , params : FullScanParams , workspace : str ) -> FullScan :
@@ -430,7 +438,16 @@ def create_full_scan(files: list, params: FullScanParams, workspace: str) -> Ful
430438 :return:
431439 """
432440 send_files = []
433- for path , name in files :
441+ create_full_start = time .time ()
442+ log .debug ("Creating new full scan" )
443+ for file in files :
444+ if platform .system () == "Windows" :
445+ file = file .replace ("\\ " , "/" )
446+ if "/" in file :
447+ path , name = file .rsplit ("/" , 1 )
448+ else :
449+ path = "."
450+ name = file
434451 full_path = f"{ path } /{ name } "
435452 if full_path .startswith (workspace ):
436453 key = full_path [len (workspace ):]
@@ -452,6 +469,9 @@ def create_full_scan(files: list, params: FullScanParams, workspace: str) -> Ful
452469 results = response .json ()
453470 full_scan = FullScan (** results )
454471 full_scan .sbom_artifacts = Core .get_sbom_data (full_scan .id )
472+ create_full_end = time .time ()
473+ total_time = create_full_end - create_full_start
474+ log .debug (f"New Full Scan created in { total_time :.2f} seconds" )
455475 return full_scan
456476
457477 @staticmethod
0 commit comments