2023-02-24 02:29:28 +00:00
|
|
|
ARCH ?= $(shell uname -m)
|
|
|
|
COLLECT_DIR ?= "./out/$(shell hostname -s)-$(shell date +%Y-%m-%-d-%H-%M-%S)"
|
2023-02-24 02:45:34 +00:00
|
|
|
SUDO ?= "sudo"
|
2023-02-24 02:29:28 +00:00
|
|
|
|
|
|
|
out/osqtool-$(ARCH):
|
2022-10-13 13:11:17 +00:00
|
|
|
mkdir -p out
|
2022-10-13 14:04:18 +00:00
|
|
|
GOBIN=$(CURDIR)/out go install github.com/chainguard-dev/osqtool/cmd/osqtool@latest
|
2023-02-24 02:29:28 +00:00
|
|
|
mv out/osqtool out/osqtool-$(ARCH)
|
2022-10-13 13:11:17 +00:00
|
|
|
|
2023-02-24 02:29:28 +00:00
|
|
|
out/odk-detection.conf: out/osqtool-$(ARCH) $(wildcard detection/*.sql)
|
|
|
|
./out/osqtool-$(ARCH) --max-results=0 --max-total-daily-duration=3h45m --max-query-daily-duration=1.5h --verify pack detection/ > out/.odk-detection.conf
|
|
|
|
mv out/.odk-detection.conf out/odk-detection.conf
|
2022-10-13 13:11:17 +00:00
|
|
|
|
2023-02-24 02:29:28 +00:00
|
|
|
out/odk-policy.conf: out/osqtool-$(ARCH) $(wildcard policy/*.sql)
|
|
|
|
./out/osqtool-$(ARCH) --max-results=0 --verify pack policy/ > out/.odk-policy.conf
|
|
|
|
mv out/.odk-policy.conf out/odk-policy.conf
|
2022-10-13 14:04:18 +00:00
|
|
|
|
2023-02-24 02:29:28 +00:00
|
|
|
out/odk-incident-response.conf: out/osqtool-$(ARCH) $(wildcard incident_response/*.sql)
|
|
|
|
./out/osqtool-$(ARCH) --max-results=150000 --max-query-duration=8s --max-total-daily-duration=90m --verify pack incident_response/ > out/.odk-incident_response.conf
|
|
|
|
mv out/.odk-incident_response.conf out/odk-incident_response.conf
|
2022-10-13 13:11:17 +00:00
|
|
|
|
2022-11-23 12:32:52 +00:00
|
|
|
# An alternative rules file for configurations where the "wireless_networks" table is forbidden for querying
|
2023-02-24 02:29:28 +00:00
|
|
|
out/odk-incident-response-no-wifi.conf: out/osqtool-$(ARCH)
|
2023-02-08 19:37:09 +00:00
|
|
|
./out/osqtool --max-results=150000 --max-query-duration=8s --max-total-daily-duration=90m --verify --exclude wireless_networks_macos pack incident_response/ > out/odk-incident-response-no-wifi.conf
|
2022-11-23 12:32:52 +00:00
|
|
|
|
|
|
|
packs: out/odk-detection.conf out/odk-policy.conf out/odk-incident-response.conf out/odk-incident-response-no-wifi.conf
|
2022-10-13 13:11:17 +00:00
|
|
|
|
|
|
|
out/odk-packs.zip: packs
|
|
|
|
cd out && zip odk-packs.zip *.conf
|
|
|
|
|
2022-10-20 13:10:45 +00:00
|
|
|
.PHONY: reformat
|
|
|
|
reformat:
|
|
|
|
find . -type f -name "*.sql" | perl -ne 'chomp; system("cp $$_ /tmp/fix.sql && npx sql-formatter -l sqlite /tmp/fix.sql > $$_");'
|
|
|
|
|
2023-02-10 15:33:04 +00:00
|
|
|
.PHONY: reformat-updates
|
|
|
|
reformat-updates:
|
|
|
|
git status -s | awk '{ print $$2 }' | grep ".sql" | perl -ne 'chomp; system("cp $$_ /tmp/fix.sql && npx sql-formatter -l sqlite /tmp/fix.sql > $$_");'
|
|
|
|
|
2023-02-24 02:29:28 +00:00
|
|
|
.PHONY: collection
|
|
|
|
collection: ./out/osqtool-$(ARCH)
|
|
|
|
mkdir -p $(COLLECT_DIR)
|
|
|
|
@echo "Saving output to: $(COLLECT_DIR)"
|
2023-02-24 02:45:34 +00:00
|
|
|
$(SUDO) ./out/osqtool-$(ARCH) run incident_response | tee $(COLLECT_DIR)/incident_response.txt
|
|
|
|
$(SUDO) ./out/osqtool-$(ARCH) run policy | tee $(COLLECT_DIR)/policy.txt
|
|
|
|
$(SUDO) ./out/osqtool-$(ARCH) run detection | tee $(COLLECT_DIR)/detection.txt
|
2023-02-24 02:29:28 +00:00
|
|
|
|
2022-10-14 14:25:08 +00:00
|
|
|
all: out/odk-packs.zip
|
2023-02-24 02:29:28 +00:00
|
|
|
|