// Control-socket payload verbs: arbitrary JSON from group members, applied by root. #include "strawberry/policy.hpp" #include #include #include #include #include extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { if (size == 0) return 0; static const char* verbs[] = {"allowlist-add", "allowlist-remove", "feed-add", "feed-remove", "feed-set-enabled", "protection-set", "contain-add", "bogus"}; static const std::string dir = "/tmp/strawberry-fuzz-policy-" + std::to_string(::getpid()); std::filesystem::create_directories(dir); strawberry::PolicyStore store(dir + "/policy.json"); std::string error; if (!store.load(&error)) std::abort(); const std::string payload(reinterpret_cast(data) + 1, size - 1); (void) store.apply(verbs[data[0] % 8], payload, 1000, &error); // Whatever was accepted must reload. strawberry::PolicyStore again(dir + "/policy.json"); if (!again.load(&error)) std::abort(); std::filesystem::remove(dir + "/policy.json"); return 0; }