Files
Etienne PerotandgVisor bot 4ba8be6a1e seccomp: Add secfuzz library to fuzz seccomp-bpf programs.
This contains a large auto-generated Go file.
Its goal is to convert BPF instruction coverage to Go line-based
coverage, so that coverage-based guidance works for the Go-based fuzzer.

This isn't used yet, but will be in a different change.

PiperOrigin-RevId: 576715826
2023-10-25 19:38:53 -07:00

51 lines
1.4 KiB
Python

load("//tools:defs.bzl", "go_library")
package(
default_applicable_licenses = ["//:license"],
licenses = ["notice"],
)
go_library(
name = "secfuzz",
testonly = 1,
srcs = [
"secfuzz.go",
"secfuzz_covermeup.go",
"secfuzz_nocoverageguidance.go",
],
visibility = [
"//:sandbox",
],
deps = [
"//pkg/abi/linux",
"//pkg/abi/sentry",
"//pkg/atomicbitops",
"//pkg/bpf",
"//pkg/seccomp",
"//pkg/sync",
],
)
genrule(
name = "secfuzz_covermeup",
srcs = ["secfuzz_covermeup.tmpl.go"],
outs = ["secfuzz_covermeup.go"],
cmd = (
" while IFS= read -r line; do" +
" if echo \"$$line\" | grep -q 'GENERATED_LINES_INSERTED_HERE_THIS_IS_A_LOAD_BEARING_COMMENT'; then" +
" while IFS= read -r i; do" +
" echo -e \"\\\\tcase $$(( $$i + 1 )):\";" +
" echo -e \"\\\\t\\\\tif covered[$$i] {\";" +
" echo -e \"\\\\t\\\\t\\\\tfuzzee.coverage[$$i].Store(true)\";" +
" echo -e \"\\\\t\\\\t}\";" +
" echo -e \"\\\\t\\\\tfallthrough\";" +
" done < <(awk 'BEGIN{for (i = 4095; i >= 1; i --) print i}');" +
" else" +
" echo \"$$line\";" +
" fi;" +
" done" +
" < $(location :secfuzz_covermeup.tmpl.go)" +
" > $@"
),
)