refactor: 迁移 winapi 到 windows-sys,修复配置解析漏洞

- 依赖替换为 windows-sys 0.61,main.rs 全面适配新 API
  - 配置解析错误显式传播:env/args 类型错误、数组空洞、非法键不再静默
  吞错
  - 修正空环境变量与空参数语义,补充 UTF-8 与路径拼接校验
  - require 容错移至 Rust 侧,模块加载失败记录日志并跳过
  - 新增配置解析与运行时单元测试(19 个)
This commit is contained in:
2026-08-14 20:09:34 +08:00
parent ed5439eaa1
commit 5e69a6a980
13 changed files with 691 additions and 278 deletions

View File

@@ -10,7 +10,7 @@ return {
-- 1. 标准相对路径 + 正斜杠拼接 (最推荐,绿色便携)
---------------------------------------------------
["git"] = {
path = base_dir .. "/git/bin/git.exe",
target = base_dir .. "/git/bin/git.exe",
-- 追加参数
args = { "--no-pager" },
-- 注入环境变量,使用 get_env 获取宿主机当前值
@@ -24,7 +24,7 @@ return {
---------------------------------------------------
["python"] = {
-- 在 [[]] 内部,\ 不需要写成 \\,直接粘贴即可
path = [[C:\Python310\python.exe]],
target = [[C:\Python310\python.exe]],
args = { "-B" },
-- 空字典也是合法的,等同于不设置
env = {
@@ -46,14 +46,15 @@ return {
-- 3. 极简参数覆盖 (没有 args 和 env)
---------------------------------------------------
["curl"] = {
path = base_dir .. "/curl/curl.exe"
target = base_dir .. "/curl/curl.exe"
},
---------------------------------------------------
-- 4. 模块化路由 (得益于 Rust 注入的 package.path)
-- require 能够直接在当前目录 或 conf.d/ 目录下寻找 node.lua
-- require 能够直接在当前目录 或 tools/ 目录下寻找 node.lua
-- 模块缺失时由 Rust 侧记录日志并跳过该条目(见 runtime.rs
---------------------------------------------------
["node"] = require("node"),
["npm"] = require("npm")
}
}