Safeguard
Security Guides•

How do scanners detect licenses: manifest, file text or snippet matching?

Scanners read declared metadata, match license file text, or compare code snippets. Each method has different strengths and failure modes. A comparison.

Safeguard Security Team
3 min read

License scanners use three methods. Manifest reading takes the declared license from package metadata. File text matching reads LICENSE files and compares them with known texts. Snippet matching compares code fragments with known sources. Manifests are fastest, file matching is more grounded, and snippets catch copied code the others miss.

The three methods

MethodHow it worksStrengthWeakness
Manifest or metadataReads the license field, expression or classifierFast, structured, scalableAuthor's claim, can be wrong or empty
File text matchingFinds files such as LICENSE or COPYING and matches textCloser to what was actually grantedEdited text, odd file names, multiple licenses
Snippet matchingCompares code fragments with a corpusFinds copied code with no metadataHeavier, false positives, depends on corpus

What the documentation tells us

Ecosystem docs show how uneven metadata is. npm accepts an SPDX identifier, an expression, a pointer to a custom file, or UNLICENSED. Python moved to a validated License-Expression field after years of free text and classifiers. Go has no field at all, and the Go package site states plainly that its file based detection is a heuristic with no accuracy guarantee. A good scanner combines methods and says which one produced each answer.

How to choose and combine

  1. Use manifest data as the first pass for every dependency.
  2. Verify with file text for anything your policy treats as sensitive.
  3. Use snippet matching where copied code is likely: vendored folders, acquired code, AI generated code you cannot trace.
  4. Keep the confidence level next to each result, so reviewers know what was inferred.
  5. Send disagreements between methods to manual review.

Questions to ask a tool

Does it parse expressions with AND, OR and WITH? Does it show where each answer came from? Can you override a wrong result and keep the override? Does it scan vendored folders and container layers? See SCA license detection: what to expect for more.

Try it yourself

Click through it at your own pace, or open it full screen.

Look at which metadata an inventory entry carries and think about which method would produce it.

Be wary of single number accuracy claims for any detector. Accuracy depends on your ecosystems, your vendored code and how many odd licenses you have. Test a tool on a sample of your own repositories, compare its answers with a manual review of twenty or thirty packages, and look at the disagreements. That gives you a more honest picture than a headline figure.

Safeguard offers SBOM and dependency scanning. A free scan lets you judge the output on your own code.

Quick check

Which method is most accurate?

None alone. Combine them and keep confidence labels.

Why not trust the declared license field?

It is the author's claim. It can be empty, outdated or inconsistent with the license file.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.