Universal Importer & DefectDojo-CLI | DefectDojo Documentation

Universal Importer & DefectDojo-CLI (Pro)

Note: The following external tools are DefectDojo Pro-only features. These binaries will not work unless they are connected to an instance with a DefectDojo Pro license.

About External Tools

defectdojo-cli and universal-importer are command-line tools designed to streamline both the import and re-import processes of Findings and associated objects, making it ideal for users who want to quickly set up these interactions with the DefectDojo API.

DefectDojo-CLI has the same functionality as Universal Importer, but also includes the ability to export Findings from DefectDojo to JSON or CSV.

Installation

  1. Locate “External Tools” from your User Profile menu:

  2. Download the appropriate binary for your operating system from the platform.

  3. Extract the downloaded archive within a directory of your choice. Optionally, add the directory containing the extracted binary to your system’s $PATH for repeat access.

Note that Macintosh users may be blocked from running DefectDojo-CLI or Universal Importer as they are apps from an unidentified developer. See Apple Support for instructions on how to override the block from Apple.

Windows Users: If you receive the “Couldn’t download - virus detected” error, disabling Smartscreen may work. Otherwise, use a different browser to download the tool from the Cloud portal.

Configuration

Universal Importer & DefectDojo-CLI can be configured using flags, environment variables, or a configuration file. The most important configuration is the API token, which must be set as an environment variable:

  1. Add your API key to your environment variables. You can retrieve your API key from: https://YOUR_INSTANCE.cloud.defectdojo.com/api/key-v2

or

Via the DefectDojo user interface in the user dropdown in the top-right corner:

  1. Set your environment variable for the API token:

    For DefectDojo-CLI: export DD_CLI_API_TOKEN=YOUR_API_KEY

    For Universal Importer: export DD_IMPORTER_DOJO_API_TOKEN=YOUR_API_KEY

Note: On Windows, use set instead of export.

Windows: Using PowerShell

  1. Open PowerShell (Windows Key, then search for “PowerShell”).

  2. Set the environment variables:

    • Temporary:

      $env:DD_IMPORTER_DOJO_API_TOKEN = "[VALUE_FROM_DEFECTDOJO_API]"
      $env:DD_IMPORTER_DEFECTDOJO_URL=”[e.g. http://localhost:8080/defectdojo]”
      
    • Permanent:

      [Environment]::SetEnvironmentVariable("DD_IMPORTER_DOJO_API_TOKEN", "[VALUE_FROM_DEFECTDOJO_API]", "Machine")
      
  3. Restart your PowerShell session.

  4. Verify the setting:

    echo $env:DD_IMPORTER_DOJO_API_TOKEN
    echo $env:DD_IMPORTER_DEFECTDOJO_URL
    

Windows: Using Command Prompt (Administrative Accounts)

  1. Open Command Prompt (Windows Key, then search for “Command Prompt”).
  2. Set the environment variables:
    • Temporary:

      set DD_IMPORTER_DOJO_API_TOKEN = "[VALUE_FROM_DEFECTDOJO_API]"
      set DD_IMPORTER_DEFECTDOJO_URL=”[e.g. http://localhost:8080/defectdojo]”
      
    • Permanent:

      setx DD_IMPORTER_DOJO_API_TOKEN = "[VALUE_FROM_DEFECTDOJO_API]"
      setx DD_IMPORTER_DEFECTDOJO_URL=”[e.g. http://localhost:8080/defectdojo]"
      

Windows Settings (Non-Administrative Accounts)

  1. Press Win + I to open the system settings dialog.

  2. In the search box, type “environment”.

  3. Choose “Edit Environment variables for your account”.

  4. Under “User variables for [username]”, click the “New…” button.

  5. Set the variable:

    • Variable name: DD_IMPORTER_DOJO_API_TOKEN
    • Variable value: [VALUE_FROM_DEFECTDOJO_API]
  6. Click “OK”.

  7. Repeat steps 4 through 6 for the DD_IMPORTER_DEFECTDOJO_URL variable.

  8. Restart any open command windows.

  9. Verify the settings:

    echo %DD_IMPORTER_DOJO_API_TOKEN%
    echo %DD_IMPORTER_DEFECTDOJO_URL%
    

DefectDojo-CLI

defectdojo-cli seamlessly integrates scan results into DefectDojo, streamlining the import and reimport processes of Findings and associated objects. Designed for ease of use, the tool supports various endpoints, catering to both initial imports and subsequent reimports — ideal for users requiring robust and flexible interaction with the DefectDojo API. DefectDojo-CLI can perform the same functions as universal-importer, and adds export functionality for Findings.

Commands

Global Options

--help, -h

--version, -v

CLI Formatting

--no-color

--no-emojis, --no-emoji

--verbose

Import

Use the import command to import new findings into DefectDojo.

Usage

defectdojo-cli [global options] import <required flags> [optional flags]
    or: defectdojo-cli [global options] import  --config ./config-file-path
    or: defectdojo-cli import [-h | --help]
    or: defectdojo-cli import example [subcommand options]
    or: defectdojo-cli import example [-h | --help]

>> The API token must be set in the environment variable `DD_CLI_API_TOKEN`.

import can import Findings in two ways:

By ID:

In this scenario, a new Test will be created inside the Engagement.

By Name:

In this scenario, DefectDojo will look up the Engagement by the provided details.

When using names you can let the importer automatically create Engagements, Products and Product-types by using auto-create-context=true. You can use deduplication-on-engagement to restrict deduplication for imported Findings to the newly created Engagement.

Import Basic syntax:

defectdojo-cli import [options]

Import Example:

defectdojo-cli import \
--defectdojo-url "https://YOUR_INSTANCE.cloud.defectdojo.com/" \
--scan-type "burp scan" \
--report-path "./examples/burp_findings.xml" \
--product-name "dev" \
--engagement-name "dev" \
--product-type-name "Research and Development" \
--test-name "burp-test-dev" \
--verified \
--active \
--minimum-severity "info" \
--tag "dev" --tag "tools" --tag "burp" --tag "test-dev" \
--test-version "0.0.1" \
--auto-create-context

Commands

example, x

Options

--active, -a

--api-scan-configuration value, --asc value

--apply-tags-endpoints, --te

--apply-tags-findings, --tf

--auto-create-context, --acc

--close-old-findings, --cof

--close-old-findings-product-scope, --cofps

--deduplication-on-engagement, --doe

--engagement-id value, --ei value

--engagement-name value, -e value

--minimum-severity value, --ms value

--product-name value, -p value

--product-type-name value, --pt value

--report-path value, -r value

--scan-type value, -s value

--tag value, -t value [ --tag value, -t value ]

--test-name value, --tn value

--test-version value, -V value

--verified, -v

Settings:

--config value, -c value

--defectdojo-url value, -u value

--insecure-tls, --no-tls

Reimport

Use the reimport command to extend an existing Test with Findings from a new report in one of two ways:

By ID:

By Names:

In this scenario, DefectDojo will look up the Test by the provided details. If no test-name is provided, the latest test inside the engagement will be chosen based on scan-type.

Usage

defectdojo-cli [global options] reimport <required flags> [optional flags]
   or: defectdojo-cli [global options] reimport  --config ./config-file-path
   or: defectdojo-cli reimport [-h | --help]
   or: defectdojo-cli reimport example [subcommand options]
   or: defectdojo-cli reimport example [-h | --help]

>> The API token must be set in the environment variable `DD_CLI_API_TOKEN`.

Reimport Example:

defectdojo-cli reimport \
--defectdojo-url "https://YOUR_INSTANCE.cloud.defectdojo.com/" \
--scan-type "Nancy Scan" \
--report-path "./examples/nancy_findings.json" \
--test-id 11 \
--verified \
--active \
--minimum-severity "info" \
--tag "dev" --tag "tools" --tag "nancy" --tag "test-dev" \
--test-version "1.0" \
--auto-create-context

Commands

example, x

Options

--active, -a

--api-scan-configuration value, --asc value

--apply-tags-endpoints, --te

--apply-tags-findings, --tf

--auto-create-context, --acc

--close-old-findings, --cof

Export

Usage

defectdojo-cli export <required options> [optional options]
    or: defectdojo-cli [global options] export --defectdojo-url <https://YOUR_INSTANCE.cloud.defectdojo.com/> --json ./output_file_path.json [optional filters]
    or: defectdojo-cli [global options] export --defectdojo-url <https://YOUR_INSTANCE.cloud.defectdojo.com/> --csv ./output_file_path.csv [optional filters]
    or: defectdojo-cli [global options] export --defectdojo-url <https://YOUR_INSTANCE.cloud.defectdojo.com/> --json ./output_file_path.json --csv ./output_file_path.csv [optional filters]
    or: defectdojo-cli [global options] export --config ./config-file-path
    or: defectdojo-cli [global options] export --config ./config-file-path --json ./output_file_path.json
    or: defectdojo-cli [global options] export --config ./config-file-path --csv ./output_file_path.csv
    or: defectdojo-cli export [-h | --help]
    or: defectdojo-cli export example [subcommand options]
    or: defectdojo-cli export example [-h | --help]

>> The API token must be set in the environment variable `DD_CLI_API_TOKEN`.

To export Findings from DefectDojo-CLI, you will need to supply a configuration file which contains details explaining which Findings you wish to export. This is similar to the GET Findings method via the API.

For assistance use defectdojo-cli export --help.

Export Example

This example specifies the URL, export format and a few filter parameters to create a list of Findings.

defectdojo-cli export \
--defectdojo-url "https://your-dojo-instance.cloud.defectdojo.com/"
--json "./path/to/findings.json" \
--active "true" \
--created "Past 90 days"

Commands

example, x

help, h

Options

Findings Filters:

--active true|false, -a true|false

--created value

--cvssv3-score value

--cwe value

--date value

--discovered-after value

--discovered-before value

--discovered-on value

--duplicate true|false

--engagement-ids value [ --engagement-ids value ]

--epss-percentile value

--epss-score value

--false-positive true|false

--is-mitigated true|false

--mitigated value

--mitigated-after value

--mitigated-before value

--mitigated-by-ids value [ --mitigated-by-ids value ]

--mitigated-by-names value [ --mitigated-by-names value ]

--mitigated-on value

--not-tags value [ --not-tags value ]

--out-of-scope true|false

--out-of-sla true|false

--product-name value

--product-name-contains value

--product-type-ids value [ --product-type-ids value ]

--product-type-names value [ --product-type-names value ]

--risk-accepted true|false

--severity value [ --severity value ]

--tags value [ --tags value ]

--test-id value

--title-contains value

--under-review true|false

--verified true|false

Findings Output

--csv value

--json value

Settings

--config value, -c value

--defectdojo-url value, -u value

--insecure-tls, --no-tls

Interactive

Interactive mode allows you to configure import and reimport process, step-by-step.

Usage

defectdojo-cli interactive
    or: defectdojo-cli interactive  [--skip-intro] [--no-full-screen] [--log-path]
    or: defectdojo-cli interactive [-h | --help]

Options

--skip-intro

--no-full-screen

--log-path value

--help, -h

Universal Importer

universal-importer seamlessly integrates scan results into DefectDojo, streamlining both the import and reimport processes of findings and associated objects. Designed for ease of use, the tool supports various endpoints, catering to both initial imports and subsequent reimports — ideal for users requiring robust and flexible interaction with the DefectDojo API.

While similar to DefectDojo-CLI, Universal Importer does not have the Export functionality, and environment variables are encoded differently.

Commands

Global Options

--help, -h

--version, -v

CLI Formatting

--no-color

--no-emojis, --no-emoji

--verbose

Import

Use the import command to import new findings into DefectDojo.

Usage

universal-importer [global options] import <required flags> [optional flags]
    or: universal-importer [global options] import  --config ./config-file-path
    or: universal-importer import [-h | --help]
    or: universal-importer import example [subcommand options]
    or: universal-importer import example [-h | --help]

>> The API token must be set in the environment variable `DD_IMPORTER_DOJO_API_TOKEN`.

import can import Findings in two ways:

By ID:

By Name:

When using names you can let the importer automatically create Engagements, Products and Product-types by using auto-create-context=true.

Import Basic syntax:

universal-importer import [options]

Import Example:

universal-importer import \
--defectdojo-url "https://YOUR_INSTANCE.cloud.defectdojo.com/" \
--scan-type "burp scan" \
--report-path "./examples/burp_findings.xml" \
--product-name "dev" \
--engagement-name "dev" \
--product-type-name "Research and Development" \
--test-name "burp-test-dev" \
--verified \
--active \
--minimum-severity "info" \
--tag "dev" --tag "tools" --tag "burp" --tag "test-dev" \
--test-version "0.0.1" \
--auto-create-context

Reimport

Use the reimport command to extend an existing Test with Findings from a new report in one of two ways:

By ID:

By Names:

In this scenario, DefectDojo will look up the Test by the provided details.

Usage

universal-importer [global options] reimport <required flags> [optional flags]
   or: universal-importer [global options] reimport  --config ./config-file-path
   or: universal-importer reimport [-h | --help]
   or: universal-importer reimport example [subcommand options]
   or: universal-importer reimport example [-h | --help]

>> The API token must be set in the environment variable `DD_IMPORTER_DOJO_API_TOKEN`.

Reimport Example:

universal-importer reimport \
--defectdojo-url "https://YOUR_INSTANCE.cloud.defectdojo.com/" \
--scan-type "Nancy Scan" \
--report-path "./examples/nancy_findings.json" \
--test-id 11 \
--verified \
--active \
--minimum-severity "info" \
--tag "dev" --tag "tools" --tag "nancy" --tag "test-dev" \
--test-version "1.0" \
--auto-create-context

Troubleshooting

If you encounter any issues with these tools, please check the following: