Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
a196e4ba
Unverified
Commit
a196e4ba
authored
4 years ago
by
Tom Robinson
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Check dependency licenses in CI (#9290)
parent
145b575b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.circleci/config.yml
+12
-1
12 additions, 1 deletion
.circleci/config.yml
bin/check-licenses
+189
-0
189 additions, 0 deletions
bin/check-licenses
project.clj
+2
-1
2 additions, 1 deletion
project.clj
with
203 additions
and
2 deletions
.circleci/config.yml
+
12
−
1
View file @
a196e4ba
...
...
@@ -716,6 +716,14 @@ jobs:
-
run
:
./bin/deploy-webhook $DEPLOY_WEBHOOK
check-licenses
:
executor
:
node
steps
:
-
attach-workspace
-
restore-be-deps-cache
-
restore-fe-deps-cache
-
run
:
./bin/check-licenses
########################################################################################################################
# WORKFLOWS #
########################################################################################################################
...
...
@@ -992,7 +1000,10 @@ workflows:
requires
:
-
be-deps
<<
:
*Matrix
-
check-licenses
:
requires
:
-
be-deps
-
fe-deps
-
fe-tests-cypress
:
name
:
fe-tests-cypress-1-<< matrix.edition >>
requires
:
...
...
This diff is collapsed.
Click to expand it.
bin/check-licenses
0 → 100755
+
189
−
0
View file @
a196e4ba
#!/usr/bin/env node
const
{
execSync
}
=
require
(
"
child_process
"
);
const
{
readFileSync
}
=
require
(
"
fs
"
);
const
_
=
require
(
"
underscore
"
);
const
DEV_MODE
=
false
;
function
normalizeLicense
(
license
)
{
return
license
.
toLowerCase
()
.
trim
()
.
replace
(
/^the
\s
+/
,
""
);
}
const
LICENSE_ALLOWLIST
=
new
Set
(
[
"
Apache 2
"
,
"
Apache 2.0
"
,
"
Apache License 2.0
"
,
"
Apache License
"
,
"
Apache License, Version 2.0
"
,
"
Apache Software License - Version 2.0
"
,
"
Apache Software License, Version 2.0
"
,
"
Apache v2
"
,
"
Apache*
"
,
"
Apache-2.0
"
,
"
Apache 2.0 License
"
,
"
Artistic-2.0
"
,
"
BSD 3-Clause License
"
,
"
BSD License
"
,
"
BSD licence
"
,
"
BSD
"
,
"
BSD*
"
,
"
0BSD
"
,
"
BSD-2-Clause
"
,
"
BSD-3-Clause
"
,
"
BSD 3-clause
"
,
"
BSD style
"
,
"
Bouncy Castle Licence
"
,
"
CC0 1.0 Universal
"
,
"
CC0-1.0
"
,
"
CC-BY-4.0
"
,
"
CC-BY-3.0
"
,
"
CDDL + GPLv2 with classpath exception
"
,
// this means CDDL or GPLv2 w/ classpath exception
"
CDDL 1.1
"
,
"
CDDL License
"
,
"
CDDL/GPLv2+CE
"
,
// this means CDDL or GPLv2 w/ classpath exception
"
COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
"
,
"
Common Development and Distribution License (CDDL) v1.0
"
,
"
Common Public License Version 1.0
"
,
"
Common Public License Version
"
,
"
Eclipse Public License - v 1.0
"
,
"
Eclipse Public License 1.0
"
,
"
Eclipse Public License
"
,
"
GNU Lesser General Public License 3.0
"
,
"
GNU Lesser General Public License, Version 2.1
"
,
"
ISC
"
,
"
ISC/BSD License
"
,
"
LGPL-2.1
"
,
"
Lesser GPL
"
,
"
MIT (http://mootools.net/license.txt)
"
,
"
MIT License
"
,
"
MIT Licensed. http://www.opensource.org/licenses/mit-license.php
"
,
"
MIT
"
,
"
MIT*
"
,
"
MIT AND BSD-3-Clause
"
,
"
MIT AND Zlib
"
,
"
MPL 2.0
"
,
"
New BSD License
"
,
// same as 3-clause
"
Public Domain
"
,
"
Revised BSD
"
,
// "The MIT License (MIT)",
"
Unlicense
"
,
"
WTFPL
"
,
].
map
(
normalizeLicense
),
);
const
PACKAGE_ALLOWLIST
=
new
Set
([
"
com.amazon.redshift/redshift-jdbc42-no-awssdk@1.2.45.1069
"
,
// Apache 2.0?
"
amalloy/ring-gzip-middleware@0.1.4
"
,
// MIT https://github.com/clj-commons/ring-gzip-middleware/blob/master/LICENSE
"
caniuse-db@1.0.30000789
"
,
// CC-BY-4.0: https://github.com/Fyrd/caniuse
"
colorize@0.1.1
"
,
// Eclipse Public License: https://github.com/ibdknox/colorize
"
com.google.re2j/re2j@1.1
"
,
// Go License https://github.com/google/re2j/blob/master/LICENSE
"
com.unboundid/unboundid-ldapsdk@4.0.4
"
,
// dual licensed LGPL/GPL: https://ldap.com/unboundid-ldap-sdk-for-java/
"
cycle@1.0.3
"
,
// Public domain: https://github.com/dscape/cycle/blob/master/cycle.js
"
expectations@2.2.0-beta2
"
,
// BSD 3-Clause: https://github.com/clojure-expectations/expectations
"
hiccup@1.0.5
"
,
// Eclipse Public License: https://github.com/weavejester/hiccup
"
isnumeric@0.2.0
"
,
// MIT: https://github.com/leecrossley/isNumeric
"
javax.servlet.jsp/jsp-api@2.1
"
,
// CDDL/GPL dual license: https://javaee.github.io/javaee-jsp-api/LICENSE
"
jdk.tools@1.8
"
,
// build tools
"
net.jcip/jcip-annotations@1.0
"
,
// Public Domain: https://mvnrepository.com/artifact/net.jcip/jcip-annotations
"
org.gnu.gettext/libintl@0.18.3
"
,
// LGPL: https://www.gnu.org/software/gettext/manual/html_node/Licenses.html
"
org.json/json@20090211
"
,
// JSON License: https://www.json.org/license.html
"
pako@1.0.6
"
,
// build tool only
"
slingshot@0.10.2
"
,
// Eclipse Public License: https://github.com/scgilardi/slingshot
"
sntp@1.0.9
"
,
// BSD-3-Clause: https://github.com/hueniverse/sntp/blob/master/LICENSE
"
spdx-expression-parse@1.0.4
"
,
// build tool only
"
spdx-license-ids@1.2.2
"
,
// build tool only
"
stencil@0.5.0
"
,
// Eclipse Public License: https://github.com/davidsantiago/stencil/blob/0.5.0/LICENSE
]);
function
parseLicenses
(
license
)
{
license
=
license
.
replace
(
/^
\((
.*
)\)
$/g
,
"
$1
"
);
// trim parens
if
(
/
\b
or
\b
/i
.
test
(
license
)
&&
!
/
\b
and
\b
/i
.
test
(
license
))
{
return
license
.
split
(
/
\b
or
\b
/gi
).
map
(
normalizeLicense
);
}
else
{
return
[
normalizeLicense
(
license
)];
}
}
function
getJavaScriptPackageLicences
()
{
return
(
DEV_MODE
?
readFileSync
(
"
licenses.json
"
,
"
utf-8
"
)
:
execSync
(
"
yarn licenses list --json
"
,
{
encoding
:
"
utf-8
"
})
)
.
split
(
"
\n
"
)
.
slice
(
-
2
,
-
1
)
// 2nd to last row
.
map
(
line
=>
JSON
.
parse
(
line
))[
0
]
.
data
.
body
.
map
(
row
=>
({
name
:
row
[
0
],
version
:
row
[
1
],
license
:
row
[
2
],
licenses
:
parseLicenses
(
row
[
2
]),
type
:
"
javascript
"
,
}));
}
function
getClojurePackageLicenses
()
{
return
(
(
DEV_MODE
?
readFileSync
(
"
licenses.csv
"
,
"
utf-8
"
)
:
execSync
(
"
lein with-profiles +include-all-drivers,-dev licenses :csv
"
,
{
encoding
:
"
utf-8
"
,
})
)
// rudimentary csv parsing
.
split
(
"
\n
"
)
.
filter
(
line
=>
/^".*"$/
.
test
(
line
))
.
map
(
line
=>
line
.
replace
(
/^"
(
.*
)
"$/g
,
"
$1
"
).
split
(
/","/g
))
.
map
(
row
=>
({
name
:
row
[
0
],
version
:
row
[
1
],
license
:
row
[
2
],
licenses
:
parseLicenses
(
row
[
2
]),
type
:
"
clojure
"
,
}))
);
}
function
checkLicences
(
packages
)
{
return
packages
.
filter
(
({
name
,
version
,
licenses
})
=>
// check if any of the licenses are allowed
!
_
.
any
(
licenses
,
license
=>
LICENSE_ALLOWLIST
.
has
(
license
))
&&
// check package allowlist
!
PACKAGE_ALLOWLIST
.
has
(
`
${
name
}
@
${
version
}
`
),
);
}
const
unknownJavaScriptLicenses
=
checkLicences
(
getJavaScriptPackageLicences
());
const
unknownClojureLicenses
=
checkLicences
(
getClojurePackageLicenses
());
const
unknownPackageLogs
=
[];
const
unknownLicenseCounts
=
new
Map
();
for
(
const
{
name
,
version
,
license
,
type
}
of
[
...
unknownJavaScriptLicenses
,
...
unknownClojureLicenses
,
])
{
unknownPackageLogs
.
push
(
`[
${
license
}
]
${
name
}
@
${
version
}
(
${
type
}
)`
);
unknownLicenseCounts
.
set
(
license
,
(
unknownLicenseCounts
.
get
(
license
)
||
0
)
+
1
,
);
}
console
.
log
(
"
Packages
\n
========
\n
"
);
console
.
log
(
unknownPackageLogs
.
sort
().
join
(
"
\n
"
));
console
.
log
(
"
\n
Licenses
\n
========
\n
"
);
console
.
log
(
_
.
sortBy
(
Array
.
from
(
unknownLicenseCounts
),
1
)
.
reverse
()
.
map
(([
license
,
count
])
=>
`[
${
count
}
]
${
license
}
`
)
.
join
(
"
\n
"
),
);
process
.
exit
(
unknownLicenseCounts
.
size
===
0
?
0
:
1
);
This diff is collapsed.
Click to expand it.
project.clj
+
2
−
1
View file @
a196e4ba
...
...
@@ -205,7 +205,8 @@
[
ring/ring-mock
"0.4.0"
]]
:plugins
[[
lein-environ
"1.1.0"
]]
; easy access to environment variables
[[
lein-environ
"1.1.0"
]
; easy access to environment variables
[
lein-licenses
"LATEST"
]]
:injections
[(
require
'pjstadig.humane-test-output
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment