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
|
|
|
|
}
|
|
|
|
|
2022-11-11 10:16:14 -05:00
|
|
|
err=0
|
2022-07-26 05:49:13 -04:00
|
|
|
go mod download
|
|
|
|
|
|
|
|
go-licenses csv ./... | {
|
2022-11-10 08:17:04 -05:00
|
|
|
while read -r line; do
|
2022-07-26 05:49:13 -04:00
|
|
|
|
2022-11-10 08:17:04 -05:00
|
|
|
pkg=${line%%,*}
|
|
|
|
lic=${line##*,}
|
2022-07-26 05:49:13 -04:00
|
|
|
|
2022-11-10 08:17:04 -05:00
|
|
|
case ${lic} in
|
|
|
|
Apache-2.0 | BSD-2-Clause | BSD-3-Clause | ISC | MIT) ;;
|
2022-07-26 05:49:13 -04:00
|
|
|
|
2022-11-11 10:16:14 -05:00
|
|
|
MPL-2.0)
|
2022-11-10 04:28:35 -05:00
|
|
|
case ${pkg} in
|
2023-01-02 07:33:56 -05:00
|
|
|
github.com/siderolabs/talos/pkg/machinery/config/encoder) ;;
|
2022-11-10 08:17:04 -05:00
|
|
|
|
|
|
|
github.com/letsencrypt/boulder) ;;
|
|
|
|
|
|
|
|
github.com/hashicorp/*) ;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
not_allowed
|
|
|
|
;;
|
2022-07-26 05:49:13 -04:00
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
2022-08-19 09:57:01 -04:00
|
|
|
AGPL-3.0)
|
2022-11-10 04:28:35 -05:00
|
|
|
case ${pkg} in
|
2022-11-10 08:17:04 -05:00
|
|
|
github.com/edgelesssys/constellation/v2) ;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
not_allowed
|
|
|
|
;;
|
2022-07-26 05:49:13 -04:00
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
2022-08-19 09:57:01 -04:00
|
|
|
Unknown)
|
2022-11-10 04:28:35 -05:00
|
|
|
case ${pkg} in
|
2022-11-10 08:17:04 -05:00
|
|
|
*)
|
|
|
|
not_allowed
|
|
|
|
;;
|
2022-08-19 09:57:01 -04:00
|
|
|
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
|
|
|
|
;;
|
2022-11-10 08:17:04 -05:00
|
|
|
esac
|
2022-07-26 05:49:13 -04:00
|
|
|
|
2022-11-10 08:17:04 -05:00
|
|
|
done
|
|
|
|
exit "${err}"
|
2022-07-26 05:49:13 -04:00
|
|
|
}
|