Skip to main content

Dependency-Track client by VioletBeacon

Project description

VioletBeacon Dependency-Track Client

A command-line Dependency-Track client that is primarily useful for CI/CD environments.

GitHub: https://github.com/VioletBeacon/deptrack-client

PyPI: https://pypi.org/project/violetbeacon-deptrack-client

Installation

pip install violetbeacon-deptrack-client

This will install the deptrack-client cli into your Python environment.

Usage

Use the -h option to display usage options.

$ deptrack-client -h
usage: deptrack-client [-h] {version,create-config,upload-bom} ...

Dependency-Track Client

positional arguments:
  {version,create-config,upload-bom}
                        Commands
    version             Print version information
    create-config       Create configuration file
    upload-bom          Upload BOM

options:
  -h, --help            show this help message and exit

Create a configuation file (optional)

$ deptrack-client create-config -h
usage: deptrack-client create-config [-h] [-v] -c CONFIG [-H DTRACK_BASEURL] [-A API_KEY] [-a]
                                     -p PROJECT_NAME -q PROJECT_VERSION

options:
  -h, --help            show this help message and exit
  -v                    Increase logging verbosity. Can be provided multiple times.
  -c, --config CONFIG   Path to configuration file. Default: deptrack-client.yaml
  -H, --dtrack-baseurl DTRACK_BASEURL
                        Base URL of Dependency-Track API instance (excluding /api/v1/...). If
                        prefixed with `env:` this is the name of the environment variable which
                        contains the hostname. Default=env:DTRACK_BASEURL
  -A, --api-key API_KEY
                        API key for the Dependency-Track API. If prefixed with `env:` this is the
                        name of the environment variable which contains the API key.
                        Default=env:DTRACK_APIKEY
  -a, --autocreate      Tell Dependency-Track to autocreate the project if it does not exist
  -p, --project-name PROJECT_NAME
                        Project name
  -q, --project-version PROJECT_VERSION
                        Project ID

Example:

$ deptrack-client create-config -H https://my-dependency-track-instance 

Upload a BOM file to Dependency-Track

$ deptrack-client upload-bom --help
usage: deptrack-client upload-bom [-h] [-v] [-c CONFIG] [-H DTRACK_BASEURL] [-A API_KEY] [-a]
                                  -p PROJECT_NAME -q PROJECT_VERSION -f BOM_FILE

options:
  -h, --help            show this help message and exit
  -v                    Increase logging verbosity. Can be provided multiple times.
  -c, --config CONFIG   Path to configuration file. Default: deptrack-client.yaml
  -H, --dtrack-baseurl DTRACK_BASEURL
                        Base URL of Dependency-Track API instance (excluding /api/v1/...). If
                        prefixed with `env:` this is the name of the environment variable which
                        contains the hostname. Default=env:DTRACK_BASEURL
  -A, --api-key API_KEY
                        API key for the Dependency-Track API. If prefixed with `env:` this is the
                        name of the environment variable which contains the API key.
                        Default=env:DTRACK_APIKEY
  -a, --autocreate      Autocreate the project if it does not exist
  -p, --project-name PROJECT_NAME
                        Project name
  -q, --project-version PROJECT_VERSION
                        Project ID
  -f, --bom-file BOM_FILE
                        Path to BOM file

Example (Note: this is not best practice since it will put the API key in the bash history):

$ deptrack-client upload-bom -A odt_... -H https://my-dependency-track-instance -a -p ${PROJECT} -q ${VERSION} -f bom.json

Following is a typical CI/CD example where secrets are injected into the build environment via environment variables:

The default value for the -A | --api-key parameter is env:DTRACK_APIKEY, which tells the client to pull the API key from the environment variable named DTRACK_APIKEY.

The default value for the -H | --dtrack-baseurl parameters is env:DTRACK_BASEURL, which tells the client to pull the base URL from the environment variable named DTRACK_BASEURL.

You can modify these parameters by setting -A env:<APIKEY_VARNAME> and -H env:<URL_VARNAME> options.

# Prerequisites
# 1. The API key is set in the DTRACK_APIKEY environment variable
# 2. The Base URL is set in the DTRACK_BASEURL environment variable
$ deptrack-client upload-bom -a -p ${PROJECT} -q ${VERSION} -f bom.json

Development

See DEVELOPMENT.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

violetbeacon_deptrack_client-0.1.1.tar.gz (43.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

violetbeacon_deptrack_client-0.1.1-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file violetbeacon_deptrack_client-0.1.1.tar.gz.

File metadata

File hashes

Hashes for violetbeacon_deptrack_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 06fc3106098191a6dc7e1792e891360228dfc48206622ee8776a700658e6c73f
MD5 2bddd9558b7dc09aa869a0e277f2b086
BLAKE2b-256 dd6665a1ea8c98a7849770bb242eb4a8cfa518af405d473f5cbe25284dcfbc35

See more details on using hashes here.

File details

Details for the file violetbeacon_deptrack_client-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for violetbeacon_deptrack_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9fa8fed1fe8f3125677d72384c6446694bb1a04f85fea580eb1b116f31ab3bd7
MD5 36173e372f493122cc4d45fce6d7aa95
BLAKE2b-256 96c28bb629bb03bf2f2617788799a427a354d8368f2f78316e732e8171a4eaf2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page