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

Installation

pip install violetbeacon_deptrack_util

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

A typical CI/CD example where secrets are injected into the build environment via environment variables is shown below.

Note: 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.0.tar.gz (43.8 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.0-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for violetbeacon_deptrack_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7bee5bd0f8d5e1e0ab0757b3f1c6ff69a3ac182ba68aa95f756f88d68898f882
MD5 c951c251e3342d3b8bc28d5e2611ef7f
BLAKE2b-256 2d50b4ba72b9a112a70cace12e1f3f96e3a149580fd428e8c9dde673af8bf0fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for violetbeacon_deptrack_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fccda8852d317778d3575c706dc838822b24b3428287bb64e2b021c75f9b87eb
MD5 da365952a26e462f7e29e2e307f6537f
BLAKE2b-256 165cbf75044c52f78f48c26219b10eef5cf662d549c2204f17cafc43901b8f94

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