fix(fuzzer): resolve zapret2 lua library and blob candidate paths, capture daemon output
This commit is contained in:
@@ -18,6 +18,7 @@ let object_or_empty = common.object_or_empty;
|
|||||||
let array_or_empty = common.array_or_empty;
|
let array_or_empty = common.array_or_empty;
|
||||||
|
|
||||||
const CONFIG_NAME = getenv("TACHYON_CONFIG_NAME") || "tachyon";
|
const CONFIG_NAME = getenv("TACHYON_CONFIG_NAME") || "tachyon";
|
||||||
|
const LIB_DIR = getenv("TACHYON_LIB") || "/usr/lib/tachyon";
|
||||||
const STATE_DIR = getenv("TACHYON_FUZZER_STATE_DIR") || "/var/run/tachyon";
|
const STATE_DIR = getenv("TACHYON_FUZZER_STATE_DIR") || "/var/run/tachyon";
|
||||||
const STATE_FILE = STATE_DIR + "/fuzzer-state.json";
|
const STATE_FILE = STATE_DIR + "/fuzzer-state.json";
|
||||||
const PID_FILE = STATE_DIR + "/fuzzer-worker.pid";
|
const PID_FILE = STATE_DIR + "/fuzzer-worker.pid";
|
||||||
@@ -69,34 +70,42 @@ function get_zapret2_lua_flags(args_str) {
|
|||||||
|
|
||||||
let candidate_dirs = [
|
let candidate_dirs = [
|
||||||
getenv("ZAPRET2_PROVIDER_LUA_DIR"),
|
getenv("ZAPRET2_PROVIDER_LUA_DIR"),
|
||||||
|
LIB_DIR + "/providers/zapret2/lua",
|
||||||
|
"/usr/lib/tachyon/providers/zapret2/lua",
|
||||||
"/opt/zapret2/lua",
|
"/opt/zapret2/lua",
|
||||||
"/usr/share/zapret2/lua",
|
|
||||||
"/etc/zapret2/lua",
|
|
||||||
"/opt/zapret/lua",
|
"/opt/zapret/lua",
|
||||||
"/usr/share/zapret/lua"
|
"/usr/share/zapret2/lua",
|
||||||
|
"/usr/share/zapret/lua",
|
||||||
|
"/etc/zapret2/lua",
|
||||||
|
"/etc/zapret/lua",
|
||||||
|
"/usr/lib/zapret2/lua",
|
||||||
|
"/usr/lib/zapret/lua"
|
||||||
|
];
|
||||||
|
|
||||||
|
let lua_scripts = [
|
||||||
|
"zapret-lib.lua",
|
||||||
|
"zapret-antidpi.lua",
|
||||||
|
"zapret-auto.lua"
|
||||||
];
|
];
|
||||||
|
|
||||||
let flags = "";
|
let flags = "";
|
||||||
for (let d in candidate_dirs) {
|
for (let script in lua_scripts) {
|
||||||
if (!d || fs.stat(d) == null)
|
let found = null;
|
||||||
continue;
|
for (let d in candidate_dirs) {
|
||||||
let lib_lua = d + "/zapret-lib.lua";
|
if (!d || fs.stat(d) == null)
|
||||||
let antidpi_lua = d + "/zapret-antidpi.lua";
|
continue;
|
||||||
let auto_lua = d + "/zapret-auto.lua";
|
let p = d + "/" + script;
|
||||||
let l_actual = fs.stat(lib_lua) != null ? lib_lua : (fs.stat(lib_lua + ".gz") != null ? (lib_lua + ".gz") : null);
|
if (fs.stat(p) != null) {
|
||||||
let a_actual = fs.stat(antidpi_lua) != null ? antidpi_lua : (fs.stat(antidpi_lua + ".gz") != null ? (antidpi_lua + ".gz") : null);
|
found = p;
|
||||||
let au_actual = fs.stat(auto_lua) != null ? auto_lua : (fs.stat(auto_lua + ".gz") != null ? (auto_lua + ".gz") : null);
|
break;
|
||||||
if (l_actual) flags += sprintf("--lua-init=@%s ", l_actual);
|
}
|
||||||
if (a_actual) flags += sprintf("--lua-init=@%s ", a_actual);
|
if (fs.stat(p + ".gz") != null) {
|
||||||
if (au_actual) flags += sprintf("--lua-init=@%s ", au_actual);
|
found = p + ".gz";
|
||||||
if (flags != "")
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
if (flags == "" && fs.stat("/opt/zapret2/lua") != null) {
|
if (found != null)
|
||||||
let l_opt = fs.stat("/opt/zapret2/lua/zapret-lib.lua.gz") != null ? "/opt/zapret2/lua/zapret-lib.lua.gz" : "/opt/zapret2/lua/zapret-lib.lua";
|
flags += sprintf("--lua-init=@%s ", found);
|
||||||
let a_opt = fs.stat("/opt/zapret2/lua/zapret-antidpi.lua.gz") != null ? "/opt/zapret2/lua/zapret-antidpi.lua.gz" : "/opt/zapret2/lua/zapret-antidpi.lua";
|
|
||||||
let au_opt = fs.stat("/opt/zapret2/lua/zapret-auto.lua.gz") != null ? "/opt/zapret2/lua/zapret-auto.lua.gz" : "/opt/zapret2/lua/zapret-auto.lua";
|
|
||||||
flags = sprintf("--lua-init=@%s --lua-init=@%s --lua-init=@%s ", l_opt, a_opt, au_opt);
|
|
||||||
}
|
}
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
@@ -237,10 +246,13 @@ function get_zapret2_blob_dir() {
|
|||||||
let candidate_dirs = [
|
let candidate_dirs = [
|
||||||
getenv("ZAPRET2_PROVIDER_FILES_DIR") ? (getenv("ZAPRET2_PROVIDER_FILES_DIR") + "/fake") : null,
|
getenv("ZAPRET2_PROVIDER_FILES_DIR") ? (getenv("ZAPRET2_PROVIDER_FILES_DIR") + "/fake") : null,
|
||||||
"/opt/zapret2/files/fake",
|
"/opt/zapret2/files/fake",
|
||||||
"/usr/share/zapret2/files/fake",
|
|
||||||
"/etc/zapret2/files/fake",
|
|
||||||
"/opt/zapret/files/fake",
|
"/opt/zapret/files/fake",
|
||||||
"/usr/share/zapret/files/fake"
|
"/usr/share/zapret2/files/fake",
|
||||||
|
"/usr/share/zapret/files/fake",
|
||||||
|
"/etc/zapret2/files/fake",
|
||||||
|
"/etc/zapret/files/fake",
|
||||||
|
LIB_DIR + "/providers/zapret2/files/fake",
|
||||||
|
"/usr/lib/tachyon/providers/zapret2/files/fake"
|
||||||
];
|
];
|
||||||
for (let d in candidate_dirs) {
|
for (let d in candidate_dirs) {
|
||||||
if (d && fs.stat(d) != null) return d;
|
if (d && fs.stat(d) != null) return d;
|
||||||
@@ -250,14 +262,31 @@ function get_zapret2_blob_dir() {
|
|||||||
|
|
||||||
function resolve_zapret2_blobs(args_str) {
|
function resolve_zapret2_blobs(args_str) {
|
||||||
if (!args_str || args_str == "") return "";
|
if (!args_str || args_str == "") return "";
|
||||||
let bdir = get_zapret2_blob_dir();
|
let candidate_dirs = [
|
||||||
|
getenv("ZAPRET2_PROVIDER_FILES_DIR") ? (getenv("ZAPRET2_PROVIDER_FILES_DIR") + "/fake") : null,
|
||||||
|
"/opt/zapret2/files/fake",
|
||||||
|
"/opt/zapret/files/fake",
|
||||||
|
"/usr/share/zapret2/files/fake",
|
||||||
|
"/usr/share/zapret/files/fake",
|
||||||
|
"/etc/zapret2/files/fake",
|
||||||
|
"/etc/zapret/files/fake",
|
||||||
|
LIB_DIR + "/providers/zapret2/files/fake",
|
||||||
|
"/usr/lib/tachyon/providers/zapret2/files/fake"
|
||||||
|
];
|
||||||
let blob_flags = "";
|
let blob_flags = "";
|
||||||
for (let name, info in KNOWN_BLOB_FILES) {
|
for (let name, info in KNOWN_BLOB_FILES) {
|
||||||
if ((index(args_str, "blob=" + name) >= 0 || index(args_str, "seqovl_pattern=" + name) >= 0) &&
|
if ((index(args_str, "blob=" + name) >= 0 || index(args_str, "seqovl_pattern=" + name) >= 0) &&
|
||||||
index(args_str, "--blob=" + name + ":") < 0) {
|
index(args_str, "--blob=" + name + ":") < 0) {
|
||||||
let blob_path = bdir + "/" + info.file;
|
let actual_path = null;
|
||||||
if (fs.stat(blob_path) != null || fs.stat("/opt/zapret2/files/fake/" + info.file) != null) {
|
for (let d in candidate_dirs) {
|
||||||
let actual_path = fs.stat(blob_path) != null ? blob_path : ("/opt/zapret2/files/fake/" + info.file);
|
if (!d || fs.stat(d) == null) continue;
|
||||||
|
let p = d + "/" + info.file;
|
||||||
|
if (fs.stat(p) != null) {
|
||||||
|
actual_path = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (actual_path != null) {
|
||||||
blob_flags += sprintf("--blob=%s:@%s ", name, actual_path);
|
blob_flags += sprintf("--blob=%s:@%s ", name, actual_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2400,7 +2429,7 @@ function run_probe(engine, args_str, target_key, custom_url) {
|
|||||||
fwmark_flag = sprintf("--dpi-desync-fwmark=%s ", FUZZER_FWMARK);
|
fwmark_flag = sprintf("--dpi-desync-fwmark=%s ", FUZZER_FWMARK);
|
||||||
}
|
}
|
||||||
|
|
||||||
let spawn_cmd = sprintf("cd /tmp && %s --qnum=%d %s%s%s%s%s --pidfile=%s --daemon 2>%s", bin, qnum, fwmark_flag, lua_init_flags, blob_flags, filter_prefix, args_str, pid_path, shell_quote(stderr_log));
|
let spawn_cmd = sprintf("cd /tmp && %s --qnum=%d %s%s%s%s%s --pidfile=%s --daemon >%s 2>&1", bin, qnum, fwmark_flag, lua_init_flags, blob_flags, filter_prefix, args_str, pid_path, shell_quote(stderr_log));
|
||||||
system(common.background_command(spawn_cmd));
|
system(common.background_command(spawn_cmd));
|
||||||
|
|
||||||
let pid_running = false;
|
let pid_running = false;
|
||||||
@@ -2424,8 +2453,18 @@ function run_probe(engine, args_str, target_key, custom_url) {
|
|||||||
let err_content = fs.readfile(stderr_log);
|
let err_content = fs.readfile(stderr_log);
|
||||||
let err_msg = err_content ? trim(as_string(err_content)) : "";
|
let err_msg = err_content ? trim(as_string(err_content)) : "";
|
||||||
if (err_msg != "") {
|
if (err_msg != "") {
|
||||||
let first_line = split(err_msg, "\n")[0];
|
let lines = split(err_msg, "\n");
|
||||||
result.error = sprintf("Daemon failed to start: %s", first_line);
|
let err_line = "";
|
||||||
|
for (let i = length(lines) - 1; i >= 0; i--) {
|
||||||
|
let l = trim(lines[i]);
|
||||||
|
if (l == "") continue;
|
||||||
|
if (index(l, "version") < 0 && index(l, "Running as") < 0 && index(l, "LUA v") < 0 && index(l, "JIT:") < 0 && index(l, "we have") < 0 && index(l, "initializing") < 0) {
|
||||||
|
err_line = l;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (err_line == "") err_line = split(err_msg, "\n")[0];
|
||||||
|
result.error = sprintf("Daemon failed to start: %s", err_line);
|
||||||
} else {
|
} else {
|
||||||
result.error = sprintf("Daemon %s failed to start (invalid arguments or missing Lua library)", is_z2 ? "nfqws2" : "nfqws");
|
result.error = sprintf("Daemon %s failed to start (invalid arguments or missing Lua library)", is_z2 ? "nfqws2" : "nfqws");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,10 +34,13 @@ function get_blob_dir() {
|
|||||||
let candidate_dirs = [
|
let candidate_dirs = [
|
||||||
getenv("ZAPRET2_PROVIDER_FILES_DIR") ? (getenv("ZAPRET2_PROVIDER_FILES_DIR") + "/fake") : null,
|
getenv("ZAPRET2_PROVIDER_FILES_DIR") ? (getenv("ZAPRET2_PROVIDER_FILES_DIR") + "/fake") : null,
|
||||||
"/opt/zapret2/files/fake",
|
"/opt/zapret2/files/fake",
|
||||||
"/usr/share/zapret2/files/fake",
|
|
||||||
"/etc/zapret2/files/fake",
|
|
||||||
"/opt/zapret/files/fake",
|
"/opt/zapret/files/fake",
|
||||||
"/usr/share/zapret/files/fake"
|
"/usr/share/zapret2/files/fake",
|
||||||
|
"/usr/share/zapret/files/fake",
|
||||||
|
"/etc/zapret2/files/fake",
|
||||||
|
"/etc/zapret/files/fake",
|
||||||
|
LIB_DIR + "/providers/zapret2/files/fake",
|
||||||
|
"/usr/lib/tachyon/providers/zapret2/files/fake"
|
||||||
];
|
];
|
||||||
for (let d in candidate_dirs) {
|
for (let d in candidate_dirs) {
|
||||||
if (d && fs.stat(d) != null) return d;
|
if (d && fs.stat(d) != null) return d;
|
||||||
@@ -47,14 +50,31 @@ function get_blob_dir() {
|
|||||||
|
|
||||||
function resolve_blobs(args_str) {
|
function resolve_blobs(args_str) {
|
||||||
if (!args_str || args_str == "") return [];
|
if (!args_str || args_str == "") return [];
|
||||||
let bdir = get_blob_dir();
|
let candidate_dirs = [
|
||||||
|
getenv("ZAPRET2_PROVIDER_FILES_DIR") ? (getenv("ZAPRET2_PROVIDER_FILES_DIR") + "/fake") : null,
|
||||||
|
"/opt/zapret2/files/fake",
|
||||||
|
"/opt/zapret/files/fake",
|
||||||
|
"/usr/share/zapret2/files/fake",
|
||||||
|
"/usr/share/zapret/files/fake",
|
||||||
|
"/etc/zapret2/files/fake",
|
||||||
|
"/etc/zapret/files/fake",
|
||||||
|
LIB_DIR + "/providers/zapret2/files/fake",
|
||||||
|
"/usr/lib/tachyon/providers/zapret2/files/fake"
|
||||||
|
];
|
||||||
let result = [];
|
let result = [];
|
||||||
for (let name, info in KNOWN_BLOB_FILES) {
|
for (let name, info in KNOWN_BLOB_FILES) {
|
||||||
if ((index(args_str, "blob=" + name) >= 0 || index(args_str, "seqovl_pattern=" + name) >= 0) &&
|
if ((index(args_str, "blob=" + name) >= 0 || index(args_str, "seqovl_pattern=" + name) >= 0) &&
|
||||||
index(args_str, "--blob=" + name + ":") < 0) {
|
index(args_str, "--blob=" + name + ":") < 0) {
|
||||||
let blob_path = bdir + "/" + info.file;
|
let actual_path = null;
|
||||||
if (fs.stat(blob_path) != null || fs.stat("/opt/zapret2/files/fake/" + info.file) != null) {
|
for (let d in candidate_dirs) {
|
||||||
let actual_path = fs.stat(blob_path) != null ? blob_path : ("/opt/zapret2/files/fake/" + info.file);
|
if (!d || fs.stat(d) == null) continue;
|
||||||
|
let p = d + "/" + info.file;
|
||||||
|
if (fs.stat(p) != null) {
|
||||||
|
actual_path = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (actual_path != null) {
|
||||||
push(result, sprintf("--blob=%s:@%s", name, actual_path));
|
push(result, sprintf("--blob=%s:@%s", name, actual_path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,4 +146,32 @@ if (!Array.isArray(val.byedpi) || val.byedpi.length < 20) {
|
|||||||
console.log("Generated matrix: Zapret2=" + val.zapret2.length + ", Zapret=" + val.zapret.length + ", ByeDPI=" + val.byedpi.length);
|
console.log("Generated matrix: Zapret2=" + val.zapret2.length + ", Zapret=" + val.zapret.length + ", ByeDPI=" + val.byedpi.length);
|
||||||
NODE
|
NODE
|
||||||
|
|
||||||
|
# 6. Check zapret2 Lua library resolution from LIB_DIR
|
||||||
|
lua_res="$(TACHYON_LIB="$TACHYON_LIB" ucode -L "$TACHYON_LIB" -e '
|
||||||
|
let fs = require("fs");
|
||||||
|
let LIB_DIR = getenv("TACHYON_LIB") || "/usr/lib/tachyon";
|
||||||
|
let candidate_dirs = [
|
||||||
|
getenv("ZAPRET2_PROVIDER_LUA_DIR"),
|
||||||
|
LIB_DIR + "/providers/zapret2/lua",
|
||||||
|
"/usr/lib/tachyon/providers/zapret2/lua"
|
||||||
|
];
|
||||||
|
let lua_scripts = [ "zapret-lib.lua", "zapret-antidpi.lua", "zapret-auto.lua" ];
|
||||||
|
let flags = "";
|
||||||
|
for (let script in lua_scripts) {
|
||||||
|
let found = null;
|
||||||
|
for (let d in candidate_dirs) {
|
||||||
|
if (!d || fs.stat(d) == null) continue;
|
||||||
|
let p = d + "/" + script;
|
||||||
|
if (fs.stat(p) != null) { found = p; break; }
|
||||||
|
if (fs.stat(p + ".gz") != null) { found = p + ".gz"; break; }
|
||||||
|
}
|
||||||
|
if (found != null) flags += sprintf("--lua-init=@%s ", found);
|
||||||
|
}
|
||||||
|
print(flags);
|
||||||
|
')"
|
||||||
|
echo "$lua_res" | grep -q 'zapret-lib.lua' || fail "missing zapret-lib.lua in resolved lua flags"
|
||||||
|
echo "$lua_res" | grep -q 'zapret-antidpi.lua' || fail "missing zapret-antidpi.lua in resolved lua flags"
|
||||||
|
echo "$lua_res" | grep -q 'zapret-auto.lua' || fail "missing zapret-auto.lua in resolved lua flags"
|
||||||
|
|
||||||
printf 'PASS: fuzzer_strategy_cli\n'
|
printf 'PASS: fuzzer_strategy_cli\n'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user