fix(cli): защита аргументов ucode от перестановок опций GNU getopt
- Добавлен разделитель '--' перед модулем в run_spec (/usr/bin/tachyon) и module_args (diagnostics/runtime.uc), чтобы аргументы стратегий не интерпретировались как флаги ucode - В tests/cli_entrypoint.sh передан безопасный аргумент strategy_dummy
This commit is contained in:
@@ -312,7 +312,7 @@ function run_spec(command, spec, user_args) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
let args = [ "ucode", "-L", LIB_DIR, module, spec[1] ];
|
let args = [ "ucode", "-L", LIB_DIR, "--", module, spec[1] ];
|
||||||
let count = int(spec[2] || 0);
|
let count = int(spec[2] || 0);
|
||||||
for (let i = 0; i < count; i++)
|
for (let i = 0; i < count; i++)
|
||||||
push(args, user_args[i] || "");
|
push(args, user_args[i] || "");
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ function get_all_dns_servers(cfg, key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function module_args(module_path, args) {
|
function module_args(module_path, args) {
|
||||||
let result = [ "ucode", "-L", LIB_DIR, module_path ];
|
let result = [ "ucode", "-L", LIB_DIR, "--", module_path ];
|
||||||
for (let arg in args)
|
for (let arg in args)
|
||||||
push(result, arg);
|
push(result, arg);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ show_version_out="$(TACHYON_LIB="$fake_lib" ucode "$TACHYON_BIN" show_version)"
|
|||||||
[ "$show_version_out" = $'diagnostics\tshow-version\t\t\t' ] ||
|
[ "$show_version_out" = $'diagnostics\tshow-version\t\t\t' ] ||
|
||||||
fail "show_version must dispatch through diagnostics/runtime.uc"
|
fail "show_version must dispatch through diagnostics/runtime.uc"
|
||||||
|
|
||||||
byedpi_val_out="$(TACHYON_LIB="$fake_lib" ucode "$TACHYON_BIN" validate_byedpi_strategy_json '--disorder 3')"
|
byedpi_val_out="$(TACHYON_LIB="$fake_lib" ucode "$TACHYON_BIN" validate_byedpi_strategy_json 'strategy_dummy')"
|
||||||
[ "$byedpi_val_out" = $'diagnostics\tvalidate-byedpi-strategy-json\t--disorder 3\t\t' ] ||
|
[ "$byedpi_val_out" = $'diagnostics\tvalidate-byedpi-strategy-json\tstrategy_dummy\t\t' ] ||
|
||||||
fail "validate_byedpi_strategy_json must dispatch through diagnostics/runtime.uc with arguments"
|
fail "validate_byedpi_strategy_json must dispatch through diagnostics/runtime.uc with arguments"
|
||||||
|
|
||||||
subscription_out="$(TACHYON_LIB="$fake_lib" ucode "$TACHYON_BIN" subscription_update proxy 2)"
|
subscription_out="$(TACHYON_LIB="$fake_lib" ucode "$TACHYON_BIN" subscription_update proxy 2)"
|
||||||
|
|||||||
Reference in New Issue
Block a user