diff options
author | Tor Andersson <tor@ccxvii.net> | 2025-04-26 19:05:51 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2025-04-29 00:39:06 +0200 |
commit | 7a93787dfe5cdaba3eed98ed8edd19674186430b (patch) | |
tree | f13e9ee68453472f77329df73e0dd2a20bda8e9e | |
parent | 1785e14b151a50ae76738a3461b38c44cc4bd587 (diff) | |
download | server-7a93787dfe5cdaba3eed98ed8edd19674186430b.tar.gz |
Add fuzzer assert callback to framework.
-rw-r--r-- | public/common/framework.js | 15 | ||||
-rw-r--r-- | tools/fuzz.js | 4 |
2 files changed, 16 insertions, 3 deletions
diff --git a/public/common/framework.js b/public/common/framework.js index ec9132a..a1601b7 100644 --- a/public/common/framework.js +++ b/public/common/framework.js @@ -7,7 +7,8 @@ const SCENARIOS = [] var G, L, R, V, S = {}, P = {} function on_setup() {} function on_view() {} -function on_query(q) { return null } +function on_query(q) {} +function on_assert() {} */ function log(s) { @@ -193,6 +194,18 @@ exports.query = function (state, role, q) { return result } +exports.assert = function (state) { + if (typeof on_assert === "function") { + G = state + L = G.L + R = null + V = null + _load() + on_assert() + _save() + } +} + function _load() { R = ROLES.indexOf(R) if (Array.isArray(G.active)) diff --git a/tools/fuzz.js b/tools/fuzz.js index 0690697..a547f68 100644 --- a/tools/fuzz.js +++ b/tools/fuzz.js @@ -115,8 +115,8 @@ exports.fuzz = function (fuzzerInputData) { try { ctx.state = rules.action(ctx.state, ctx.active, action, arg) - if (typeof rules.assert_state === "function") - rules.assert_state(ctx.state) + if (typeof rules.assert === "function") + rules.assert(ctx.state) } catch (e) { ctx.state = prev_state return log_crash(e, ctx, action, arg) |