Skip to content

Commit 3908d52

Browse files
Introduce automated license check reviews
In this PR we introduce the option to use our license check tool, "dash-licenses", in "Automatic IP Team Review Requests" mode [1]. In this mode, any dependency that's found to have an unclear or suspicious license will be automatically submitted to the Eclipse Foundation for review. Each such dependency will have a ticket opened on the Foundation's Gitlab and be automatically reviewed. If the automated review is not conclusive, a manual assessment will be performed by the Foundation's IP team. In our experience, most dependencies are approved automatically within minutes. To perform a license check with automated reviews, use the new script: $> yarn license:check:review To perform the license check without the automated review, do as before: $> yarn license:check Note: for review mode to work, a Personal Access Token from the Foundation's Gitlab is required, created from a project committer's Gitlab profile. Set it in an environment variable named "DASH_LICENSES_PAT". E.g. in bash: $> export DASH_LICENSES_PAT=<token> [1] https://github.com/eclipse/dash-licenses#automatic-ip-team-review-requests Signed-off-by: Marc Dumais <[email protected]>
1 parent 18c5fa7 commit 3908d52

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"download:plugins": "theia download:plugins",
7272
"electron": "yarn -s --cwd examples/electron",
7373
"license:check": "node scripts/check_3pp_licenses.js",
74+
"license:check:review": "node scripts/check_3pp_licenses.js --review",
7475
"lint": "lerna run lint",
7576
"lint:clean": "rimraf .eslintcache",
7677
"lint:oneshot": "node --max-old-space-size=4096 node_modules/eslint/bin/eslint.js --cache=true \"{dev-packages,packages,examples}/**/*.{ts,tsx}\"",

scripts/check_3pp_licenses.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,30 @@
1818
const cp = require('child_process');
1919
const fs = require('fs');
2020
const path = require('path');
21+
const { env, argv } = require('process');
2122
const readline = require('readline');
23+
// Submit any suspicious dependencies for review by the Eclipse Foundation, using dash-license "review" mode?
24+
const autoReviewMode = (process.argv.slice(2))[0] == "--review" ? true:false
2225

2326
const NO_COLOR = Boolean(process.env['NO_COLOR']);
2427
const dashLicensesJar = path.resolve(__dirname, 'download/dash-licenses.jar');
2528
const dashLicensesSummary = path.resolve(__dirname, '../dependency-check-summary.txt');
2629
const dashLicensesBaseline = path.resolve(__dirname, '../dependency-check-baseline.json');
2730
const dashLicensesUrl = 'https://repo.eclipse.org/service/local/artifact/maven/redirect?r=dash-licenses&g=org.eclipse.dash&a=org.eclipse.dash.licenses&v=LATEST';
31+
const project = "ecd.theia";
32+
33+
// A Eclipse Foundation Gitlab Personal Access Token, generated by an Eclipse committer,
34+
// is required to use dash-licenses in "review" mode. For more information see:
35+
// https://github.com/eclipse/dash-licenses#automatic-ip-team-review-requests
36+
// e.g. Set the token like so (bash shell):
37+
// $> export DASH_LICENSES_PAT="<PAT>"
38+
const gitlabTokenDefined = env.DASH_LICENSES_PAT ? true : false;
39+
40+
if (autoReviewMode && !gitlabTokenDefined) {
41+
console.error("Please setup an Eclipse Foundation Gitlab Personal Access Token to run the license check in 'review' mode");
42+
console.error("It should be set in an environment variable named 'DASH_LICENSES_PAT'");
43+
process.exit(1);
44+
}
2845

2946
main().catch(error => {
3047
console.error(error);
@@ -48,9 +65,19 @@ async function main() {
4865
fs.renameSync(dashLicensesSummary, `${dashLicensesSummary}.old`);
4966
}
5067
info('Running dash-licenses...');
68+
var args = ['-jar', dashLicensesJar, 'yarn.lock', '-batch', '50', '-timeout', '240', '-summary', dashLicensesSummary]
69+
if (autoReviewMode && gitlabTokenDefined) {
70+
info('using "review" mode');
71+
args.push('-review', '-token', '$DASH_LICENSES_PAT', '-project', project);
72+
}
73+
74+
// note: "shell:true" is required so we can reference the
75+
// Gitlab Personal Access Token through an environment variable
76+
// at invocation of "dash-license". This is necessary to avoid
77+
// leaking the token's value
5178
const dashError = getErrorFromStatus(spawn(
52-
'java', ['-jar', dashLicensesJar, 'yarn.lock', '-batch', '50', '-timeout', '240', '-summary', dashLicensesSummary],
53-
{ stdio: ['ignore', 'ignore', 'inherit'] },
79+
'java', args,
80+
{ stdio: ['ignore', 'ignore', 'inherit'], shell: true }
5481
));
5582
if (dashError) {
5683
warn(dashError);

0 commit comments

Comments
 (0)