-
Notifications
You must be signed in to change notification settings - Fork 598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read GitHub Dependency Graph SBOM format #3639
Comments
Hi @Shweta4398 - thanks for the issue. Sorry to hear you're having troubles with running grype on an SBOM. However, it's very difficult for us to diagnose the issue without an SBOM to look at. How did you generate the SBOM? Can you please link to the SBOM or upload it here, so we can examine it? |
Hello Popey!! Sure I will upload it here . I have generated it through this :- 'https://api.github.com/repos/{owner}/{repo}/dependency-graph/sbom . Below format!!
|
@popey ^^^ |
Thanks for reporting this issue! I took a look at the SBOM you provided and I think I can see what's happening here. The SBOM appears to be wrapped in an additional For comparison, a standard SPDX JSON format (like those produced by Syft) has the SPDX fields directly at the root level of the JSON document, like this: {
"spdxVersion": "SPDX-2.3",
"dataLicense": "CC0-1.0",
...
} As a workaround, you can strip that outer wrapper with
Now grype understands the file, as it's in the correct format.
Would you be able to try that and let me know if it resolves the issue? Let me know if you need any clarification or have questions! |
Thanks @popey , Thanks for the above solution it worked via terminal . Actually I am trying to update this in the script and having a hard luck .. !! Can you please help ?? Here's my function to get sbom def get_sbom_for_repo_dependabot(owner, repo, access_token):
url = f'[https://api.github.com/repos/{owner}/{repo}/dependency-graph/sbom](https://api.github.com/repos/%7Bowner%7D/%7Brepo%7D/dependency-graph/sbom)'
headers = {'Authorization': f'token {access_token}'}
response = requests.get(url, headers=headers)
if response.status_code == 200:
return response.json()
else:
print(f"Error fetching SBOM for {repo}: {response.status_code} {response.text}")
return None and write to file def write_to_file(repo_data, filename):
try:
with open(filename, 'w') as file:
json.dump(repo_data, file , indent=4)
print(f"SBOM data written to {filename}")
except Exception as e:
print(f"Error writing SBOM data to {filename}: {e}") And generate sbom for per repo def generate_sbom_for_repos_dependabot(repos, owner, access_token):
# sbom_data = []
for repo in repos:
repo_name = repo['name']
if not is_repo_archived(owner, repo_name, access_token):
sbom = get_sbom_for_repo_dependabot(owner, repo_name, access_token)
if sbom:
filename = f"{repo_name}_sbom.json"
write_to_file(sbom, filename) Can you suggest the changes to be made above ?? |
Hey @Shweta4398, it looks like you're using Grype to scan a GitHub Dependency Graph SBOM. Unfortunately, we do not read those today, but Syft does generate these, so an enhancement would be to read them too. As such, I'm going to move this to the Syft repo and retitle it to better represent the ask. Thanks! |
What happened:
I am trying to scan SBOM generated by Dependabot which is in SPDX format .
What you expected to happen:
I want to scan the sbom files generated for vulnerabilities .
How to reproduce it (as minimally and precisely as possible):
I want to run the SBOM on the sbom file generated.
Anything else we need to know?:
Environment:
grype version
:cat /etc/os-release
or similar):The text was updated successfully, but these errors were encountered: