fix: 全仓审计加固与死代码清理,版本 1.1.87

- 回滚/备份:空 bak 改名 .bad 跳过;升级刷新 bak 补上单数 marker 补丁;统一原子写
- 补丁命中:optional 命中不符记软失败;#42 插入型替换加探针防重复插入
- Windows:进程枚举改用 | 分隔 + UTF-8,修复中文路径换包不杀旧进程;换包失败拉起原版
- 安全:asar 解包防越界;红队路径校验 realpath 防空 symlink;更新仅 https;报告回放去换行注入
- 提示词钩子:停用后 rewriteFn 返回原装配文本并清理 assemble guard;缓存签名纳入红队/策略/override
- 红队:listEngagements 默认不算统计;listVulns/报告支持 evidenceLimit
- 子代理名额占位即时生效并回退;--apply 有失败项退出码 1
- 清理:删除 lib/mnemon-settings.js 及 13 处死代码/未使用 import;移除 test 目录与 test 脚本
This commit is contained in:
叫我小杨同学 committed 2026-11-01 21:47:03 +08:00
1 parent 71d3a55884
commit f806b048ac
48 files changed
+890 -1652

No files matched your search

+5 -4
View File
@@ -9,6 +9,7 @@
*/
import fs from "node:fs";
import path from "node:path";
import { atomicWriteSync } from "./core.js";
export const PURGE_NAME = "dsh-purge";
@@ -112,7 +113,7 @@ export function ensureProfileBodyInsert(profileDir) {
...blockLines,
...shape.lines.slice(shape.emptyFlowIndex + 1),
].join("\n");
fs.writeFileSync(fp, `${out.endsWith("\n") ? out : `${out}\n`}`, "utf8");
atomicWriteSync(fp, `${out.endsWith("\n") ? out : `${out}\n`}`, "utf8");
return { ok: true, wrote: true, path: fp };
}
if (shape.kind === "flow-seq" || shape.kind === "unknown") {
@@ -121,7 +122,7 @@ export function ensureProfileBodyInsert(profileDir) {
}
// 空文件 / 只有注释 → 直接写 insert 块;正常块序列 → 沿用旧的追加行为
const prefix = text && !text.endsWith("\n") ? "\n" : "";
fs.writeFileSync(fp, `${text}${prefix}${text ? "\n" : ""}${INSERT_BLOCK}`, "utf8");
atomicWriteSync(fp, `${text}${prefix}${text ? "\n" : ""}${INSERT_BLOCK}`, "utf8");
return { ok: true, wrote: true, path: fp };
}
@@ -167,7 +168,7 @@ export function ensureProfileBundles(profileDir) {
const bundles = Array.isArray(pkg.dsh.profile.bundles) ? pkg.dsh.profile.bundles : [];
if (bundles.includes(PURGE_NAME)) return { ok: true, wrote: false, path: fp };
pkg.dsh.profile.bundles = [...bundles, PURGE_NAME];
fs.writeFileSync(fp, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
atomicWriteSync(fp, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
return { ok: true, wrote: true, path: fp };
}
@@ -344,7 +345,7 @@ export function ensurePnpmAllowBuild(profileDir) {
if (next === current) return { ok: true, wrote: false, path: fp };
// 写前校验不过就不写盘,宁可保持现状(#180)
if (!validateAllowBuildRewrite(next)) return { ok: false, wrote: false, path: fp, reason: "allowBuilds-invalid" };
fs.writeFileSync(fp, next, "utf8");
atomicWriteSync(fp, next, "utf8");
return { ok: true, wrote: true, path: fp };
}