@@ -674,7 +674,7 @@ def create_full_scan_with_report_url(
674674 sbom_start = time .time ()
675675 sbom_artifacts_dict = self .get_sbom_data (new_full_scan .id )
676676 sbom_artifacts = self .get_sbom_data_list (sbom_artifacts_dict )
677- packages = self .create_packages_dict (sbom_artifacts )
677+ packages = self ._create_packages_dict_without_license_text (sbom_artifacts )
678678 diff .packages = packages
679679
680680 all_alerts_collection : Dict [str , List [Issue ]] = {}
@@ -751,6 +751,30 @@ def create_packages_dict(self, sbom_artifacts: list[SocketArtifact]) -> dict[str
751751
752752 return packages
753753
754+ @staticmethod
755+ def _create_packages_dict_without_license_text (
756+ sbom_artifacts : list [SocketArtifact ],
757+ ) -> dict [str , Package ]:
758+ """Like create_packages_dict but skips the license-metadata API call.
759+
760+ Used when we only need packages for alert extraction (e.g. populating
761+ GitLab/JSON/SARIF reports from a full scan) and don't need license text.
762+ """
763+ packages : dict [str , Package ] = {}
764+ top_level_count : dict [str , int ] = {}
765+ for artifact in sbom_artifacts :
766+ package = Package .from_socket_artifact (asdict (artifact ))
767+ if package .id not in packages :
768+ packages [package .id ] = package
769+ if package .topLevelAncestors :
770+ for top_id in package .topLevelAncestors :
771+ top_level_count [top_id ] = top_level_count .get (top_id , 0 ) + 1
772+
773+ for package_id , package in packages .items ():
774+ package .transitives = top_level_count .get (package_id , 0 )
775+
776+ return packages
777+
754778 def get_package_license_text (self , package : Package ) -> str :
755779 """
756780 Gets the license text for a package if available.
0 commit comments