2525
2626
2727__author__ = 'socket.dev'
28- __version__ = '0.0.67 '
28+ __version__ = '0.0.72 '
2929__all__ = [
3030 "Core" ,
3131 "log" ,
@@ -246,6 +246,55 @@ def get_security_policy() -> dict:
246246 }
247247 return org_rules
248248
249+ # @staticmethod
250+ # def get_supported_file_types() -> dict:
251+ # path = "report/supported"
252+
253+ @staticmethod
254+ def get_manifest_files (package : Package , packages : dict ) -> str :
255+ if package .direct :
256+ manifests = []
257+ for manifest_item in package .manifestFiles :
258+ manifest = manifest_item ["file" ]
259+ manifests .append (manifest )
260+ manifest_files = ";" .join (manifests )
261+ else :
262+ manifests = []
263+ for top_id in package .topLevelAncestors :
264+ top_package : Package
265+ top_package = packages [top_id ]
266+ for manifest_item in top_package .manifestFiles :
267+ manifest = manifest_item ["file" ]
268+ new_string = f"{ package .name } @{ package .version } ({ manifest } )"
269+ manifests .append (new_string )
270+ manifest_files = ";" .join (manifests )
271+ return manifest_files
272+
273+ @staticmethod
274+ def create_sbom_output (diff : Diff ) -> list :
275+ sbom = []
276+ for package_id in diff .packages :
277+ package : Package
278+ package = diff .packages [package_id ]
279+ manifest_files = Core .get_manifest_files (package , diff .packages )
280+ item = {
281+ "id" : package .id ,
282+ "license" : package .license ,
283+ "license_text" : package .license_text ,
284+ "manifestFiles" : manifest_files ,
285+ "score" : package .score ,
286+ "size" : package .size ,
287+ "ecosystem" : package .type ,
288+ "alerts" : package .alerts ,
289+ "direct" : package .direct ,
290+ "name" : package .name ,
291+ "version" : package .version ,
292+ "author" : package .author ,
293+ "url" : package .url
294+ }
295+ sbom .append (item )
296+ return sbom
297+
249298 @staticmethod
250299 def find_files (path : str ) -> list :
251300 """
@@ -314,8 +363,8 @@ def find_files(path: str) -> list:
314363 "requirements.frozen" : {
315364 "pattern" : "requirements.frozen"
316365 },
317- "setup.py.old " : {
318- "pattern" : "setup.py.old "
366+ "setup.py" : {
367+ "pattern" : "setup.py"
319368 }
320369 },
321370 "golang" : {
@@ -325,6 +374,11 @@ def find_files(path: str) -> list:
325374 "go.sum" : {
326375 "pattern" : "go.sum"
327376 }
377+ },
378+ "java" : {
379+ "pom.xml" : {
380+ "pattern" : "pom.xml"
381+ }
328382 }
329383 }
330384 all_files = []
@@ -469,12 +523,12 @@ def compare_sboms(new_scan: list, head_scan: list) -> Diff:
469523
470524 for package_id in new_packages :
471525 purl , package = Core .create_purl (package_id , new_packages )
472- if package_id not in head_packages :
526+ if package_id not in head_packages and package . direct :
473527 diff .new_packages .append (purl )
474528 new_scan_alerts = Core .create_issue_alerts (package , new_scan_alerts , new_packages )
475529 for package_id in head_packages :
476530 purl , package = Core .create_purl (package_id , head_packages )
477- if package_id not in new_packages :
531+ if package_id not in new_packages and package . direct :
478532 diff .removed_packages .append (purl )
479533 head_scan_alerts = Core .create_issue_alerts (package , head_scan_alerts , head_packages )
480534 diff .new_alerts = Core .compare_issue_alerts (new_scan_alerts , head_scan_alerts , diff .new_alerts )
0 commit comments