-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (58 loc) · 2.23 KB
/
Makefile
File metadata and controls
73 lines (58 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
.PHONY: build test test-integration run docker clean index reindex link-data clean-benchmark
# Paths
ABOUTSECURITY_DIR ?= ../AboutSecurity
ABOUTSECURITY_REPO = https://github.com/wgpsec/AboutSecurity.git
# Local development
build:
go build -o absec ./cmd/absec/
test:
go test ./...
test-integration:
go test -tags integration -v .
# Clone AboutSecurity repo if not present
$(ABOUTSECURITY_DIR):
git clone --depth 1 $(ABOUTSECURITY_REPO) $(ABOUTSECURITY_DIR)
# Build FTS5 index from AboutSecurity data
data/builtin.db: build/build_index.py build/security_dict.txt | $(ABOUTSECURITY_DIR)
pip3 install --quiet jieba pyyaml
python3 build/build_index.py \
--input $(ABOUTSECURITY_DIR) \
--dict build/security_dict.txt \
--output data/builtin.db
# Symlink AboutSecurity content directories into data/ for local development
link-data: | $(ABOUTSECURITY_DIR)
@for dir in Payload Dic skills Vuln; do \
if [ -d "$(ABOUTSECURITY_DIR)/$$dir" ] && [ ! -e "data/$$dir" ]; then \
ln -s "$$(cd $(ABOUTSECURITY_DIR) && pwd)/$$dir" data/$$dir; \
echo "Linked data/$$dir -> $(ABOUTSECURITY_DIR)/$$dir"; \
fi; \
done
# Alias for just building the index
index: data/builtin.db
# Force rebuild index (use after changing AboutSecurity data)
reindex:
rm -f data/builtin.db
rm -f data/runtime/runtime.db data/runtime/runtime.db-wal data/runtime/runtime.db-shm
$(MAKE) data/builtin.db
run: build reindex link-data
./absec serve --port 1337 --data-dir ./data
# Docker — default: clones AboutSecurity from GitHub
docker:
DOCKER_BUILDKIT=1 docker build -t context1337:latest -f build/Dockerfile .
# Build with a specific branch/tag
ABOUTSECURITY_REF ?= main
docker-ref:
DOCKER_BUILDKIT=1 docker build -t context1337:latest -f build/Dockerfile \
--build-arg ABOUTSECURITY_REF=$(ABOUTSECURITY_REF) .
# Build with local AboutSecurity repo (skip git clone)
ABOUTSECURITY_LOCAL ?= ../AboutSecurity
docker-local:
DOCKER_BUILDKIT=1 docker build -t context1337:latest -f build/Dockerfile \
--build-context aboutsecurity=$(ABOUTSECURITY_LOCAL) .
clean:
rm -f absec
rm -f data/builtin.db
rm -f data/Payload data/Dic data/skills data/Vuln
rm -f data/runtime/runtime.db data/runtime/runtime.db-wal data/runtime/runtime.db-shm
clean-benchmark:
rm -rf data/benchmark/