Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created September 20, 2024 21:17
Show Gist options
  • Save KyMidd/a6b325e9e660628a107433598c6a45af to your computer and use it in GitHub Desktop.
Save KyMidd/a6b325e9e660628a107433598c6a45af to your computer and use it in GitHub Desktop.
# Parse response by looping over sbom.packages to get all names and license types
for package in response.json()['sbom']['packages']:
# If license key not present, set to unknown
if 'licenseConcluded' not in package:
license = "Unknown"
else:
license = package['licenseConcluded']
# If license contains string GPL, print out repo name
if "GPL" in license.upper():
print("- ⬅️ Copyleft licensed tool found:", package['name'], "with license:", license)
# Write to CSV
with open(GITHUB_ORG+"_repo_dependency_licensing.csv", 'a', newline='') as file:
# Initialize writer
writer = csv.writer(file)
# Write data
field = [GITHUB_ORG, repo, package['name'], license]
writer.writerow(field)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment