@@ -82,15 +82,17 @@ def get_org_id_slug(self) -> Tuple[str, str]:
8282 return org_id , organizations [org_id ]['slug' ]
8383 return None , None
8484
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 ]:
8686 """Returns the list of SBOM artifacts for a full scan."""
8787 response = self .sdk .fullscans .stream (self .config .org_slug , full_scan_id , use_types = True )
88+ artifacts : List [SocketArtifact ] = []
8889 if not response .success :
8990 log .debug (f"Failed to get SBOM data for full-scan { full_scan_id } " )
9091 log .debug (response .message )
9192 return {}
92-
93- return response .artifacts
93+ for artifact_id in response .artifacts :
94+ artifacts .append (response .artifacts [artifact_id ])
95+ return artifacts
9496
9597 def get_sbom_data_list (self , artifacts_dict : Dict [str , SocketArtifact ]) -> list [SocketArtifact ]:
9698 """Converts artifacts dictionary to a list."""
@@ -326,8 +328,7 @@ def create_full_scan(self, files: List[str], params: FullScanParams, has_head_sc
326328
327329 full_scan = FullScan (** asdict (res .data ))
328330 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 )
331332 full_scan .packages = self .create_packages_dict (full_scan .sbom_artifacts )
332333
333334 create_full_end = time .time ()
@@ -436,7 +437,8 @@ def get_repo_info(self, repo_slug: str, default_branch: str = "socket-default-br
436437 log .error ("Failed to create repository: empty response" )
437438 raise Exception ("Failed to create repository: empty response" )
438439 else :
439- return create_response
440+ response = self .sdk .repos .repo (self .config .org_slug , repo_slug , use_types = True )
441+ return response .data
440442
441443 except APIFailure as e :
442444 log .error (f"API failure while creating repository: { e } " )
@@ -554,22 +556,23 @@ def create_new_diff(
554556 # Find manifest files
555557 files = self .find_files (path )
556558 files_for_sending = self .load_files_for_sending (files , path )
557-
559+ has_head_scan = False
558560 if not files :
559561 return Diff (id = "no_diff_id" )
560562
561563 try :
562564 # Get head scan ID
563565 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
565568 except APIResourceNotFound :
566569 head_full_scan_id = None
567- has_head_scan = False
568570
569571 # Create new scan
570572 try :
571573 new_scan_start = time .time ()
572574 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 )
573576 new_scan_end = time .time ()
574577 log .info (f"Total time to create new full scan: { new_scan_end - new_scan_start :.2f} " )
575578 except APIFailure as e :
0 commit comments