Topic 4 of 5 · 4 min read
Licence scanning before merge
Goal: Read a licence scan report on an agent's change and decide which findings block the merge.
Licence scanning runs automatically on a change and lists the licences it finds, so a human only has to decide what each finding means for the product. An agent can add ten dependencies in one pull request. No reviewer reads ten licence files by hand.
Check yourself · 1 of 3
A scan of an agent's pull request flags a package under AGPL-3.0-only, used at runtime in your hosted API, and your policy denies AGPL. What do you do?
Two kinds of scanner
- Dependency checks read manifests and lockfiles. GitHub's dependency review, for example, shows the packages a pull request adds or updates, with their licences, and can fail the check on a deny list. Other package-licence checkers work the same way.
- Source scanners read files. ScanCode Toolkit looks inside the code for licence texts, notices and copyright lines, which catches pasted snippets that no manifest lists.
Use both. A dependency check misses pasted code, and a source scan can be slow on a large tree.
How to read a report
For each finding, answer four questions:
- What licence? Use the SPDX name, and check the scanner got it right.
- Where? A new direct dependency, a transitive one, or a pasted file in
src/. - How do we use it? Shipped, hosted only, dev tool, or test only. A test-only GPL tool is not the same as a GPL library in your binary.
- What does policy say? Allowed, needs approval, or denied.
What blocks a merge
Block on a denied licence in shipped code, on an unknown or missing licence, and on a licence header found in a pasted file. Escalate rather than block when the licence is on the review list, such as LGPL or MPL, and ask legal or the owner of the policy. Let allowed licences pass, but make sure the notices are updated.
Scanners are heuristics. They can report a false match or miss a dual-licence choice. Treat a finding as a lead to check, and a clean report as "nothing found", not "nothing there".
Before and after
Weak: the check is red, so the engineer adds the package to the allow list and merges. Better: the engineer reads that pdf-forge is AGPL-3.0-only, used in the hosted API, which policy denies, and asks the agent to use the approved pdf-lib instead.
What goes wrong
- Allow-listing to get green. It hides the problem and removes the check for next time.
- Scanning only direct dependencies. Transitive packages are in your build too.
- Running the scan after merge. Fixing a licence is cheapest in the pull request.
Examples
Reading a scan result
license-check FAIL
+ pdf-forge 3.4.0 AGPL-3.0-only direct runtime
+ tiny-uuid 1.0.2 MIT direct runtime
+ eslint-plugin-x 0.9 GPL-3.0-only transitive dev only
+ src/vendor/tz.js (no manifest) header: Apache-2.0
pdf-forge blocks: AGPL in a hosted runtime. tiny-uuid passes. The dev-only GPL plugin is not shipped, so it is usually fine but note it. src/vendor/tz.js needs its Apache-2.0 notice and a record of where it came from.
A deny list in CI
- uses: actions/dependency-review-action@v4
with:
deny-licenses: AGPL-3.0-only, AGPL-3.0-or-later, GPL-3.0-only
The agent's pull request now fails before a human opens it if it adds a denied licence. The list itself comes from company policy.
Key points
- Run a dependency check on manifests and a source scan on files; each catches what the other misses.
- For every finding ask which licence, where it is, how you use it, and what policy says.
- Block denied, unknown or missing licences in shipped code and pasted files with licence headers.
- Escalate review-list licences such as LGPL or MPL instead of guessing.
- Never add to an allow list just to turn a check green.
Common mistakes
- Adding a package to the allow list to get a green check.
- Checking only direct dependencies and ignoring transitive ones.
- Treating a clean scan as proof that no licensed code is present.
- Ignoring whether the flagged package is shipped, hosted, or only used in tests.
Check yourself · 2 of 3
Why run a source scanner in addition to a dependency check?
Check yourself · 3 of 3
A scan shows a GPL-3.0-only package that is only a dev dependency used by the linter and is never shipped. What is the most reasonable reading?
Practice items, not counted towards your mastery.
Start here
- Choose a License (opens in a new tab)ArticleFree
Plain summaries of what each common licence permits, requires and forbids.
- SPDX License List (opens in a new tab)DocsFree
The standard short identifiers (MIT, Apache-2.0, GPL-3.0-only) used in headers, manifests and scanners.
- OSI Approved Licenses (Open Source Initiative) (opens in a new tab)DocsFree
The reference list of licences that meet the open source definition, with full texts.
More for this topic
- ScanCode Toolkit (opens in a new tab)ToolFree
An open-source scanner that detects licences, copyrights and dependencies in a code tree.
- About dependency review (GitHub Docs) (opens in a new tab)DocsFree
How a pull request check shows added dependencies, their licences and known vulnerabilities.