Skip to content

Commit 4e73b1e

Browse files
committed
Tighten dependency license policy
1 parent db8acc9 commit 4e73b1e

File tree

7 files changed

+72
-35
lines changed

7 files changed

+72
-35
lines changed
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
# Keep the initial policy focused on risky dependency changes first.
2-
# If you want stricter license enforcement later, add allow-licenses here.
2+
# This allowlist is intentionally based on the licenses already present in the
3+
# current dependency tree so normal updates do not become noisy immediately.
34
fail-on-severity: high
45
fail-on-scopes:
56
- runtime
67
- unknown
78
license-check: true
9+
allow-licenses:
10+
- Apache-2.0
11+
- Apache-2.0 AND LGPL-3.0-or-later
12+
- Apache-2.0 OR BSD-2-Clause
13+
- BSD-2-Clause
14+
- BSD-3-Clause
15+
- BlueOak-1.0.0
16+
- CC-BY-4.0
17+
- CC0-1.0
18+
- ISC
19+
- MIT
20+
- MPL-2.0
21+
- PSF-2.0
22+
- Python-2.0
23+
- 0BSD

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ That command writes generated reports into `reports/licenses/`.
9797

9898
Dependency review also runs automatically on pull requests to catch newly introduced vulnerable dependency changes.
9999

100+
That dependency review config also includes an allowlist for the licenses already present in the current dependency tree. If you intentionally add a dependency under a new acceptable license, update `.github/dependency-review-config.yml` in the same pull request.
101+
100102
## Changing the API Contract
101103

102104
If you modify request or response shapes:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ Pull requests also run GitHub dependency review so new vulnerable dependency cha
127127

128128
A separate GitHub workflow generates license-report artifacts for the root workspace, frontend workspace, and backend Python environment.
129129

130+
The dependency-review config also keeps a conservative allowlist of licenses already present in the current dependency tree, so tightening policy does not start by breaking routine updates.
131+
130132
## Releases
131133

132134
- Release Drafter keeps a draft release updated from merged pull requests on `main` and can auto-label incoming pull requests by path.

SECURITY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ The repository also uses automated scanning to help catch common security issues
3434
- GitHub dependency review on pull requests for newly introduced vulnerable dependency changes
3535
- GitHub license-report artifacts for npm and Python dependency inventories
3636

37+
Dependency review is also configured with an allowlist that matches the current dependency tree, so changes that introduce new license types are surfaced deliberately instead of silently drifting in.
38+
3739
Those checks do not replace private disclosure. If you believe a vulnerability is real or
3840
exploitable, please still report it through a private advisory.
3941

backend/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ build-backend = "hatchling.build"
66
name = "nextjs-python-computer-vision-kit-backend"
77
version = "0.1.0"
88
description = "FastAPI backend for the computer vision starter kit."
9+
license = "MIT"
910
readme = "README.md"
1011
requires-python = ">=3.12"
1112
dependencies = [

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "frontend",
33
"version": "0.1.0",
44
"private": true,
5+
"license": "MIT",
56
"scripts": {
67
"dev": "next dev",
78
"build": "next build",

scripts/report-licenses.mjs

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -48,50 +48,63 @@ function writeReport(filename, content) {
4848
writeFileSync(outputPath, normalized, "utf8");
4949
}
5050

51+
function summarizeNpmLicenses(rawJson) {
52+
const data = JSON.parse(rawJson);
53+
const counts = new Map();
54+
55+
for (const item of Object.values(data)) {
56+
const license = item.licenses ?? "UNKNOWN";
57+
counts.set(license, (counts.get(license) ?? 0) + 1);
58+
}
59+
60+
return [...counts.entries()]
61+
.sort((left, right) => {
62+
if (right[1] !== left[1]) {
63+
return right[1] - left[1];
64+
}
65+
66+
return left[0].localeCompare(right[0]);
67+
})
68+
.map(([license, count]) => `${count.toString().padStart(3, " ")} ${license}`)
69+
.join("\n");
70+
}
71+
5172
const backendPython = resolvePythonCommand(backendDir);
5273

5374
rmSync(reportDir, { recursive: true, force: true });
5475
mkdirSync(reportDir, { recursive: true });
5576

56-
writeReport(
57-
"root-npm.json",
58-
runAndCapture(
59-
"npx",
60-
[
61-
"--yes",
62-
npmLicenseTool,
63-
"--json",
64-
"--relativeLicensePath",
65-
"--relativeModulePath",
66-
],
67-
root,
68-
),
77+
const rootNpmJson = runAndCapture(
78+
"npx",
79+
[
80+
"--yes",
81+
npmLicenseTool,
82+
"--json",
83+
"--excludePrivatePackages",
84+
"--relativeLicensePath",
85+
"--relativeModulePath",
86+
],
87+
root,
6988
);
7089

71-
writeReport(
72-
"root-npm-summary.txt",
73-
runAndCapture("npx", ["--yes", npmLicenseTool, "--summary"], root),
74-
);
90+
writeReport("root-npm.json", rootNpmJson);
91+
writeReport("root-npm-summary.txt", summarizeNpmLicenses(rootNpmJson));
7592

76-
writeReport(
77-
"frontend-npm.json",
78-
runAndCapture(
79-
"npx",
80-
[
81-
"--yes",
82-
npmLicenseTool,
83-
"--json",
84-
"--relativeLicensePath",
85-
"--relativeModulePath",
86-
],
87-
frontendDir,
88-
),
93+
const frontendNpmJson = runAndCapture(
94+
"npx",
95+
[
96+
"--yes",
97+
npmLicenseTool,
98+
"--json",
99+
"--excludePrivatePackages",
100+
"--relativeLicensePath",
101+
"--relativeModulePath",
102+
],
103+
frontendDir,
89104
);
90105

91-
writeReport(
92-
"frontend-npm-summary.txt",
93-
runAndCapture("npx", ["--yes", npmLicenseTool, "--summary"], frontendDir),
94-
);
106+
writeReport("frontend-npm.json", frontendNpmJson);
107+
writeReport("frontend-npm-summary.txt", summarizeNpmLicenses(frontendNpmJson));
95108

96109
writeReport(
97110
"backend-python.json",

0 commit comments

Comments
 (0)