diff --git a/Makefile b/Makefile index 61593da..f6aabd2 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,12 @@ bootstrap: vendor clean: -rm package-scanner +.PHONY: clean-all +clean-all: clean + -rm -rf vendor + (cd tools/grype-bin && rm -rf grype*) + (cd tools/syft-bin && rm -rf syft*) + .PHONY: vendor vendor: go mod tidy -v diff --git a/go.mod b/go.mod index 9ed8f7b..ee1a300 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,6 @@ require ( github.com/olekukonko/tablewriter v0.0.5 github.com/sirupsen/logrus v1.9.3 google.golang.org/grpc v1.60.1 - google.golang.org/protobuf v1.32.0 ) require ( @@ -91,5 +90,6 @@ require ( golang.org/x/tools v0.10.0 // indirect google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect + google.golang.org/protobuf v1.32.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/tools/embed.go b/tools/embed.go index 065b689..0855b11 100644 --- a/tools/embed.go +++ b/tools/embed.go @@ -8,6 +8,6 @@ var ( //go:embed syft-bin/syft.bin SyftBin []byte - //go:embed grype-bin/grype + //go:embed grype-bin/grype.bin GrypeBin []byte ) diff --git a/tools/grype-bin/get_grype.sh b/tools/grype-bin/get_grype.sh index 5549d3b..2900d11 100755 --- a/tools/grype-bin/get_grype.sh +++ b/tools/grype-bin/get_grype.sh @@ -5,19 +5,26 @@ set -eux VERSION=0.73.1 HOST_OS=$(uname -s | tr '[:upper:]' '[:lower:]') -HOST_ARCH=$(uname -m) +HOST_ARCH="${GOARCH:=$(uname -m)}" if [ "$HOST_ARCH" = "x86_64" ]; then HOST_ARCH="amd64" elif [ "$HOST_ARCH" = "aarch64" ]; then HOST_ARCH="arm64" +elif [ "$HOST_ARCH" = "arm" ]; then + HOST_ARCH="arm" fi ARCHITECTURE="${TARGETPLATFORM:-$HOST_OS/$HOST_ARCH}" IFS=/ read BUILD_OS BUILD_ARCH <<< $ARCHITECTURE -rm -rf grype_*.tar.gz grype +rm -rf grype* -curl -fsSLO https://github.com/anchore/grype/releases/download/v${VERSION}/grype_${VERSION}_${BUILD_OS}_${BUILD_ARCH}.tar.gz -tar -zxvf grype_${VERSION}_${BUILD_OS}_${BUILD_ARCH}.tar.gz grype +git clone https://github.com/anchore/grype.git --branch v$VERSION || true +( + cd grype/cmd/grype + export CGO_ENABLED=0 + GOOS="$BUILD_OS" GOARCH="$BUILD_ARCH" go build -o grype.bin . + cp grype.bin ../../../ +) diff --git a/tools/syft-bin/get_syft.sh b/tools/syft-bin/get_syft.sh index 47ebb22..c07dee4 100755 --- a/tools/syft-bin/get_syft.sh +++ b/tools/syft-bin/get_syft.sh @@ -2,20 +2,26 @@ set -eux +RELEASE=optimise-resolver-2 + HOST_OS=$(uname -s | tr '[:upper:]' '[:lower:]') -HOST_ARCH=$(uname -m) +HOST_ARCH="${GOARCH:=$(uname -m)}" if [ "$HOST_ARCH" = "x86_64" ]; then HOST_ARCH="amd64" elif [ "$HOST_ARCH" = "aarch64" ]; then HOST_ARCH="arm64" +elif [ "$HOST_ARCH" = "arm" ]; then + HOST_ARCH="arm" fi ARCHITECTURE="${TARGETPLATFORM:-$HOST_OS/$HOST_ARCH}" IFS=/ read BUILD_OS BUILD_ARCH <<< $ARCHITECTURE -git clone https://github.com/deepfence/syft.git --branch optimise-resolver-2 || true +rm -rf syft* + +git clone https://github.com/deepfence/syft.git --branch $RELEASE || true ( cd syft/cmd/syft export CGO_ENABLED=0