-
Notifications
You must be signed in to change notification settings - Fork 62
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
Emit results in a SBOM format #77
Comments
Closed #3 with CycloneDX as the choice. |
Using the local environment parser from CycloneDX as inspiration for the dependency source adapter we'll have to write: https://github.com/CycloneDX/cyclonedx-python-lib/blob/79538e92834e548a3f9697388a47efa3b27da678/cyclonedx/parser/environment.py class EnvironmentParser(BaseParser):
"""
This will look at the current Python environment and list out all installed packages.
Best used when you have virtual Python environments per project.
"""
def __init__(self):
super().__init__()
import pkg_resources
i: pkg_resources.DistInfoDistribution
for i in iter(pkg_resources.working_set):
c = Component(name=i.project_name, version=i.version)
i_metadata = self._get_metadata_for_package(i.project_name)
if 'Author' in i_metadata.keys():
c.set_author(author=i_metadata.get('Author'))
if 'License' in i_metadata.keys() and i_metadata.get('License') != 'UNKNOWN':
c.set_license(license_str=i_metadata.get('License'))
if 'Classifier' in i_metadata.keys():
for classifier in i_metadata.get_all('Classifier'):
if str(classifier).startswith('License :: OSI Approved :: '):
c.set_license(license_str=str(classifier).replace('License :: OSI Approved :: ', '').strip())
self._components.append(c)
@staticmethod
def _get_metadata_for_package(package_name: str):
if sys.version_info >= (3, 8, 0):
return metadata(package_name)
else:
return metadata(package_name) |
Working on this now. Not a blocker, but it looks like the |
Blocked on #3.
The text was updated successfully, but these errors were encountered: