segrep-license scanner
Opt-in license compliance scanner with SPDX risk classification
Opt-in license compliance scanner for Segrep that classifies dependency licenses by risk and flags copyleft or unknown licenses in your project.
Why use segrep-license
- Detects copyleft and unknown licenses in your dependency tree before they reach production.
- Classifies every SPDX license into risk tiers: permissive (low), weak-copyleft (medium), strong-copyleft (high), unknown (medium).
- Supports
MIT OR Apache-2.0dual-license expressions and{ "type": "MIT" }object formats. - Runs locally with no external API calls — fast, offline, and CI-friendly.
Scanner behavior
segrep-license runs as an opt-in scanner.
pnpm segrep scan . --scanners segrep-licenseIt scans:
- Root
package.jsonlicense field - All
node_modules/*/package.jsonlicense fields - Scoped packages under
node_modules/@scope/*/package.json
License classification
| Risk | Severity | Examples |
|---|---|---|
| Permissive | low | MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC, CC0-1.0, Unlicense |
| Weak copyleft | medium | LGPL-2.1, LGPL-3.0, MPL-2.0, EPL-1.0, EPL-2.0, CDDL-1.0 |
| Strong copyleft | high | GPL-2.0, GPL-3.0, AGPL-3.0, EUPL-1.2, SSPL-1.0 |
| Unknown | medium | Any SPDX ID not in the classification database |
When a package uses a dual license expression (e.g., MIT OR Apache-2.0), the scanner picks the worst-case license for severity classification.
Finding output
Each finding includes:
packageNameandinstalledVersionfrom the package manifestruleIdset to the classified SPDX license identifiercategoryset tolicensesnippetcontaining the raw license string from the manifest
Example finding:
{
"id": "segrep-license:lodash@4.17.21:MIT",
"title": "Permissive license detected in lodash@4.17.21",
"severity": "low",
"packageName": "lodash",
"installedVersion": "4.17.21",
"ruleId": "MIT",
"category": "license",
"snippet": "MIT"
}Policy integration
Use .segrep/policy.yml to control license scanner behavior:
scanners:
- segrep-license
# Allowlist known-good licenses by SPDX ID
allowlist:
- MIT
- Apache-2.0
# Ignore paths that are not shipped to production
ignore_paths:
- "**/*.test.ts"
- "fixtures/**"Examples
Scan only for license compliance:
docker run --rm -v "$(pwd):/repo:ro" security-scanner:local \
scan /repo --scanners segrep-licenseCombine with dependency vulnerability scanning:
docker run --rm -v "$(pwd):/repo:ro" security-scanner:local \
scan /repo --scanners segrep-vuln,segrep-license --format jsonFail CI on any strong copyleft license (high severity):
docker run --rm -v "$(pwd):/repo:ro" security-scanner:local \
scan /repo --scanners segrep-license --fail-on highLimitations
- Only scans npm ecosystem packages (
package.jsonmanifests). - Does not scan
go.mod,Cargo.lock,Gemfile.lock, or other non-npm ecosystems. - License classification is based on a curated SPDX database; unknown licenses are flagged as medium severity rather than silently ignored.
Related docs
- Product scan guide
- Docker image reference
- Add a scanner
- segrep-secrets — native secret detection