-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (99 loc) · 4.83 KB
/
Copy pathMakefile
File metadata and controls
112 lines (99 loc) · 4.83 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
.PHONY: help fuzz fuzz-validate fuzz-validate-differential fuzz-malformed seed-to-wasm trace-wasm trace-wasm-debug trace trace-debug clean-artifacts gen-header
# Target Configuration (auto-detect if not set)
SPACEWASM_TARGET ?= $(shell rustc -vV | grep 'host:' | cut -d' ' -f2)
# Default target
help:
@echo "SpaceWasm Fuzzing Targets"
@echo ""
@echo "Configuration:"
@echo " SPACEWASM_TARGET=<triple> Target architecture (default: $(SPACEWASM_TARGET))"
@echo ""
@echo "Fuzzing:"
@echo " make fuzz Run the no_traps fuzzer"
@echo " make fuzz-validate Run the validate fuzzer"
@echo " make fuzz-validate-differential Run the validate differential fuzzer (SpaceWasm vs wasmi)"
@echo " make fuzz-malformed Run the malformed-input decoder fuzzer"
@echo ""
@echo "Crash Analysis:"
@echo " make trace CRASH=<file> Convert seed + trace (release)"
@echo " make trace-debug CRASH=<file> Convert seed + trace (debug with ASAN)"
@echo " make seed-to-wasm CRASH=<file> Convert fuzzer seed to Wasm"
@echo " make trace-wasm WASM=<file> Trace Wasm file (release)"
@echo " make trace-wasm-debug WASM=<file> Trace Wasm file (debug with ASAN)"
@echo ""
@echo "Examples:"
@echo " make trace CRASH=fuzz/artifacts/no_traps/crash-abc123"
@echo " make trace-debug CRASH=crash-abc123 LIMIT=100"
@echo " make trace-wasm WASM=output.wasm LIMIT=50"
@echo ""
@echo "C API:"
@echo " make gen-header Regenerate crates/spacewasm_c_api/include/spacewasm.h with cbindgen"
@echo ""
@echo "Utilities:"
@echo " make clean-artifacts Delete all fuzzer artifacts"
# Run fuzzer
fuzz:
cargo +nightly fuzz run no_traps --target $(SPACEWASM_TARGET)
fuzz-validate:
cargo +nightly fuzz run validate --target $(SPACEWASM_TARGET)
fuzz-validate-differential:
cargo +nightly fuzz run validate_differential --target $(SPACEWASM_TARGET)
fuzz-malformed:
cargo +nightly fuzz run malformed --target $(SPACEWASM_TARGET)
# Convert seed to Wasm and trace execution (release mode)
trace:
@if [ -z "$(CRASH)" ]; then \
echo "Error: CRASH variable required"; \
echo "Usage: make trace CRASH=fuzz/artifacts/no_traps/crash-xxx"; \
exit 1; \
fi
@echo "Converting seed to Wasm and tracing execution (release mode)..."
@cargo run --release -p spacewasm-fuzzing --bin seed_to_wasm --target $(SPACEWASM_TARGET) -- $(if $(TARGET),--target $(TARGET)) $(CRASH) --stdout 2>/dev/null | \
cargo run --release -p spacewasm_util --bin spacewasm-trace --target $(SPACEWASM_TARGET) -- --stdin --limit $(or $(LIMIT),50)
# Convert seed to Wasm and trace execution (debug mode with ASAN)
trace-debug:
@if [ -z "$(CRASH)" ]; then \
echo "Error: CRASH variable required"; \
echo "Usage: make trace-debug CRASH=fuzz/artifacts/no_traps/crash-xxx"; \
exit 1; \
fi
@echo "Converting seed to Wasm and tracing execution (debug mode with ASAN)..."
@cargo run -p spacewasm-fuzzing --bin seed_to_wasm --target $(SPACEWASM_TARGET) -- $(if $(TARGET),--target $(TARGET)) $(CRASH) --stdout 2>/dev/null | \
RUSTFLAGS="-Zsanitizer=address" cargo +nightly run --target $(SPACEWASM_TARGET) -p spacewasm_util --bin spacewasm-trace -- --stdin --limit $(or $(LIMIT),50)
# Convert fuzzer seed to Wasm
seed-to-wasm:
@if [ -z "$(CRASH)" ]; then \
echo "Error: CRASH variable required"; \
echo "Usage: make seed-to-wasm CRASH=fuzz/artifacts/no_traps/crash-xxx [OUT=output.wasm]"; \
exit 1; \
fi
@if [ -n "$(OUT)" ]; then \
cargo run --release -p spacewasm-fuzzing --bin seed_to_wasm --target $(SPACEWASM_TARGET) -- $(if $(TARGET),--target $(TARGET)) $(CRASH) $(OUT); \
else \
cargo run --release -p spacewasm-fuzzing --bin seed_to_wasm --target $(SPACEWASM_TARGET) -- $(if $(TARGET),--target $(TARGET)) $(CRASH) $(CRASH).wasm; \
fi
# Trace Wasm file execution (release mode)
trace-wasm:
@if [ -z "$(WASM)" ]; then \
echo "Error: WASM variable required"; \
echo "Usage: make trace-wasm WASM=file.wasm [LIMIT=50]"; \
exit 1; \
fi
cargo run --release -p spacewasm_util --bin spacewasm-trace --target $(SPACEWASM_TARGET) -- $(WASM) --limit $(or $(LIMIT),200)
# Trace Wasm file execution (debug mode with ASAN)
trace-wasm-debug:
@if [ -z "$(WASM)" ]; then \
echo "Error: WASM variable required"; \
echo "Usage: make trace-wasm-debug WASM=file.wasm [LIMIT=50]"; \
exit 1; \
fi
RUSTFLAGS="-Zsanitizer=address" cargo run --target $(SPACEWASM_TARGET) -p spacewasm_util --bin spacewasm-trace -- $(WASM) --limit $(or $(LIMIT),200)
# Regenerate the C API header from the Rust source with cbindgen. The header is
# written as a side effect of building spacewasm_c_api with the `codegen` feature.
gen-header:
cargo build -p spacewasm_c_api --features codegen
@echo "Regenerated crates/spacewasm_c_api/include/spacewasm.h"
# Clean fuzzer artifacts
clean-artifacts:
rm -rf fuzz/artifacts/*
@echo "Cleaned fuzzer artifacts"