@@ -82,15 +82,17 @@ def get_org_id_slug(self) -> Tuple[str, str]:
82
82
return org_id , organizations [org_id ]['slug' ]
83
83
return None , None
84
84
85
- def get_sbom_data (self , full_scan_id : str ) -> Dict [ str , SocketArtifact ]:
85
+ def get_sbom_data (self , full_scan_id : str ) -> List [ SocketArtifact ]:
86
86
"""Returns the list of SBOM artifacts for a full scan."""
87
87
response = self .sdk .fullscans .stream (self .config .org_slug , full_scan_id , use_types = True )
88
+ artifacts : List [SocketArtifact ] = []
88
89
if not response .success :
89
90
log .debug (f"Failed to get SBOM data for full-scan { full_scan_id } " )
90
91
log .debug (response .message )
91
92
return {}
92
-
93
- return response .artifacts
93
+ for artifact_id in response .artifacts :
94
+ artifacts .append (response .artifacts [artifact_id ])
95
+ return artifacts
94
96
95
97
def get_sbom_data_list (self , artifacts_dict : Dict [str , SocketArtifact ]) -> list [SocketArtifact ]:
96
98
"""Converts artifacts dictionary to a list."""
@@ -326,8 +328,7 @@ def create_full_scan(self, files: List[str], params: FullScanParams, has_head_sc
326
328
327
329
full_scan = FullScan (** asdict (res .data ))
328
330
if not has_head_scan :
329
- full_scan_artifacts_dict = self .get_sbom_data (full_scan .id )
330
- full_scan .sbom_artifacts = self .get_sbom_data_list (full_scan_artifacts_dict )
331
+ full_scan .sbom_artifacts = self .get_sbom_data (full_scan .id )
331
332
full_scan .packages = self .create_packages_dict (full_scan .sbom_artifacts )
332
333
333
334
create_full_end = time .time ()
@@ -436,7 +437,8 @@ def get_repo_info(self, repo_slug: str, default_branch: str = "socket-default-br
436
437
log .error ("Failed to create repository: empty response" )
437
438
raise Exception ("Failed to create repository: empty response" )
438
439
else :
439
- return create_response
440
+ response = self .sdk .repos .repo (self .config .org_slug , repo_slug , use_types = True )
441
+ return response .data
440
442
441
443
except APIFailure as e :
442
444
log .error (f"API failure while creating repository: { e } " )
@@ -554,22 +556,23 @@ def create_new_diff(
554
556
# Find manifest files
555
557
files = self .find_files (path )
556
558
files_for_sending = self .load_files_for_sending (files , path )
557
-
559
+ has_head_scan = False
558
560
if not files :
559
561
return Diff (id = "no_diff_id" )
560
562
561
563
try :
562
564
# Get head scan ID
563
565
head_full_scan_id = self .get_head_scan_for_repo (params .repo )
564
- has_head_scan = True
566
+ if head_full_scan_id is not None :
567
+ has_head_scan = True
565
568
except APIResourceNotFound :
566
569
head_full_scan_id = None
567
- has_head_scan = False
568
570
569
571
# Create new scan
570
572
try :
571
573
new_scan_start = time .time ()
572
574
new_full_scan = self .create_full_scan (files_for_sending , params , has_head_scan )
575
+ new_full_scan .sbom_artifacts = self .get_sbom_data (new_full_scan .id )
573
576
new_scan_end = time .time ()
574
577
log .info (f"Total time to create new full scan: { new_scan_end - new_scan_start :.2f} " )
575
578
except APIFailure as e :
0 commit comments