Debricked CLI
Learn all about our Command Line Interface, which enables you to run vulnerability scans on your local machine and integrate Debricked into your pipeline.
Introduction
The Debricked CLI is Debricked's command line interface, bringing open-source security, and license compliance to your project via the command prompt.
The Debricked CLI is currently available for: Windows, Linux, and macOS operating systems. It might work on other operating systems but has not been thoroughly tested yet. Supported languages: Javascript, Java, C#, Ruby, PHP, and more.
Supported package managers: Yarn, Npm, Bowel, Bazel, Gradle, and more.
Mastering Debricked's CLI and API - webinar recording
Check out our latest training webinar and learn the basics of working with Debricked CLI and API:
1. Getting started
To use the Debricked CLI, you must have a Debricked account, create an access token and install the CLI.
The CLI can be run:
locally in your terminal as an interactive shell
in your CI/CD pipeline
through docker
1.1 Authentication
To create an access token, log in to Debricked and follow the steps to generate an access token. Make sure to keep the access token in a safe place for later use.
2. Installation
The CLI can be installed and used through:
Local installations: - Standalone - Installation using Go
Adding the CLI into your CI/CD pipeline
Using a docker image
If you run into any issues during the installation process, feel free to contact us.
2.1 Local installation
2.1.1 Standalone:
Find the latest GitHub releases to download a standalone executable here.\
Command example for Linux:
Command example for Windows:
Command example for MacOS:
2.1.2 Installation using Go
Requirements:
Local compilation of Debricked CLI requires Go to be installed on your system. In order to check whether you already have the compiler installed on your device, run the command ‘go version’ on your terminal. If there is no command available, install the Go compiler.
Installation:
Install Go on your operating system following the official documentation
Clone the CLI repository to your local directory: https://github.com/debricked/cli
2.2 Adding the CLI to your CI/CD pipeline
The CLI can be integrated into your continuous integration (CI) to run scans on the pipeline. You can integrate using:
Docker image
Binary standalone
2.2.1 Using the docker debricked/cli image
Log in to debricked.com/app and follow the steps to generate an access token.
Set your access token, named
DEBRICKED_TOKEN
, as an environment variable within your continuous integration (CI). If you don’t know how to configure your environment variable, check our documentation for the most common CI integrations.Configure a new job in your CI pipeline::
debricked/cli:2-resolution-debian
docker imageRun
debricked scan
Add the
DEBRICKED_TOKEN
as a variable or (if possible) as a secret
See the example below for the GitHub actions integration (see the debricked.yml file):
For more details, please check our sample templates for the integration of your choice.
2.2.2 Using the Standalone
Log in to debricked.com/app and follow the steps to generate an access token.
Set your access token, named
DEBRICKED_TOKEN
, as an environment variable within your continuous integration (CI). If you don’t know how to configure your environment variable, visit our documentation for the most common CI integrations.Configure a new job in your CI pipeline::
Run:
to use the executable Debricked CLI.
Run
debricked scan
.
Here’s an example of the Circle CI integration: circleci/config.yml file. For more examples check out: https://github.com/debricked/cli/tree/main/examples/templates
3. Testing your installation
To confirm whether the installation was successful, run the command ‘./debricked --help’. If you can see the menu as seen below, you are ready to scan your first project!
4. Scan your first project
Once you've installed the CLI, you're ready to scan your project. You can scan a local project allocated on your local machine or a project in a remote repository via a CI integration, follow the instructions below to perform your first scan:
Run
debricked scan --help
to see the main menu and check if the CLI is runningScan your project locally using the command:
debricked scan [path] [options]
The path
is the folder that contains your project's dependency file. See this practical example, scanning a local project:
The path
is the ~/Desktop/myproject/EasyApp
and the options included are the access-token
(required). Since EasyApp is a git repository, no other flags are needed for the scan.
Include some [option]s within your scan:
The commit --commit
specifies the hash commit, and the branch with the command --branch
. Note that --commit
and --branch
are only required when the target path does not contain a git repository.
Another option is to change the directory to a folder that contains your project's dependency file. So you can use "." For example
After the scan is complete, you will see the total number of vulnerabilities found and a list of automation rules that have been evaluated. See the picture below:
You can log in to the Debricked web tool to see the scan results, by following the link with all the details.
5. List of Commands
These are the main commands for the Debricked CLI:
Command | Description |
---|---|
help | Display options. |
scan [path] [access-token] [flags] | Upload and check your dependency files for vulnerabilities. |
resolve [path] [flags] | Resolve manifest files. |
files find [path] [access-token] [flags] | Search and print the dependency files. |
report [command] [access-token] [flags] | Generate a report and send it by email. |
callgraph [path] [flags] | Generate a static callgraph for a project. |
fingerprint [[path] [flags]] | Fingerprint files. |
help
debricked [command] --help
Type debricked –-help
to display the main menu.
To display the options on any command just execute the [command], followed by the --help
option. For example, type debricked scan -–help
to list the options for the scan command.
scan
debricked scan [path] [flags]
debricked scan –-help
to see all the options.
The scan command uploads and check your dependency files for open-source vulnerabilities and license compliance.
Path:
Use the path argument to specify which directory the dependency file is in, or to exclude it. For example:
debricked scan ~/Desktop/Coder-2022/Eccomerce2/ -t <token>
.Use the path to specify where the dependency file is allocated, you can use "." to search the current working directory. For instance:
debricked files find . -t <token>
ordebricked files find ~/Desktop/Coder-2022/Eccomerce2/ -t <token>
Flags
-t --access-token
Required
Use this parameter to authenticate. Run -t
, or --access-token
and enter your access token created in the authentication. Example: --access-token <token>
-e, --exclusions
Optional
Use this command to exclude files or folders you don't want to be scanned for some reason. The following terms are supported to exclude paths:
"*": matches any sequence of non-Separator characters.
"/**/": matches zero or multiple directories.
"?": matches any single non-Separator character.
"[class]": matches any single non-Separator character against a class of characters
"{alt1,...}": matches a sequence of characters if one of the comma-separated alternatives matches.
Examples: -e "*/**.lock"
, -e "**/node_modules/**"
, -e "*/**.exe
, -e "**/node_modules/**
You can use this command to ignore multiple terms. For example: debricked files find . -e "**/node_modules/**" -e "**/package-lock.json"
Default: in case you don’t provide this parameter will be set by default to ignore the “node_modules”, "vendor", and “.git”
-b, --branch
Optional
Use this parameter to specify the branch to analyze in your project. For example: -–branch main
Default: if you don’t provide this parameter will be set by default to scan all the branches.
-c, --commit
Optional
Use this parameter to specify the commit to analyze in your project. Type -–commit
followed by the hash commit. Example: --commit 2609d8385125ddd2d7aa4cfb5be8fcd392e3280a
.
Default: if you don’t provide this parameter, Debricked will scan the last commit.
-i, --integration
Optional
Use this parameter to specify the name of the integration used to trigger the scan. For example --integration “GitHub Actions”
Default: if you don’t provide this parameter, it will be set to “CLI” by default
-p, --pass-on-timeout
Optional
Use this parameter to pass scans if there is a service access timeout
-r, --repository
Optional
Use this parameter to specify the name of the repository to analyze. For example: --repository EasyApp
-u, --repository-url
Optional
Use this parameter to specify the URL address of the repository to analyze. For example:--repository-url https://github.com/nordisk/myrepository
--no-resolve
Optional
When scanning, the High Performance resolution is enabled by default. Use this parameter to disabled it if needed. See here for more details about the High Performance Scan.
More examples:
In this example, we analyze all the dependencies files in our current directory. The “.” starts the scanning in the current working directory.
In this example, we are going to scan a project called “EasyApp” in the local directory “~/Desktop/myproject/EasyApp”:
resolve
debricked resolve [path] [flags]
debricked resolve –help
to see all the options.
The resolve command resolves manifest files to lock files. See here for more details about the High Performance Scan.
Path:
Use the path argument to specify what manifest file to resolve or what directory to resolve manifest files in. For example:
debricked resolve ~/Desktop/Coder-2022/Eccomerce2/ -t <token>
ordebricked resolve ~/Desktop/Coder-2022/Eccomerce2/pom.xml -t <token>
.
Flags:
-t --access-token
Optional
Use this parameter to authenticate to enable a higher rate limit. Run -t
, or --access-token
and enter your access token created in the authentication. Example: --access-token <token>
-e, --exclusions
Optional
Use this command to exclude files or folders you don't want to be scanned for some reason. The following terms are supported to exclude paths:
"*": matches any sequence of non-Separator characters.
"/**/": matches zero or multiple directories.
"?": matches any single non-Separator character.
"[class]": matches any single non-Separator character against a class of characters
"{alt1,...}": matches a sequence of characters if one of the comma-separated alternatives matches.
Examples: -e "*/**.lock"
, -e "**/node_modules/**"
, -e "*\**.exe
, -e "**\node_modules\**
You can use this command to ignore multiple terms. For example: debricked files find . -e "**/node_modules/**" -e "**/package-lock.json"
Default: in case you don’t provide this parameter will be set by default to ignore the “node_modules”, "vendor", and “.git”.
--verbose
Optional
Use the this flag to toggle verbosity in error output for resolution, this mainly applies to the error output provided from the package managers which the Debricked CLI calls (i.e "external" errors) when resolving. For example --verbose=false
to get less verbose error messaging.
Default: If you don’t provide this parameter, it will be set to “true” by default.
--resolution-strictness int
Optional
Use the this flag to configure exit codes for resolution, depending on the success of the command:
- 0 (default) - Always exit with code 0, even if any or all files failed to resolve
- 1 - Exit with code 1 if all files failed to resolve, otherwise exit with code 0
- 2 - Exit with code 1 if any file failed to resolve, otherwise exit with code 0
- 3 - Exit with code 1 if all files failed to resolve, if any but not all files failed to resolve exit with code 3, otherwise exit with code 0
--regenerate int
Optional
Use the this flag to toggle regeneration of already existing lock files between 3 modes. This is useful for when you use the resolve command to generate lock files permanently in your project and would like to ensure that they are kept up to date before every scan.
- 0 (default) - No regeneration
- 1 - Regenerates existing non package manager native Debricked lock files
- 2 - Regenerates all existing lock files
--prefer-npm
Optional
This flag allows you to use npm instead of yarn (which is default) when resolving package.json files without lock files.
files find
debricked files find [path] [flags]
debricked files find –-help
to see all the options.
Use this command to search all the dependencies files in your project.
Path:
Use the path argument to specify which directory the dependency file is in, or to exclude it. For example:
debricked files find ~/Desktop/Coder-2022/Eccomerce2/ -t <token>
.Use the path to specify where the dependency file is allocated, you can use "." to search the current working directory. For instance:
debricked files find . -t <token>
ordebricked files find ~/Desktop/Coder-2022/Eccomerce2/ -t <token>
.
Note: If the path is inside a git repository, all the necessary flags branch, commit, etc) will be set for you automatically.
Flags:
-l, --lockfile
Optional
Use this parameter to find only the lock files in your project.
-j, --json
Optional
Use this parameter to print the file from the path in JSON format. Here’s an example, where we look for all the dependency files in the folder “project7” and print them in JSON format.
Output:
-s, --strict int
Allows controlling which files are matched:
- 0 (default) - returns all matched manifest and lock files regardless if they're paired or not
- 1 - returns only lock files and pairs of manifest and lock-file
- 2 - returns only pairs of manifest and lock-file\
workspaces:
Since release v2.0.7 files find
support workspaces for npm and yarn. Nothing additional is needed to make workspaces work, but in addition to the official format we also support nesting the workspace patterns under a packages
key. Examples:
For specific documentation on using workspaces with npm see the npm workspace documentation, and for yarn see the yarn workspace documentation.
report
report license
Note that this feature is only available for premium users. Visit our Pricing page for more info.
Example**:**
Flags
-t --access-token
Required
Use this parameter to authenticate. -t
, or --access-token
and enter your access token created in the authentication. For example: --access-token <token>
-c, --commit
Required
Use this parameter to specify the hash commit of the repository to analyze. For example: --commit 2609d8385125ddd2d7aa4cfb5be8fcd392e3280a
-e, --email
Required
Use this parameter to set the email address to which the report will be sent to. For example: --email user1@email.com
report vulnerability
Note that this feature is only available for premium users. Visit our Pricing page for more info.
Example generating a Vulnerability report**:**
Flags:
-e, --email
Required
Use this parameter to set the email address to which the report will be sent to. For example: --email user1@email.com
callgraph
debricked callgraph [[path] [flags]]
debricked callgraph –help
to see all the options.
The callgraph command generates a static callgraph for a project. Execute command in project directory or specify project path.
Path:
Use the path argument to specify the project path. If nothing is provided, the current working directory will be used.
Flags:
e, --exclusions
OptionalSpecify which files or paths you don't want to include in the callgraph. The following terms are supported to exclude paths:
Term Meaning *
matches any sequence of non-Separator characters
/**/
matches zero or multiple directories
?
matches any single non-Separator character
[class]
matches any single non-Separator character against a class of characters ([see "character classes"])
{alt1,...}
matches a sequence of characters if one of the comma-separated alternatives matches
Examples:
-e "**/target/test-classes/**"
,-e "*\\test.class"
You can use this command to ignore multiple terms. For example:
debricked callgraph -e "**/target/test-classes/**" -e "*\\test.class"
--no-build Optional
Do not automatically build all source code in the project. This option requires a pre-built project/available .class files.
--generate-timeout Optional
Sets a timeout (in seconds) on the call graph generation.
Default: If you don’t provide this parameter, it will be set by default to 3600 (1 hour).
Command details:
The command can be divided into three main steps:
Build project
build project based on the root pom.xml. If no root pom.xml is found, all pom.xml files will be built individually.
a successful build will generate the necessary .class files
Copy external dependency files to
.debrickedTmpFolder
in the root pom.xml directoryGenerate call graph
Uses a built version of the Debricked vulnerable functionality project to identify all .class files and map those to the root pom.xml, using the same path as
.debrickedTmpFolder
The generated call graph output is stored in the base64 encoded zip file
.debricked-call-graph
The callgraph command requires at least java11. If your project cannot be built with java11, we would recommend you to build your project in your environment before running the command and use --no-build
flag when generating the call graph.
Common errors:
Build failures
These are likely due to local configurations. If the build step fails, it is recommended to build your project as usual in your environment and skip step 1 above, i.e. just copy external dependencies to
.debrickedTmpFolder
and rundebricked callgraph --no-build
on your built project. Make sure all .class files are available.
Callgraph failures
out of memory
cp dependencies
mapping dependencies
If you see the error above, make sure all .class files are available in the right path and that all external dependencies have been copied to .debrickedTmpFolder
fingerprint
debricked fingerprint [[path] [flags]]
debricked fingerprint –help
to see all the options.
Fingerprint files for identification in a given path and write it to debricked.fingerprints.txt. This hashes all files to be used for matching against the Debricked knowledge base.
Path:
Use the path argument to specify the project path. If nothing is provided, the current working directory will be used.
Flags:
e, --exclusions
OptionalSpecify which files or paths you don't want to include when fingerprinting. The following terms are supported to exclude paths:
Term Meaning *
matches any sequence of non-Separator characters
/**/
matches zero or multiple directories
?
matches any single non-Separator character
[class]
matches any single non-Separator character against a class of characters ([see "character classes"])
{alt1,...}
matches a sequence of characters if one of the comma-separated alternatives matches
Examples:
-e "/.pyc"
,-e "*\\\\test.class"
,-e "**/target/test-classes/**"
You can use this command to ignore multiple terms. For example:
debricked fingerprint -e "/node_modules/" -e "/.egg-info/" -e "/*venv/**"
By default, the following are ignored: /nbproject/,/nbbuild/,/nbdist/,/node_modules/,/pycache/,/_yardoc/,/eggs/,/wheels/,/htmlcov/,/pypackages/,/.egg-info/,/venv/*
-fingerprint-compressed-content Optional
Fingerprint the contents of compressed files by unpacking them in memory, Supported files: [.jar .nupkg .war] default: false
6. Troubleshooting and Error Messages
Below you can find the list of some of the most common error messages. If the problem persists and you can’t solve it for yourself or have additional questions feel free to reach contact our support team.
This error message appears when the access-token is missing or if you provide an invalid access token. For more information, see the `-t -- access-token` command.
This error message appears when you run the `debricked report vulnerability/license` command without a valid email address. To resolve this, use the `--email, -e` [options] to set an email the report should be sent to. For example: `debricked report license -t “<token>” –email ”usuario1@gmail.com”`
This error message appears when you run the `debricked report vulnerability/license` command but the CLI can’t find the commit. To resolve this, use the `--commit, -c` [options] to provide a commit hash.
For example: `debricked report license -t “<token>” –email ”usuario1@gmail.com” –commit 044bdc7c22e46be010969e9360dbe679830100f1`
This error message appears when you run the `debricked report vulnerability/license` command without any commits. To resolve this, use the `--commit, -c` [options] to provide a commit hash.
For example: `debricked report license -t “<token>” –email ”usuario1@gmail.com” –commit 044bdc7c22e46be010969e9360dbe679830100f1`
This error message appears when the scan can't find any valid directory in the path. To resolve it, check if the path provided is correct.
This error message appears when we can't fetch the repository name. To fix this, set a name for the repository, using the -r
flag.
6.1 Getting support
If you need help, contact us via our live chat, open Monday-Friday 9 am-5 pm CET, or email support@debricked.com.
Uninstallation
The only thing that is needed to uninstall is to remove the binary - the file called debricked
or debricked.exe
depending on your operating system.
6.2 Create an issue or report a bug
Before creating an issue or reporting a bug, make sure to contact support and discuss the issue or feedback with us first.
If you want to create an issue or report a bug you can do it directly by submitting an issue via GitHub.
6.3 Upgrading from version 1.X.X to version 2.0.0
The 2.0.0 release contains some breaking changes, documented below:
6.4 Contributors
If you'd like to contribute directly to the project, check out our guide. Keep in mind that it might take us some time to answer your questions. For a better experience, we recommend joining our Portal community, where you can learn more about Debricked, improve the way you use open source, and help others.
Feel free to reach out to any of the maintainers or other community members if you have any questions.
Last updated