@@ -339,8 +339,7 @@ def get_status(self, vuln_status):
339339
340340 return result
341341
342- def download_sbom (self , env_id = None , ver_id = None , env_name = None ,
343- prod_name = None , ver_name = None , include_vulns = False ,
342+ def download_sbom (self , env_id = None , ver_id = None , include_vulns = False ,
344343 spec = None , spec_version = None , lite = False ,
345344 dont_package_sbom = False , original = False ,
346345 exclude_parts = False , include_support_status = False ,
@@ -349,11 +348,8 @@ def download_sbom(self, env_id=None, ver_id=None, env_name=None,
349348 Download an SBOM from the API.
350349
351350 Args:
352- env_id (str): Environment ID (projectId) (optional)
353- ver_id (str): Version ID (sbomId) (optional)
354- env_name (str): Environment name (projectName) (optional)
355- prod_name (str): Product name (projectGroupName) (optional)
356- ver_name (str): Version name (versionName) (optional)
351+ env_id (str): Environment ID (projectId) - required
352+ ver_id (str): Version ID (sbomId) - required
357353 include_vulns (bool): Include vulnerabilities in download
358354 spec (str): SBOM specification (SPDX or CycloneDX)
359355 spec_version (str): SBOM specification version
@@ -367,23 +363,16 @@ def download_sbom(self, env_id=None, ver_id=None, env_name=None,
367363 Returns:
368364 tuple: (content, content_type, filename) or (None, None, None) if error
369365 """
370- # Build variables for new server format
371- variables = {}
372-
373- # Add identifier parameters
374- if ver_id :
375- variables ["sbomId" ] = ver_id
376- if env_id :
377- variables ["projectId" ] = env_id
378- if prod_name :
379- # Trim the product name before sending to API
380- variables ["projectGroupName" ] = prod_name .strip ()
381- if env_name :
382- # Lowercase and trim the environment name before sending to API
383- variables ["projectName" ] = env_name .strip ().lower ()
384- if ver_name :
385- # Lowercase and trim the version name before sending to API
386- variables ["versionName" ] = ver_name .strip ().lower ()
366+ # Validate required IDs
367+ if not ver_id or not env_id :
368+ print ('Error: Both version ID and environment ID are required for download' )
369+ return None , None , None
370+
371+ # Build variables - the query requires projectId and sbomId
372+ variables = {
373+ "projectId" : env_id ,
374+ "sbomId" : ver_id
375+ }
387376
388377 # Add optional parameters
389378 if include_vulns :
@@ -405,20 +394,29 @@ def download_sbom(self, env_id=None, ver_id=None, env_name=None,
405394 variables ["includeSupportStatus" ] = include_support_status
406395
407396 logging .debug ("Downloading SBOM with parameters: %s" , variables )
408- logging .debug ("GraphQL Query for download:\n %s" , SBOM_DOWNLOAD_NEW )
397+ logging .debug ("GraphQL Query for download:\n %s" , SBOM_DOWNLOAD )
409398 logging .debug ("Query variables: %s" , json .dumps (variables , indent = 2 ))
410399
411400 response_data = self ._make_request (
412- SBOM_DOWNLOAD_NEW , variables , operation_name = "downloadSbom" )
401+ SBOM_DOWNLOAD , variables , operation_name = "downloadSbom" )
413402
414403 if not response_data :
415404 return None , None , None
416405
417406 if "errors" in response_data :
418407 return None , None , None
419408
420- sbom = response_data .get ('data' , {}).get (
421- 'sbom' , {}).get ('download' , {})
409+ data = response_data .get ('data' )
410+ if not data :
411+ print ('Error: No data returned from API' )
412+ return None , None , None
413+
414+ sbom_data = data .get ('sbom' )
415+ if not sbom_data :
416+ print ('Error: SBOM not found - check product, environment, and version' )
417+ return None , None , None
418+
419+ sbom = sbom_data .get ('download' , {})
422420
423421 if not sbom :
424422 print ('No SBOM matched with the given criteria' )
0 commit comments