Skip to main content

CLI Wrapper for DefectDojo using APIv2

Project description

DefectDojo CLI

License

A CLI wrapper for DefectDojo

Installation

Simply run:

python3 -m pip install defectdojo-cli2

This will install it as defectdojo.

Usage

defectdojo --help

Upload scans

Example:

defectdojo reimport_scan upload --product_name="test dd" --engagement_name="DefectDojoImporter" --scan_type="GitLab Container Scan" --active --verified --test_title="GitLab Container Scan" --file=gl-container-scanning.json

This wil upload a Gitlab Container Scan report to DefectDojo to the product named test dd and engagement called DefectDojoImporter and name the test GitLab Container Scan, if it exists it do a reimport on that test, if it doesn't exists, it will create a new test with that name. If you name the engagement to something that doesn't already exists, it will create a name engagement with the provided name.

Upload languages

Example:

defectdojo import_languages upload --product=21 --file=cloc.json

This will upload a language file for a project (normally generated with cloc) to the product with the id provided.

Development

poetry env use /usr/local/bin/python3 # = your full path to the Python executable.
poetry install
poetry run python3 defectdojo_cli2

Update dependencies https://github.com/MousaZeidBaker/poetry-plugin-up

poetry self add poetry-plugin-up
poetry up

Using environment variables

The goal of this cli is not only to be used as a cli tool for accessing DefectDojo API, but also to be able to run automated jobs in a CI environment, like importing scans to DefectDojo.

To use Defectdojo CLI in a CI context, there is DEFECTDOJO_ prefixed environment variables you could set. This, so you don't need to provide the arguments.

DEFECTDOJO_API_KEY
DEFECTDOJO_BRANCH_TAG
DEFECTDOJO_COMMIT_HASH
DEFECTDOJO_ENGAGEMENT_END_DATE
DEFECTDOJO_ENGAGEMENT_ID
DEFECTDOJO_ENGAGEMENT_NAME
DEFECTDOJO_LANGUAGES_FILE
DEFECTDOJO_PASSWORD
DEFECTDOJO_PRODUCT_ID
DEFECTDOJO_PRODUCT_NAME
DEFECTDOJO_PUSH_TO_JIRA
DEFECTDOJO_SCAN_TYPE
DEFECTDOJO_TEST_NAME
DEFECTDOJO_TEST_TITLE
DEFECTDOJO_TEST_TYPE
DEFECTDOJO_URL
DEFECTDOJO_USER_NAME

Docker images

Docker images containing defectdojo cli is published on docker hub.

Example of running defectdojo cli in GitLab Runner

To upload results of GitLab Container Scan:

defectdojo:upload:container:scanning:
  image: digitalist/defectdojo-cli2:latest
  needs:
    - job: container_scanning
      artifacts: true
  stage: .post
  variables:
    GIT_STRATEGY: none
    DEFECTDOJO_API_KEY: c1ca1f4193f2460f9f6a3dab22b723ab
    DEFECTDOJO_URL: https://defectdojo.url
    DEFECTDOJO_ENGAGEMENT_NAME: "Gitlab Runner"
    DEFECTDOJO_PRODUCT_NAME: ${CI_PROJECT_TITLE}
    DEFECTDOJO_BRANCH_TAG: ${CI_COMMIT_REF_NAME}
    DEFECTDOJO_COMMIT_HASH: ${CI_COMMIT_SHA}
    DEFECTDOJO_SCAN_TYPE: "GitLab Container Scan"
    DEFECTDOJO_TEST_TITLE: "GitLab Container Scan"
  script:
    - defectdojo reimport_scan upload --file=gl-container-scanning-report.json

To upload results of cloc (languages) to project number 42 in DefectDojo:

defectdojo:upload:cloc:
  image: digitalist/defectdojo-cli2:latest
  needs:
    - job: cloc
      artifacts: true
  variables:
    DEFECTDOJO_API_KEY: c1ca1f4193f2460f9f6a3dab22b723ab
    DEFECTDOJO_URL: https://defectdojo.url
    DEFECTDOJO_PRODUCT_ID: 42
  script:
    - defectdojo import_languages upload --file=cloc.json

Fork

This started as a fork of https://github.com/adiffpirate/defectdojo-cli.

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

defectdojo_cli2-0.1.15.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

defectdojo_cli2-0.1.15-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file defectdojo_cli2-0.1.15.tar.gz.

File metadata

  • Download URL: defectdojo_cli2-0.1.15.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Darwin/23.6.0

File hashes

Hashes for defectdojo_cli2-0.1.15.tar.gz
Algorithm Hash digest
SHA256 63e42c523951691ff2d4f676b6083d2743f2ae2e7a66ef473176e4636d8453c0
MD5 0fd467c74e67a3c6d022984387f45575
BLAKE2b-256 728aef69dc4c4cac102dc8254fef7ff24ddc71c3a5666c5683b8a0e5fc202f6d

See more details on using hashes here.

File details

Details for the file defectdojo_cli2-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: defectdojo_cli2-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 25.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Darwin/23.6.0

File hashes

Hashes for defectdojo_cli2-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 5256a3b3cb69d3d95f7673d58c515982834ca4931d7070d095cfd4da972483fe
MD5 4c7b1d2d0cac0c17dfbeba4dcddc6445
BLAKE2b-256 33a5f1161cc8e5558d4c09be059a60988bd2de30f2af47c5a5a27139592d4ae4

See more details on using hashes here.

Supported by

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