The Wild

Black Duck Detect: What It Finds in Your Code

· 6 min read · Birds

In this article
  1. What Black Duck Detect Actually Scans For
  2. Running a Black Duck Detect Scan Step by Step
  3. A Worked Example: One Project, Three Findings
  4. Where Black Duck Detect Scans Go Wrong
  5. Reading the Report and Deciding What to Fix First

Black Duck Detect is a command-line scanning tool that inspects a codebase and reports the open-source components inside it, along with their licenses and known vulnerabilities. It works by matching files and package manifests against a hosted knowledge base of open-source projects rather than reading your source line by line. You run it, it produces a report, and you act on the findings before a release.

What Black Duck Detect Actually Scans For

Detect looks for two different things and reports them separately. The first is declared dependencies: the entries in your package manifests and lock files, such as package-lock.json, pom.xml, build.gradle, requirements.txt, go.mod, Gemfile.lock, and similar files. These are read directly, so the version recorded there is the version reported.

The second is undeclared or bundled code: files copied into your repository without a manifest entry. Detect hashes files and matches those signatures against the knowledge base, which is how it catches a vendored library sitting in a vendor or third_party folder. This is the part that surprises people, because a scan can report components nobody on the team remembers adding.

For each match you get the component name, the version, the license, and any published vulnerabilities tied to that version. The output formats include a plain text summary, JSON, and a report you can archive with a build.

Running a Black Duck Detect Scan Step by Step

Detect needs a connection to a Black Duck server or to the hosted service, plus credentials, so the first run is mostly configuration. Expect the initial setup to take longer than the scans that follow.

  1. Install the tool. Download the Detect script or jar from your Black Duck instance and place it somewhere on the build machine's path. Keep the version pinned so results stay comparable between runs.
  2. Set the connection details as environment variables: the server URL, an API token, and the trust certificate if your instance uses a private certificate authority. Labels differ slightly by version, so check the tool's own help output for the exact variable names.
  3. Choose the scan mode. A full scan hashes files and searches for signatures; a quick scan reads manifests only. Use the full scan when you suspect vendored code, and the quick scan for fast feedback on pull requests.
  4. Point Detect at the directory. Run it from the repository root so it walks the whole tree, and pass an exclude pattern for build output, test fixtures, and generated assets. Scanning a node_modules folder or a compiled dist directory adds noise and time without adding findings.
  5. Run the scan and watch the log. Detect prints each detector it invokes and each component it extracts. A run over a mid-sized repository typically finishes in a few minutes; a large monorepo can take considerably longer, so give it a generous timeout in CI.
  6. Read the report. Start with the vulnerability list sorted by severity, then the license list. The component inventory is the reference you return to when a question comes up later.

Making the scan repeatable in a build pipeline

Run Detect as a step after dependency installation and before packaging, so the lock files are final. Fail the build on a policy violation rather than on any finding at all, otherwise the first scan of an old repository blocks everything and the team starts ignoring the results. A workable policy is to fail on components with a known critical vulnerability and on licenses outside an approved list, while reporting everything else for review.

A Worked Example: One Project, Three Findings

Suppose a small service has a package-lock.json listing 40 packages, plus a single JavaScript file copied from a charting library into src/vendor/ two years ago. A full Detect scan reports 41 components: the 40 declared ones and the vendored charting library, identified by its file hashes.

The report shows three items worth acting on. One declared package carries a published vulnerability rated high, so you upgrade it to a fixed version and rescan; the finding clears because the new version has no matching advisory. The vendored charting file carries a permissive license, so it stays, but you add a note recording where it came from and which version it matches. A third package uses a copyleft license that your policy disallows for distributed code, so you either replace it with a permissively licensed alternative or confirm with your legal contact that the distribution model is acceptable.

The arithmetic matters here: 41 components scanned, 3 requiring action, 38 cleared. That ratio is normal for a first scan. What changes between runs is the number of new findings, which should be small once the backlog is cleared.

Where Black Duck Detect Scans Go Wrong

The most common failure is scanning the wrong directory. Running Detect from a subfolder, or from a directory that includes a copied build tree, produces a report that either misses components or lists duplicates of the same library at several versions. Run from the repository root and exclude generated folders explicitly.

A second failure is trusting a manifest-only scan to find vendored code. Quick scans read manifests and nothing else, so a library copied into the source tree is invisible to them. If your policy requires a complete inventory, the full scan is the one that counts.

A third is treating an empty vulnerability list as proof of safety. Detect reports what is published against the exact versions it matched. A component with no advisory today can gain one next week, which is why the scan belongs in the pipeline as a recurring step rather than a one-off audit.

One misconception deserves a direct correction: Detect does not audit your own source code for bugs. It identifies third-party components and their known issues. Static analysis of your own code is a different tool doing a different job, and a clean Detect report says nothing about the quality of the code you wrote.

Reading the Report and Deciding What to Fix First

Sort by severity, then by whether the vulnerable component is reachable in production. A critical advisory in a test-only dependency is a lower priority than a medium advisory in a library that parses untrusted input on every request. Fix the reachable ones first, and record a decision for the rest so the next scan does not reopen the same discussion.

For licenses, keep an approved list and check new components against it at the point they are added, not months later. Copyleft licenses in distributed code and permissive licenses in internal tools carry very different obligations, and the report gives you the license name per component so you can apply the rule without guesswork.

Keep the JSON output from each run. Comparing two reports shows exactly which components and versions changed between releases, which is far faster than re-reading a full inventory. If a finding's status is unclear, check the advisory against the component's own release notes and confirm the fixed version before upgrading.