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
2e633b45
Unverified
Commit
2e633b45
authored
2 years ago
by
Cam Saul
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove orphaned bin/check-licenses script (#22925)
parent
9bfc3620
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/check-licenses
+0
-189
0 additions, 189 deletions
bin/check-licenses
with
0 additions
and
189 deletions
bin/check-licenses
deleted
100755 → 0
+
0
−
189
View file @
9bfc3620
#!/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.
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