2023-03-27 04:42:30 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Compare licenses of Go dependencies against a whitelist.
|
|
|
|
|
2023-03-29 08:13:26 -04:00
|
|
|
###### script header ######
|
|
|
|
|
2023-03-27 04:42:30 -04:00
|
|
|
lib=$(realpath @@BASE_LIB@@) || exit 1
|
2023-03-29 08:13:26 -04:00
|
|
|
stat "${lib}" >> /dev/null || exit 1
|
2023-03-27 04:42:30 -04:00
|
|
|
|
|
|
|
# shellcheck source=../sh/lib.bash
|
|
|
|
if ! source "${lib}"; then
|
|
|
|
echo "Error: could not find import"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-03-29 08:13:26 -04:00
|
|
|
go=$(realpath @@GO@@)
|
|
|
|
stat "${go}" >> /dev/null
|
|
|
|
golicenses=$(realpath @@GO_LICENSES@@)
|
|
|
|
stat "${golicenses}" >> /dev/null
|
|
|
|
|
|
|
|
cd "${BUILD_WORKSPACE_DIRECTORY}"
|
|
|
|
|
|
|
|
###### script body ######
|
2023-03-27 04:42:30 -04:00
|
|
|
|
|
|
|
not_allowed() {
|
|
|
|
echo "license not allowed for package: ${line}"
|
|
|
|
err=1
|
|
|
|
}
|
|
|
|
|
2023-06-14 07:58:21 -04:00
|
|
|
license_report() {
|
|
|
|
PATH="$(dirname "${go}"):${PATH}" \
|
|
|
|
GOROOT=$(${go} env GOROOT) \
|
|
|
|
GOPATH=$(${go} env GOPATH) \
|
|
|
|
GOCACHE=$(${go} env GOCACHE) \
|
|
|
|
${golicenses} report ./... | {
|
|
|
|
while read -r line; do
|
2023-03-27 04:42:30 -04:00
|
|
|
|
2023-06-14 07:58:21 -04:00
|
|
|
pkg=${line%%,*}
|
|
|
|
lic=${line##*,}
|
2023-03-27 04:42:30 -04:00
|
|
|
|
2023-06-14 07:58:21 -04:00
|
|
|
case ${lic} in
|
|
|
|
Apache-2.0 | BSD-2-Clause | BSD-3-Clause | ISC | MIT) ;;
|
2023-03-27 04:42:30 -04:00
|
|
|
|
2023-06-14 07:58:21 -04:00
|
|
|
MPL-2.0)
|
|
|
|
case ${pkg} in
|
|
|
|
github.com/siderolabs/talos/pkg/machinery/config/encoder) ;;
|
2023-03-27 04:42:30 -04:00
|
|
|
|
2023-06-14 07:58:21 -04:00
|
|
|
github.com/letsencrypt/boulder) ;;
|
2023-03-27 04:42:30 -04:00
|
|
|
|
2023-06-14 07:58:21 -04:00
|
|
|
github.com/hashicorp/*) ;;
|
2023-03-27 04:42:30 -04:00
|
|
|
|
2023-06-14 07:58:21 -04:00
|
|
|
*)
|
|
|
|
not_allowed
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
2023-03-27 04:42:30 -04:00
|
|
|
|
2023-06-14 07:58:21 -04:00
|
|
|
AGPL-3.0)
|
|
|
|
case ${pkg} in
|
|
|
|
github.com/edgelesssys/constellation/v2) ;;
|
2023-03-27 04:42:30 -04:00
|
|
|
|
2024-01-08 07:19:38 -05:00
|
|
|
github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/api/v1alpha1) ;;
|
|
|
|
|
|
|
|
github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/api) ;;
|
2023-06-14 07:58:21 -04:00
|
|
|
|
|
|
|
*)
|
|
|
|
not_allowed
|
|
|
|
;;
|
|
|
|
esac
|
2023-03-27 04:42:30 -04:00
|
|
|
;;
|
|
|
|
|
2023-06-14 07:58:21 -04:00
|
|
|
Unknown)
|
|
|
|
case ${pkg} in
|
|
|
|
github.com/edgelesssys/go-tdx-qpl/*) ;;
|
2023-03-27 04:42:30 -04:00
|
|
|
|
2023-06-14 07:58:21 -04:00
|
|
|
*)
|
|
|
|
not_allowed
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
2023-03-27 04:42:30 -04:00
|
|
|
|
|
|
|
*)
|
2023-06-14 07:58:21 -04:00
|
|
|
echo "unknown license: ${line}"
|
|
|
|
err=1
|
2023-03-27 04:42:30 -04:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2023-06-14 07:58:21 -04:00
|
|
|
done
|
|
|
|
exit "${err}"
|
|
|
|
}
|
|
|
|
}
|
2023-03-27 04:42:30 -04:00
|
|
|
|
2023-06-14 07:58:21 -04:00
|
|
|
${go} mod download
|
2023-03-27 04:42:30 -04:00
|
|
|
|
2023-06-14 07:58:21 -04:00
|
|
|
err=0
|
2023-03-27 04:42:30 -04:00
|
|
|
|
2023-06-14 07:58:21 -04:00
|
|
|
if test -v SILENT; then
|
|
|
|
license_report 2> /dev/null
|
|
|
|
else
|
|
|
|
license_report
|
|
|
|
fi
|