2024-05-02 13:42:44 +03:00
|
|
|
all: gen extractor
|
2019-11-08 15:14:43 +03:00
|
|
|
|
2024-06-03 17:06:44 +03:00
|
|
|
EXTRACTOR_PACK_OUT = extractor-pack
|
2020-01-09 22:08:15 +03:00
|
|
|
|
2024-05-02 13:42:44 +03:00
|
|
|
.PHONY: extractor gen clean autoformat check-formatting
|
2020-01-09 22:08:15 +03:00
|
|
|
|
|
|
|
clean:
|
2020-02-03 23:50:06 +03:00
|
|
|
rm -rf $(EXTRACTOR_PACK_OUT) build/stats build/testdb
|
2020-01-09 22:08:15 +03:00
|
|
|
|
2020-06-09 19:27:53 +03:00
|
|
|
autoformat:
|
2021-04-26 16:04:19 +03:00
|
|
|
find ql -iregex '.*\.qll?' -print0 | xargs -0 codeql query format -qq -i
|
|
|
|
find . -path '**/vendor' -prune -or -type f -iname '*.go' ! -empty -print0 | xargs -0 grep -L "//\s*autoformat-ignore" | xargs gofmt -w
|
2020-07-09 19:46:11 +03:00
|
|
|
|
|
|
|
check-formatting:
|
2023-10-03 13:11:18 +03:00
|
|
|
@output=$$(find . -path '**/vendor' -prune -or -type f -iname '*.go' ! -empty -print0 | xargs -0 grep -L "//\s*autoformat-ignore" | xargs gofmt -l 2>&1); \
|
|
|
|
if [ -n "$$output" ]; then \
|
2023-10-04 13:07:19 +03:00
|
|
|
echo "The following files need to be reformatted using gofmt or have compilation errors:"; \
|
2023-10-04 12:23:29 +03:00
|
|
|
echo "$$output"; \
|
2023-10-03 13:11:18 +03:00
|
|
|
fi; \
|
|
|
|
test -z "$$output"
|
2020-06-09 19:27:53 +03:00
|
|
|
|
2020-09-29 18:01:13 +03:00
|
|
|
ifeq ($(QHELP_OUT_DIR),)
|
|
|
|
# If not otherwise specified, compile qhelp to markdown in place
|
|
|
|
QHELP_OUT_DIR := ql/src
|
|
|
|
endif
|
|
|
|
|
|
|
|
qhelp-to-markdown:
|
|
|
|
scripts/qhelp-to-markdown.sh ql/src "$(QHELP_OUT_DIR)"
|
|
|
|
|
2024-05-02 13:42:44 +03:00
|
|
|
extractor:
|
2024-05-30 12:10:25 +03:00
|
|
|
bazel run :go-installer
|
2019-11-08 15:14:43 +03:00
|
|
|
|
2024-05-02 13:42:44 +03:00
|
|
|
gen:
|
|
|
|
bazel run :gen
|
2019-11-08 15:14:43 +03:00
|
|
|
|
2020-02-03 23:50:06 +03:00
|
|
|
build/stats/src.stamp:
|
|
|
|
mkdir -p $(@D)/src
|
|
|
|
git clone 'https://github.com/golang/tools' $(@D)/src
|
2020-02-20 03:39:44 +03:00
|
|
|
git -C $(@D)/src checkout 9b52d559c609 -q
|
2020-02-03 23:50:06 +03:00
|
|
|
touch $@
|
|
|
|
|
2021-08-24 03:00:53 +03:00
|
|
|
ql/lib/go.dbscheme.stats: ql/lib/go.dbscheme build/stats/src.stamp extractor
|
2020-02-03 23:50:06 +03:00
|
|
|
rm -rf build/stats/database
|
|
|
|
codeql database create -l go -s build/stats/src -j4 --search-path . build/stats/database
|
2020-04-02 12:15:10 +03:00
|
|
|
codeql dataset measure -o $@ build/stats/database/db-go
|
2019-11-08 15:14:43 +03:00
|
|
|
|
2020-02-03 23:57:09 +03:00
|
|
|
test: all build/testdb/check-upgrade-path
|
2024-06-03 17:33:17 +03:00
|
|
|
codeql test run -j0 ql/test --search-path .. --consistency-queries ql/test/consistency --compilation-cache=$(cache)
|
2023-05-11 19:10:02 +03:00
|
|
|
# use GOOS=linux because GOOS=darwin GOARCH=386 is no longer supported
|
2024-06-03 17:33:17 +03:00
|
|
|
env GOOS=linux GOARCH=386 codeql$(EXE) test run -j0 ql/test/query-tests/Security/CWE-681 --search-path .. --consistency-queries ql/test/consistency --compilation-cache=$(cache)
|
2024-05-02 13:42:44 +03:00
|
|
|
cd extractor; bazel test ...
|
2021-03-29 15:08:47 +03:00
|
|
|
bash extractor-smoke-test/test.sh || (echo "Extractor smoke test FAILED"; exit 1)
|
2019-11-08 15:14:43 +03:00
|
|
|
|
|
|
|
.PHONY: build/testdb/check-upgrade-path
|
2021-08-24 03:00:53 +03:00
|
|
|
build/testdb/check-upgrade-path : build/testdb/go.dbscheme ql/lib/go.dbscheme
|
2021-12-10 23:36:50 +03:00
|
|
|
codeql dataset upgrade build/testdb --search-path ql/lib
|
2021-08-24 03:00:53 +03:00
|
|
|
diff -q build/testdb/go.dbscheme ql/lib/go.dbscheme
|
2019-11-08 15:14:43 +03:00
|
|
|
|
2020-03-04 14:27:11 +03:00
|
|
|
.PHONY: build/testdb/go.dbscheme
|
2021-12-10 23:36:50 +03:00
|
|
|
build/testdb/go.dbscheme: ql/lib/upgrades/initial/go.dbscheme
|
2020-03-04 14:27:11 +03:00
|
|
|
rm -rf build/testdb
|
2019-11-08 15:14:43 +03:00
|
|
|
echo >build/empty.trap
|
2021-12-10 23:36:50 +03:00
|
|
|
codeql dataset import -S ql/lib/upgrades/initial/go.dbscheme build/testdb build/empty.trap
|