2022-10-10 08:21:17 -04:00
|
|
|
#!/usr/bin/env bash
|
2022-07-26 05:49:13 -04:00
|
|
|
|
|
|
|
# Compare licenses of Go dependencies against a whitelist.
|
|
|
|
|
2022-11-10 04:28:35 -05:00
|
|
|
set -euo pipefail
|
|
|
|
shopt -s inherit_errexit
|
2022-07-26 05:49:13 -04:00
|
|
|
|
|
|
|
not_allowed() {
|
2022-11-10 04:28:35 -05:00
|
|
|
echo "license not allowed for package: ${line}"
|
2022-07-26 05:49:13 -04:00
|
|
|
err=1
|
|
|
|
}
|
|
|
|
|
|
|
|
go mod download
|
|
|
|
|
|
|
|
go-licenses csv ./... | {
|
2022-11-10 04:28:35 -05:00
|
|
|
while read -r line; do
|
2022-07-26 05:49:13 -04:00
|
|
|
|
|
|
|
pkg=${line%%,*}
|
|
|
|
lic=${line##*,}
|
|
|
|
|
2022-11-10 04:28:35 -05:00
|
|
|
case ${lic} in
|
2022-07-26 05:49:13 -04:00
|
|
|
Apache-2.0|BSD-2-Clause|BSD-3-Clause|ISC|MIT)
|
|
|
|
;;
|
|
|
|
|
|
|
|
MPL-2.0)
|
2022-11-10 04:28:35 -05:00
|
|
|
case ${pkg} in
|
2022-07-26 05:49:13 -04:00
|
|
|
github.com/talos-systems/talos/pkg/machinery/config/encoder)
|
|
|
|
;;
|
2022-08-01 03:37:05 -04:00
|
|
|
github.com/letsencrypt/boulder)
|
|
|
|
;;
|
2022-09-26 09:52:31 -04:00
|
|
|
github.com/hashicorp/*)
|
|
|
|
;;
|
2022-07-26 05:49:13 -04:00
|
|
|
*)
|
|
|
|
not_allowed
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
2022-08-19 09:57:01 -04:00
|
|
|
AGPL-3.0)
|
2022-11-10 04:28:35 -05:00
|
|
|
case ${pkg} in
|
2022-09-21 09:40:02 -04:00
|
|
|
github.com/edgelesssys/constellation/v2)
|
2022-07-26 05:49:13 -04:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
not_allowed
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
2022-08-19 09:57:01 -04:00
|
|
|
Unknown)
|
2022-11-10 04:28:35 -05:00
|
|
|
case ${pkg} in
|
2022-08-19 09:57:01 -04:00
|
|
|
*)
|
|
|
|
not_allowed
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
2022-07-26 05:49:13 -04:00
|
|
|
*)
|
2022-11-10 04:28:35 -05:00
|
|
|
echo "unknown license: ${line}"
|
2022-07-26 05:49:13 -04:00
|
|
|
err=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
done
|
2022-11-10 04:28:35 -05:00
|
|
|
exit "${err}"
|
2022-07-26 05:49:13 -04:00
|
|
|
}
|