test(fuzz): add a Clang/libFuzzer target for the header-only parsers
This commit is contained in:
1 parent
fd9e8673c0
commit
c2b80416a5
9 files changed
+64
-1
No files matched your search
@@ -334,6 +334,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
|
||||
|
||||
- **Wave 120 (WiX/MSI-Style Packaging & VoidLibrary CI)**: added `vbs install --archive FILE --archive-format wix`, which emits a WiX v3 source (deterministic Product/Upgrade GUIDs, directory tree, component per file, feature/component group) - the CPack WIX model consumed by candle/light on Windows; the XML is validated by a real parser and asserted in the install test. A `.gitea/workflows/vbs.yml` template (native build, smoke test, install check) was pushed to the VoidLibrary `build-vbs` branch.
|
||||
|
||||
- **Wave 121 (Coverage-Guided Fuzzing with Clang/libFuzzer)**: added `fuzz/fuzz_parsers.cpp` (JSON, SemVer range/strict) plus `fuzz/run.sh` (Clang 23 `-fsanitize=fuzzer,address,undefined`, seeded corpus, `VOID_INCLUDE_DIR`). First run: 1,541,020 executions in 31 s with no findings, and libFuzzer produced a recommended dictionary. TOML/lockfile/tar stay covered by the deterministic mutation harness because their implementations are not header-only.
|
||||
|
||||
## Remaining future scope
|
||||
|
||||
- **Superiority plan ([22-superiority-and-gaps.md](../roadmap/22-superiority-and-gaps.md), 2026-12-05)**: revised platform strategy - **macOS deferred**, **Windows via MinGW-w64 cross-compilation + Wine execution** (`dev cpp-gcc -p pkgsCross.mingwW64.stdenv.cc`, `dev cpp-gcc -p wine64`), native MSVC deferred; plus packaging parity (ZIP/DEB/RPM), IDE ecosystem, migration tooling, test-runner parity, benchmarks, CI runners, and remote execution in prioritized order.
|
||||
|
||||
@@ -123,4 +123,5 @@ Base HEAD: `fe0d1a6`
|
||||
| Wave 118 (VoidLibrary in-repo build description) | Branch `build-vbs` in Void/Library with build.cpp + module table + smoke test; #61 updated | PUSHED & VERIFIED IN CLONE (branch content confirmed via Gitea API) | [Void/Library branch build-vbs](https://git.faumaray.com/Void/Library/src/branch/build-vbs), `contrib/voidlibrary-migration/`, Void/Library#61 |
|
||||
| Wave 119 (VoidLibrary install rules + profiles) | install rules, `build.profiles.cpp`, verified 320-file prefix and a dpkg-valid DEB; streaming DEB writer; LICENSE issue #63 | COMPLETE & VERIFIED IN CLONE | `contrib/voidlibrary-migration/`, [Void/Library build-vbs](https://git.faumaray.com/Void/Library/src/branch/build-vbs), `src/Install/Installer.cpp`, Void/Library#63 |
|
||||
| Wave 120 (WiX/MSI-style packaging + VoidLibrary CI) | `--archive-format wix` WiX v3 source generator; `.gitea/workflows/vbs.yml` template on the branch | COMPLETE & VERIFIED for the generator (XML parsed, install test passes, full CTest 8/8); CI template unexecuted | `src/Install/Installer.cpp`, `src/Main.cpp`, `tests/FullV1Tests.cpp`, [Void/Library build-vbs](https://git.faumaray.com/Void/Library/src/branch/build-vbs), docs |
|
||||
| Wave 121 (libFuzzer fuzzing) | `fuzz/fuzz_parsers.cpp` + `fuzz/run.sh` for JSON and SemVer with Clang/libFuzzer | COMPLETE & VERIFIED (1,541,020 runs, 0 findings) | `fuzz/`, docs |
|
||||
| Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions) |"}] Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) |
|
||||
@@ -1662,6 +1662,20 @@ vbs ide plugin --project <proj> --build-dir <build> --editor vscode --output <di
|
||||
Version, UpgradeCode, a `Source="bin/cli_hi"` File and the ComponentGroup (**passed**, 7.16 s).
|
||||
- Full CTest: **8 / 8 passed** in 281.07 s.
|
||||
|
||||
## Coverage-Guided Fuzzing (Clang 23.1.5 + libFuzzer, pin `0002e74`)
|
||||
|
||||
```sh
|
||||
VOID_INCLUDE_DIR=/tmp/opencode/vl-pin/include dev cpp -c bash fuzz/run.sh 30
|
||||
```
|
||||
|
||||
- Built `fuzz/fuzz_parsers.cpp` with `clang++ -fsanitize=fuzzer,address,undefined` and ran for
|
||||
30 s: **1,541,020 executions, no crashes or sanitizer reports**, and libFuzzer emitted a
|
||||
recommended dictionary from the observed inputs.
|
||||
- Targets: `Void::Json::Strict::parse`, `Void::Semver::parse_range`, `Void::Semver::parse_strict`
|
||||
(all header-only). TOML, lockfile and tar remain in the deterministic mutation harness because
|
||||
their implementations are not header-only.
|
||||
- No repo build changed, so the last full CTest run (8/8, 281.07 s at `fd9e867`) remains valid.
|
||||
|
||||
## Limits and Unrun Checks
|
||||
|
||||
1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified).
|
||||
|
||||
@@ -82,7 +82,7 @@ Concrete work this implies:
|
||||
5. Migration tooling (**done**: `vbs migrate` renders a `build.cpp` scaffold from a bounded CMakeLists subset) and migrating VoidLibrary onto VBS (**trial extended**: 25+ pure modules build with VBS in a separate clone; upstream #61 tracks the in-repo build description and the remaining externally dependent modules).
|
||||
6. Test-runner parity.
|
||||
7. Benchmarks against CMake/Meson/build2 on documented fixtures (including 10k-target scaling).
|
||||
8. CI on real runners, sanitizer jobs (**sanitizer build run done**), parser fuzzing (**deterministic mutation harness done**; coverage-guided libFuzzer still needs Clang).
|
||||
8. CI on real runners, sanitizer jobs (**sanitizer build run done**), parser fuzzing (**deterministic mutation harness and a Clang/libFuzzer target done**).
|
||||
9. Remote execution workers.
|
||||
|
||||
## 6. Observed baseline (2026-12-05, x86_64, GCC 16.2, Debug, `benchmarks/compare.sh 20`)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// Coverage-guided fuzz target for the standalone parsers (Clang/libFuzzer).
|
||||
// Build and run through fuzz/run.sh.
|
||||
#include <Void/Data/StrictJson.hpp>
|
||||
#include <Void/Text/Semver.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string_view>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) {
|
||||
const std::string_view input{reinterpret_cast<const char *>(data), size};
|
||||
(void)Void::Json::Strict::parse(input);
|
||||
// TOML/lockfile/tar are covered by the deterministic mutation harness
|
||||
// (CoreEngineTests.fuzz_mutated_inputs_never_crash_parsers): their implementations
|
||||
// are not header-only.
|
||||
(void)Void::Semver::parse_range(input);
|
||||
(void)Void::Semver::parse_strict(input);
|
||||
return 0;
|
||||
}
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
# Coverage-guided fuzzing of the standalone parsers with Clang/libFuzzer.
|
||||
# Usage: VOID_INCLUDE_DIR=/path/to/VoidLibrary/include fuzz/run.sh [seconds] [extra libFuzzer args...]
|
||||
set -euo pipefail
|
||||
|
||||
root="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
seconds="${1:-60}"
|
||||
shift || true
|
||||
|
||||
: "${VOID_INCLUDE_DIR:?set VOID_INCLUDE_DIR to the VoidLibrary include directory}"
|
||||
|
||||
out="${FUZZ_OUT:-$root/build/fuzz}"
|
||||
corpus="$out/corpus"
|
||||
mkdir -p "$out" "$corpus"
|
||||
if [ -d "$root/fuzz/seeds" ]; then
|
||||
cp -n "$root/fuzz/seeds/"* "$corpus/" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
clang++ -std=c++26 -O1 -g -fsanitize=fuzzer,address,undefined \
|
||||
-fno-omit-frame-pointer \
|
||||
-I"$root/include" -I"$root/recipes" -I"$VOID_INCLUDE_DIR" \
|
||||
"$root/fuzz/fuzz_parsers.cpp" -o "$out/fuzz_parsers"
|
||||
|
||||
exec "$out/fuzz_parsers" -max_total_time="$seconds" -max_len=65536 "$corpus" "$@"
|
||||
@@ -0,0 +1 @@
|
||||
{"a":[1,true,"x"],"b":{"c":null}}
|
||||
@@ -0,0 +1 @@
|
||||
{"schema_version":1,"revision_hash":"abc","contexts":{}}
|
||||
@@ -0,0 +1 @@
|
||||
^1.2.3
|
||||
Reference in new issue
Block a user