Skip to content

Instantly share code, notes, and snippets.

@drio
Created December 16, 2021 21:00
Show Gist options
  • Save drio/bcf5a5ddca0c302da46ffc19c1ef87bb to your computer and use it in GitHub Desktop.
Save drio/bcf5a5ddca0c302da46ffc19c1ef87bb to your computer and use it in GitHub Desktop.
BIN_DIR=./bin
# To make sure some binaries exists in path
BINARIES = curl sh python3
K := $(foreach exec,$(BINARIES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
all: as_root deps root_grype.json output.txt
output.txt: ./parser.py
python3 parser.py > $@
# To create the SBOM (software bill of materials)
root_sbom.json:
$(BIN_DIR)/syft packages dir:/ -o json > $@
# To do the scanning
root_grype.json: root_sbom.json
$(BIN_DIR)/grype root_sbom.json -o json --scope all-layers > $@
deps: $(BIN_DIR)/grype $(BIN_DIR)/syft
$(BIN_DIR)/% $(BIN_DIR)/%:
curl -sSfL https://raw.githubusercontent.com/anchore/$*/main/install.sh | sh -s -- -b $(BIN_DIR)
bin:
mkdir bin
as_root:
@if ! [ "$(shell id -u)" = 0 ];then \
echo "You want to run this as root."; \
exit 1; \
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment