This is re-usable python tools for working with SBoMs
This project contains libraries for working with SBoMs
Most users will want to use SBOMGuard or icsbom and not these libraries directly.
Package are on pypi pip install ics-sbom-libs
We suggest a workflow involving the following tools:
pyenv
-- to manage python versions (and virtual environments on MacOS + Linux)poetry
-- to manage dependency resolution, installation, building, packaging, publishing, and running of the codepyinstaller
-- to build executables that can be ran without requiring a python installation on the target systembrew install pyenv
% sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget
curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
% curl https://pyenv.run | bash
...
# This sets up pyenv into your profile
% echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
% echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
% echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
Invoke-WebRequest -UseBasicParsing -Uri 'https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1' -OutFile "./install-pyenv-win.ps1"; \&'./install-pyenv-win.ps1'
$env:PATH='$HOME\.pyenv\pyenv-win\bin;' + $env:PATH
$env:PATH='$HOME\.pyenv\pyenv-win\shims;' + $env:PATH
Checking for what versions of python are available to install
pyenv install --list
Checking for what versions of python are installed
pyenv versions
Install desired python version:
pyenv install 3.11
Set the global python version
pyenv global 3.11
Set the local (dependent on directory) python version
pyenv local 3.9
Install pip (if it wasn’t already installed)
wget https://bootstrap.pypa.io/get-pip.py -OutFile get-pip.py
python ./get-pip.py
rm get-pip.py
Mac:
% brew install poetry
Ubuntu:
% sudo apt-get install pipx
% pipx install poetry
PowerShell:
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
$HOME\AppData\Roaming\Python\Scripts
Limitations of pyenv/poetry on Windows (which DO NOT EXIST ON POSIX):
A few important commands using poetry are:
poetry install
poetry lock
poetry run black .
poetry build
poetry run <script_name>
Each poetry run
creates a virtual environment in which the script is executed. If pyenv
controls the virtual environments,
poetry
should be configured to not create virtual environments. In this case, poetry
will respect and use the pyenv virtual environment.
Downloading the NVD database into the cache can take a very long time. To help with this they have created a way to use an API key that will allow you to access the NVD database at a faster rate. You can find the instructions to receive and activate an API key here.
Once you have the API key you can copy it into the cache_dir
(default: ${HOME}/.cache/icsbom
) in a file called api_key.txt
.
Another way that you can use your API key is as an argument to the CLI tools using --api_key ${your key}
.