Running a component scan using the Signature Scanner command line
You run a component scan to identify the components contained in an archive or a directory of files.
The usage is:
scan.cli.bat [parameter1]...[parameterN]...<scan_path>
Parameter | Description |
---|---|
-?, --help | Shows help for this tool. |
<scan_path> | Path to the file directory location or archive that you want to scan. |
--bdio2 |
Use BDIO 2's JSON-LD format for storing and transmitting scan evidence to the Black Duck server. |
--binaryAllowedList <file extensions> --sourceAllowedList <file extensions> |
Use to create approved signature lists.
|
--cloneFrom <version> |
Specifies the name of an existing project version to use as a clone. To clone a project version, use the:
For example, to clone version 1.0 of project SampleProject to a new version called 2.0, you would include these parameters:
|
--context <context> | Additional URL context. Use this parameter, for example, if the X-Forwarded-Prefix header is being specified in a proxy server/load balancer configuration. |
--copyright-search | Enables copyright text detection. |
--correlationId <value> | Used by the Black Duck system to provide the ability to correlate results from different types of scan (package manager scan and signature scan) for the same code location to improve the reliability of results. |
--dryRunReadFile <data directory> | Specifies the directory, including the file name, from a dryRun scan and posts the scan to the Black Duck server. |
--dryRunWriteDir <data directory> | Specifies the directory to which the scanner outputs a
BDIO file with the original file metadata used for scanning. The scanner
does not connect to or post the scan to the Black Duck server. Note that the
data directory is created inside the specified
directory. |
--exclude <pattern> --exclude-from <Filename> |
Excludes a directory or several directories from scanning. The scanner automatically excludes these directories and the contents of these directories:
The scanner automatically excludes files named:
To exclude other directories, use --exclude to exclude a single directory; --exclude-from to specify a file that lists directories that should be excluded. Exclusion guidelines:
There are two additional methods you can use to exclude directories from scanning:
You must also follow the exclusion guidelines as described above when using either of these methods. Tip: Use the debug parameter when excluding
directories to ensure that the scanner visited and excluded the
directory.
|
--fs-wait-time <number of minutes> |
Number of minutes the scan client waits for the File System scan (signature scan) to be in either the completed or error status before starting the snippet or string search scan. Must be a positive integer number. |
--host <host> | Server hosting the Black Duck installation. |
--individualFileMatching <option> |
Individual file matching is the identification of a component based purely upon the checksum information of a single file. By default, individual file matching is disabled. To enable individual file matching, select one of the following options:
Any other value will be ignored and individual file matching will remain disabled. Click here for more information on using this parameter with approved signature lists. |
--insecure | Ignores TLS validation errors, allowing the scanner to connect to the Black Duck server. |
--license-search | Enables searching for embedded licenses. |
--logDir <log directory> |
Location of the |
--matchConfidenceThreshold <value> | Specify the match confidence threshold as a percentage value between 1 - 100. A low value returns more matches; whereas a high value returns fewer matches. |
--max-request-body-size <size> --max-update-size <size> |
Controls how scan data is streamed (buffered) from the Signature Scanner to Black Duck. In rare cases, you may need to modify these values to better suit your network, for example, decreasing the values if there are issues with your network or increasing the default values if your network is highly stable.
|
--min-scan-interval=<time in hours> |
Minimum scan interval setting (in hours), which may be used to limit daily rate of the signature scan for given code location. If set to greater than 0, signature scans will not be processed if they occur before the set scan interval. |
--name <scan name> |
Unique name identifying this scan. This name is displayed on the Scans page. Click here for more information. Note: The --name parameter is not supported when specifying
multiple scan paths in a single command line.
|
--no-prompt |
Non-interactive mode. Instead of the --no-prompt parameter, you can set the BD_HUB_NO_PROMPT environment variable to enable non-interactive mode. |
--no-signature-generation | Use the traditional Signature Scanner instead of the Enhanced Signature Generation. |
--password <password> |
Forces the scanner to prompt you for the password for the user account with the code scanner role:
Set the BD_HUB_PASSWORD environment variable with the Black Duck server password instead of passing an argument to the --password parameter:
Important: Set the BD_HUB_PASSWORD environment variable with the Black Duck server password. If you supply the
password parameter, an error message appears and the scan
will not complete.
If this environment variable is not set, the scanner prompts you for the password whether you include or omit the --password parameter. Note: If the password parameter is the parameter immediately before
<scan_path> use -- to indicate you are finished
passing parameters, for example
--password --
<scan_path> . Otherwise, the scanner will try to use
the <scan_path> value as the password.Instead of specifying a username and password, use the BD_HUB_TOKEN environment variable to specify a Black Duck API token. |
--port <port> |
Port on which the Black Duck server instance is listening. |
--project <project> |
Name of the project to which you want to map the scan results. If you specify a project, you must specify a version.
|
--project-group <project group name> |
Assigns the project to the designated project group. If the project does not already exist, it is created in the corresponding project group. This parameter has no effect if the project already exists or if the specified project group does not exist. |
--release<release> |
Name of the project version to which you want to map the scan results. If you specify a version, you must specify a project.
|
--retain-unmatched-files --discard-unmatched-files |
Used to retain or discard, respectively, any unmatched files discovered by this scan and this scan only. If either option is supplied, project and global retention settings are ignored; otherwise, retention is determined by project or global settings as described in "Settings". Specifying both options with a single scan is an error. |
--scheme <scheme> |
Protocol to use to connect to the server hosting the Black Duck installation. Possible values are
http or https; https is the default value. You must include
|
--statusWriteDir <directory> | Specifies the directory to which the scanner outputs a JSON file which contains the complete scan status information. |
--selfTest | Performs a self-test; will not connect to or post the scan to the Black Duck server. |
--snippet-matching --snippet-matching-only --snippet-matching-all-source --full-snippet-scan |
Select one of the following for snippet matching:
To upload source files, you must use the --upload-source parameter, as described below. |
--tlscertpass |
Forces the scanner to prompt you for the password for the client certificate. You can specify the --tlscertpass parameter and/or set the BD_HUB_CLIENTCERT_PASS environment variable which specifies the private key password for the client certificate, for example, when --tlscert points to an encrypted PKCS #12 key store. The result of specifying the --tlscertpass parameter depends on whether the key is encrypted.
|
--tlskey <keyFile> |
Black Duck client certificate private key file. Automatically sets --scheme to https. Note: This parameter is optional as the key and certificate can be in
included in the key store file specified with
--tlscert.
|
--tlscert <certFile> |
Black Duck client certificate chain file or key store file. Automatically sets --scheme to https. Click here for more information on using certificate-based authentication. |
--upload-source |
Uploads the source file, an optional feature for snippet matching, embedded license search, and copyright text search. This parameter is optional with the --snippet-matching or --snippet-matching-only parameters or with the --license-search and/or --copyright-search parameters. |
--username <username> |
Black Duck user account with the code scanner role. Instead of specifying a username and password, use the BD_HUB_TOKEN environment variable to specify a Black Duck API token. |
-V, --version | Shows the version information of this tool. |
-v, --verbose | Sets the logging level to verbose. |
--debug | Shows debug output. |
Other environment variable:
|
Used to specify the Black Duck API token which is the preferred authentication method over username and password. Use the Profile page in the Black Duck UI or the api-token-rest-server API to manage API tokens. |
Specifying the password
Set the BD_HUB_PASSWORD environment variable with the Black Duck server password. If you supply the password parameter, the scan will not complete.
About package management files
By default, the scanner does not include components declared in supported package management files. Use Black Duck Detect to discover declared dependencies.
Exit Statuses
The possible exit statuses are:
-
0: SUCCESS. The export completed successfully.
-
1: FAILURE. Generic failure.
- 2: NOT_EXECUTED. Returned by the scan client when the configured minimum scan
interval is not exceeded and the scan was not executed. See the
--min-scan-interval
command line argument above for additional details. -
64: USAGE. The command to run the tool was used incorrectly, for example, with the wrong number of arguments or a bad syntax.
-
65: DATA_ERROR. The input data was incorrect.
-
66: NO INPUT. An input file (not a system file) did not exist or was not readable.
-
67: NO_USER. The specified user does not exist.
-
68: NO_HOST. The specified host does not exist.
-
69: UNAVAILABLE. A service is unavailable.
-
70: SOFTWARE. An internal software error has been detected.
-
71: OS_ERROR. An operating system error has been detected.
-
72: OS_FILE. A system file does not exist, cannot be opened, or has some sort of error, for example a syntax error.
-
73: CANNOT_CREATE. An output file cannot be created.
-
74: IO_ERROR. An error occurred while doing input/output on a file.
-
75: TEMPORARY FAILURE. Temporary failure,
-
76: PROTOCOL. The remote system returned something that was "not possible" during a protocol exchange.
-
77: NO_PERMISSION. You did not have sufficient permission to perform the operation.
-
78: CONFIGURATION. Something was found in an unconfigured or misconfigured state.
-
79: NO_REGISTRATION. Registration to Black Duck or Protex was not valid.
You can also find more information about these exit codes here.
Examples
The following are examples of using the command line to run the Signature Scanner CLI.
-
Scanning and sending scan data toBlack Duck
-
Scanning and mapping the scan data
Note that:
-
In all examples, the user has a code scanner role. Contact your Black Duck administrator for more information.
-
The examples show only required parameters.
To scan and send the scan data to Black Duck:
-
Open a command prompt.
-
Go to the directory where the Signature Scanner is installed.
For example:
Linux/MAC OSX:
/opt/blackduck/hub/scan.cli-2024.7.3/scan.cli-2024.7.3/bin
Windows:
C:\scan.cli-2024.7.3\scan.cli-2024.7.3\bin
-
Run the following command to configure and initiate the scan.
For example:
Linux/Mac OSX:
./scan.cli.sh --username <username> --host <host> --port <port> <scan_path>
Windows:
scan.cli.bat --username <username> --host <host> --port <port> <scan_path>
The Signature Scanner sends the scan data to Black Duck's server. Log in to Black Duck to map the component scan to a project, which adds the identified components to the project BOM.
To scan over HTTPS, sending the scan data to Black Duck, and automatically mapping scan to a project:
-
Open a command prompt.
-
Go to the directory to which the scanner is installed.
Linux/MAC OSX:
/opt/blackduck/hub/scan.cli-2024.7.3/scan.cli-2024.7.3/bin
Windows:
C:\scan.cli-2024.7.3\scan.cli-2024.7.3\bin
-
Run the following command to configure and initiate the scan.
Linux/Mac OSX:
./scan.cli.sh --username <username> --host <host> --port <port> --scheme HTTPS --project <project> --release <release> <scan_path>
Windows:
scan.cli.bat --username <username> --host <host> --port <port> --scheme HTTPS --project <project> --release <release> <scan_path>
The Signature Scanner sends the scan data to the Black Duck server and automatically maps the scan to the version of the project you specified.