Generate a bill of materials and vulnerability information for your python projects.
Project description
PyBOM
Generate a bill of materials and vulnerability information for your python projects.
About
PyBOM has two functions:
- Aggregate a python project's license, package, and vulnerability information in one place by leveraging the GitHub dependency and vulnerability APIs and PyPI JSON API.
- Report image vulnerability information for docker images pushed to a registry. (Currently in development; Google Container Registry will be the first supported.)
Getting Started
Installation
pip install pybom
...or add pybom to your requirements.txt and run pip install -r requirements.txt.
Usage
GitHub Personal Access Token
PyBOM uses GitHub's v4 GraphQL API to get dependency and vulnerability information. To use the API, you must have a Personal Access Token (PAT).
To get a PAT:
- Navigate to the Personal access tokens page in GitHub's Settings (Settings > Developer settings > Personal access tokens)
- Click Generate new token.
- Add a note explaining what the token is for, and under Scopes, select Repo.
- Click Generate Token.
- Copy the token. You won't be able to see it again.
PyBOM reads the token from the GITHUB_PERSONAL_ACCESS_TOKEN environment variable. To set this variable for all bash sessions, include the following in your .bash_profile (on macOS):
export GITHUB_PERSONAL_ACCESS_TOKEN=<your-token-here>
...then source ~/.bash_profile in your current session to set the variable.
Python BOM
To get a list of components in your Python project hosted in Github: (Note: You must have the Dependency Graph API turned on for this to work.)
from pybom.repository import get_components
repo_name = "pybom"
repo_owner = "carbonrelay"
components = get_components(repo_name, repo_owner)
type(components) # <class 'list'>
type(components[0]) # <class 'pybom.application_component.ApplicationComponent'>
Python Vulnerabilities
To get a list of vulnerabilities in your Python project hosted on Github:
from pybom.repository import get_vulnerabilities
repo_name = "pybom"
repo_owner = "carbonrelay"
vulnerabilities = get_vulnerabilities(repo_name, repo_owner)
type(vulnerabilities) # <class 'list'>
type(vulnerabilities[0]) # <class 'pybom.vulnerability.Vulnerability'>
Image Vulnerabilities
Image vulnerability reporting is not yet fully implemented. It will be finished in a future release.
Contributing
PyBOM is developed and tested against Python 3.6. I recommend using pyenv to manage your python versions and venv to manage project dependencies.
After cloning the repository:
python -m venv venv
. venv/bin/activate
pip install -r requirements.txt
# run tests with coverage report
./coverage.sh
To build the project wheels:
# adapted from https://packaging.python.org/tutorials/packaging-projects/
pip install --user --upgrade setuptools wheel
python setup.py sdist bdist_wheel
If you bump a requirement version in requirements.txt, freeze the new dependencies to requirements-freeze.txt:
pip freeze > requirements-freeze.txt
License
This project is licensed under the Apache license. See LICENSE.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pybom-0.2.0.tar.gz.
File metadata
- Download URL: pybom-0.2.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e31c55444fc48dc7d7e794b786fb0059222aecdee3c638885085e959aef6288
|
|
| MD5 |
389640a0ef6b2b530ee42f81e0fe0585
|
|
| BLAKE2b-256 |
f6fd8d176314e55d2621bfea974d568d07605163f1702d0c782bc62fb6f9ff7b
|
File details
Details for the file pybom-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pybom-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e84a1b6d872b7317036bd2f2ce8c7ce524df4868b94d048d577f3af73515abf7
|
|
| MD5 |
dece0b60255ba290f5bf54a0e8ab5ae8
|
|
| BLAKE2b-256 |
a5a8c769551b5a1d164f16ac715de36d6a6420fc45ef622f8e931837c5a2b9e5
|