mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 07:40:22 +08:00
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:
1 parent
71d3a55884
commit
f806b048ac
48 files changed
+890
-1652
No files matched your search
+7
-13
@@ -15,7 +15,7 @@ export function wasApplied(state) {
|
||||
return [state.shim_cmd, state.shim_ps1, state.shim_bin].includes("patched");
|
||||
}
|
||||
|
||||
export function shouldDeletePluginTree(dir, dshHome = core.findDshHome()) {
|
||||
export function shouldDeletePluginTree(dir) {
|
||||
if (!dir) return false;
|
||||
let real;
|
||||
try {
|
||||
@@ -24,15 +24,9 @@ export function shouldDeletePluginTree(dir, dshHome = core.findDshHome()) {
|
||||
real = path.resolve(dir);
|
||||
}
|
||||
const n = real.replace(/[/\\]+/g, "/").toLowerCase();
|
||||
if (n.includes("/node_modules/dsh-purge")) return true;
|
||||
let home;
|
||||
try {
|
||||
home = fs.realpathSync(dshHome);
|
||||
} catch {
|
||||
home = path.resolve(dshHome);
|
||||
}
|
||||
const homeN = home.replace(/[/\\]+/g, "/").toLowerCase();
|
||||
return n.startsWith(`${homeN}/profiles/`);
|
||||
// npm link / file: 安装的 realpath 会指到用户源码目录;只认安装树路径,
|
||||
// 不按末段名字猜,避免卸载时把源码仓库整棵删掉。
|
||||
return n.includes("/node_modules/dsh-purge");
|
||||
}
|
||||
|
||||
function isPurgeBundleItem(item) {
|
||||
@@ -81,7 +75,7 @@ function readJson(fp) {
|
||||
}
|
||||
|
||||
function writeJson(fp, value) {
|
||||
fs.writeFileSync(fp, `${JSON.stringify(value, null, 2)}\n`, "utf8");
|
||||
core.atomicWriteSync(fp, `${JSON.stringify(value, null, 2)}\n`, "utf8");
|
||||
}
|
||||
|
||||
function pkgMentionsPurge(pkg) {
|
||||
@@ -175,7 +169,7 @@ function collectCleanupDirs(profiles, dshHome) {
|
||||
} catch {
|
||||
real = path.resolve(nm);
|
||||
}
|
||||
if (shouldDeletePluginTree(real, dshHome)) remember(real);
|
||||
if (shouldDeletePluginTree(real)) remember(real);
|
||||
if (path.resolve(nm).toLowerCase() !== real.toLowerCase()) remember(nm);
|
||||
}
|
||||
|
||||
@@ -183,7 +177,7 @@ function collectCleanupDirs(profiles, dshHome) {
|
||||
remember(dataDir);
|
||||
|
||||
const root = updater.pluginRoot();
|
||||
if (shouldDeletePluginTree(root, dshHome)) remember(root);
|
||||
if (shouldDeletePluginTree(root)) remember(root);
|
||||
|
||||
return cleanup;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user