mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-27 16:10:22 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
554277fcfb | ||
|
|
9d384d0723 | ||
|
|
c17e668a3a | ||
|
|
36870324f2 | ||
|
|
96b5af8962 | ||
|
|
b3f5c2dd3e | ||
|
|
456c312c9b | ||
|
|
2e23b44159 | ||
|
|
de220ae0ef | ||
|
|
4122b01ea7 | ||
|
|
4adb249525 | ||
|
|
8c1aca5bfd | ||
|
|
3cc691c66c | ||
|
|
661eebac15 | ||
|
|
06617553e0 | ||
|
|
95f4cfe1f7 | ||
|
|
3ad257e5a7 | ||
|
|
2595360b79 | ||
|
|
92aafa0101 | ||
|
|
daa44d60cb | ||
|
|
2794ac6055 | ||
|
|
b17b98baa5 | ||
|
|
e3fbbd1fd0 | ||
|
|
567aba33a3 | ||
|
|
f746618988 | ||
|
|
90d0f7b702 | ||
|
|
599c818c34 | ||
|
|
19f5e26b84 | ||
|
|
1726711f52 | ||
|
|
0a291fd07f | ||
|
|
bb850ce8d4 | ||
|
|
8173f6f81c | ||
|
|
265f859ef3 | ||
|
|
2bf8bfb618 | ||
|
|
ed676bcb11 | ||
|
|
f4f43c1733 | ||
|
|
4803ee181f | ||
|
|
6313ac36f0 |
No files matched your search
@@ -14,6 +14,7 @@ scripts/tmp-*.mjs
|
||||
scripts/test-*.mjs
|
||||
.scratch/
|
||||
dsh-redteam-mode-main/
|
||||
/1
|
||||
|
||||
# 外部参考,不是本插件
|
||||
choirboy-prompt/
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
<h1 align="center">⚔️ DeepSeek Harness cybersecurity red-team tool (dsh-purge)</h1>
|
||||
|
||||
<p align="center"><strong>Version 1.1.61</strong></p>
|
||||
<p align="center"><strong>Version 1.1.66</strong></p>
|
||||
|
||||
<p align="center">
|
||||
<em>Local official DeepSeek Harness cybersecurity red-team plugin. Clean host policy, and ship a built-in drill console. Swap prompts per model. Default prompt for Chinese models — 小码酱. Please star ⭐</em>
|
||||
<em>DeepSeek Harness jailbreak: every model, swap prompts per model. Default prompt for 小码酱. Please star ⭐ If you build on this, see Attribution required.</em>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -25,16 +25,15 @@
|
||||
<a href="README.md">English</a> | <a href="README.zh-CN.md">中文</a>
|
||||
</p>
|
||||
|
||||
> **Current support is DeepSeek Harness 0.2 only** (official desktop **0.2.0-rc.2**). **0.1.x is not supported.** On other host versions, unmatched originals stay pending or skipped. Nothing is rewritten blindly.
|
||||
> **Official Web and the official desktop app are both supported.** Official `dsh web` uses profile `web`. The official desktop EXE (DeepSeek Harness **0.2.0-rc.2**) uses profile `desktop`. Install and Apply them separately. This release targets dsh 0.2 only. Older dsh builds need the matching older plugin. Community Desktop is not maintained.
|
||||
>
|
||||
> **Apply writes the prompt and patches, then restarts the host automatically.** After the host comes back, start a new chat — that is when the inject enters the session. If Apply fails (for example patches did not all apply), it does not restart.
|
||||
> Adding the plugin to a profile does not patch the host. Click **dsh-purge** beside the session title → **Clean** → **Apply**. A successful Apply restarts; an unfinished Apply does not. After the restart, start a new chat — that is when the inject enters the session.
|
||||
>
|
||||
> Node.js **≥18**; Windows no-flash import hooks need **Node ≥22** `registerHooks`, older Node still gets file-level `windowsHide` patches. After install, click **Apply** once (a successful Apply restarts for you).
|
||||
>
|
||||
> The Hub page is for reading only: [DeepSeek Harness Hub](https://deepseek.stream/plugins/dsh-purge). Do not use the Hub one-click install, and do not install via `deepseek.stream/api/plugins/download?...`. Hub one-click runs `git+https://github.com/yujunzhixue/dsh-purge.git`, which fails at `git ls-remote`. The allowBuilds hint after that does not apply: this package has no `prepare` script. Install with the `.tar.gz` command below.
|
||||
> Node.js **≥18**. Windows no-flash needs **Node ≥22**. Do not use the Hub one-click install. Commands are below.
|
||||
|
||||
## Contents
|
||||
|
||||
- [Sponsor](#sponsor)
|
||||
- [What this is](#what-this-is)
|
||||
- [Attribution required](#attribution-required)
|
||||
- [Supported hosts](#supported-hosts)
|
||||
@@ -48,9 +47,24 @@
|
||||
|
||||
---
|
||||
|
||||
<a id="sponsor"></a>
|
||||
|
||||
## ☕ Sponsor
|
||||
|
||||
If this project helps you, send it over — I'm out here asking~
|
||||
|
||||
| Asset | Address |
|
||||
| --- | --- |
|
||||
| USDT (TRC20) | `TV5ajPkRD8RH623Dx9mqvYZVNN8nPGRKid` |
|
||||
| Solana | `6x16GhRgLVpKFFXaU1seKNdx2rypspSJTL4dbpt6Xpwk` |
|
||||
| Ethereum | `0xB68BD60C0e8c519513B7DF9bB147696815423B3E` |
|
||||
| Bitcoin | `bc1qu70yxkrtwnymt8ryluz9x8y8hqzune5340npht` |
|
||||
|
||||
---
|
||||
|
||||
## What this is
|
||||
|
||||
**dsh-purge** is a cybersecurity red-team plugin for the official [DeepSeek Harness](https://www.deepseek.com/harness/) already installed on your machine.
|
||||
**dsh-purge** is a cybersecurity red-team plugin for the official [DeepSeek Harness](https://www.deepseek.com/harness/) already installed on your machine. Official **Web** (`dsh web`) and the official **desktop EXE** are both supported. Install and Apply them separately.
|
||||
|
||||
Harness does more than forward a prompt. It rewrites prompts, approval gates, sandbox policy, and session migration at runtime. Asking only “will the model answer” treats a host-layer block as a model refusal. This plugin separates those two layers on your own install, for controlled evaluation and for seeing which default policy is too tight.
|
||||
|
||||
@@ -118,15 +132,12 @@ Using them without attribution, hiding the source, or passing them off as your o
|
||||
|
||||
## Supported hosts
|
||||
|
||||
This release supports **DeepSeek Harness 0.2** only (official desktop **0.2.0-rc.2**). **0.1.x is not supported.**
|
||||
Pick the plugin that matches your dsh. The latest plugin supports **dsh 0.2** only. Older dsh builds need the matching older plugin. Do not apply this release to 0.1.x.
|
||||
|
||||
| Host | Status |
|
||||
|---|---|
|
||||
| Official Harness 0.2 desktop / `dsh web` | Supported |
|
||||
| Official Harness 0.1.x | Not supported |
|
||||
| Any other version | Unmatched patches stay pending or skipped; do not expect them to work |
|
||||
- **dsh 0.2** (official desktop **0.2.0-rc.2** / official `dsh web`): use **1.1.40** or newer. The current release is **1.1.66**. The install commands on this page install that line.
|
||||
- **dsh 0.1.7** (including **0.1.7-rc.1** and **0.1.7-rc.2**): use **1.1.39** or older. Pick the tag on [Releases](https://github.com/YuJunZhiXue/dsh-purge/releases).
|
||||
|
||||
The plugin version is **1.1.61**. 1.1.45 is skipped; it has bugs.
|
||||
Unmatched patches stay pending or skipped. Nothing is rewritten blindly.
|
||||
|
||||
---
|
||||
|
||||
@@ -141,6 +152,8 @@ Only official `dsh web` and the official desktop EXE are maintained. Install and
|
||||
|
||||
If `dsh` is not on PATH, or you do not want a remote install, use [Manual install](#manual).
|
||||
|
||||
The Hub page is for reading only: [DeepSeek Harness Hub](https://deepseek.stream/plugins/dsh-purge). Do not use the Hub one-click install, and do not install via `deepseek.stream/api/plugins/download?...`. Hub one-click runs `git+https://github.com/yujunzhixue/dsh-purge.git`, which fails at `git ls-remote`. The allowBuilds hint after that does not apply: this package has no `prepare` script. Install with the `.tar.gz` command below.
|
||||
|
||||
### After the command: three steps
|
||||
|
||||
Adding the plugin to a profile does **not** patch `@deepseek-ai` by itself.
|
||||
@@ -192,13 +205,13 @@ Official desktop 0.2 loads the `desktop` profile. Do not use `default`, and do n
|
||||
<p align="center">
|
||||
<a href="https://deepseek.stream/plugins/dsh-purge"><strong>🌐 Open Hub page</strong></a>
|
||||
·
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.61&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>🚀 Install in desktop client</strong></a>
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.66&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>🚀 Install in desktop client</strong></a>
|
||||
</p>
|
||||
|
||||
🔗 **Raw protocol URL:**
|
||||
|
||||
```
|
||||
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.61&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
|
||||
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.66&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
|
||||
```
|
||||
|
||||
<details>
|
||||
@@ -214,7 +227,7 @@ export function installDshPurgeToDesktop() {
|
||||
const params = new URLSearchParams({
|
||||
id: 'dsh-purge',
|
||||
name: 'dsh-purge',
|
||||
version: '1.1.61',
|
||||
version: '1.1.66',
|
||||
repo: 'YuJunZhiXue/dsh-purge',
|
||||
permissions: '系统提示词注入, 本机补丁, 设置页',
|
||||
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
|
||||
@@ -233,7 +246,7 @@ export function installDshPurgeToDesktop() {
|
||||
**HTML link:**
|
||||
|
||||
```html
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.61&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.66&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
|
||||
🚀 Install in desktop client
|
||||
</a>
|
||||
```
|
||||
@@ -244,16 +257,14 @@ export function installDshPurgeToDesktop() {
|
||||
|---|---|---|
|
||||
| id | `dsh-purge` | Plugin id |
|
||||
| name | `dsh-purge` | Display name |
|
||||
| version | `1.1.61` | Semver |
|
||||
| version | `1.1.66` | Semver |
|
||||
| repo | `YuJunZhiXue/dsh-purge` | GitHub repo |
|
||||
| permissions | `系统提示词注入, 本机补丁, 设置页` | Requested permissions |
|
||||
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub source archive |
|
||||
|
||||
</details>
|
||||
|
||||
Then fully quit the official client, including the tray, and open it again.
|
||||
|
||||
On the official desktop, click **Apply** (a successful Apply restarts automatically).
|
||||
Then fully quit the official client, including the tray, open it again, and follow the three steps above to click **Apply**.
|
||||
|
||||
### How to tell it installed
|
||||
|
||||
@@ -573,7 +584,6 @@ On the Clean page, under Prompt. One host per line, then Save list. Steps are in
|
||||
| dsh-purge | button beside the session title; opens or collapses the dock |
|
||||
| Clean | the old Rules page: patches, prompt, rule sets, skills |
|
||||
| Drill | assets, skills, and environment after authorization. The tab says Unauthorized until then |
|
||||
| Light / Ink | card appearance |
|
||||
| Patches | grouped status, Apply, Restore, or Uninstall |
|
||||
| Prompt | edit `prompt-inject.md` as the session override |
|
||||
| Own servers | one IP or exact hostname per line, saved to `$DSH_HOME/net-scope-allow.txt` |
|
||||
@@ -584,45 +594,9 @@ On the Clean page, under Prompt. One host per line, then Save list. Steps are in
|
||||
|
||||
## Layout
|
||||
|
||||
```
|
||||
dsh-purge/
|
||||
├── bin/dsh-purge.js
|
||||
├── client.js
|
||||
├── cordis.patch.yml
|
||||
├── docs/
|
||||
│ ├── banner.svg
|
||||
│ └── preview/
|
||||
│ ├── dock-auth.png
|
||||
│ ├── dock-clean.png
|
||||
│ ├── dock-drill.png
|
||||
│ ├── own-servers.png
|
||||
│ ├── own-servers-en.png
|
||||
│ ├── rules.png
|
||||
│ └── settings.png
|
||||
├── lib/
|
||||
│ ├── redteam/
|
||||
│ ├── child-process-hide.mjs
|
||||
│ ├── core.js
|
||||
│ ├── hide-console.js
|
||||
│ ├── identity.js
|
||||
│ ├── index.js
|
||||
│ ├── restart-web.js
|
||||
│ ├── rewind.js
|
||||
│ ├── rules.js
|
||||
│ ├── skills.js
|
||||
│ ├── uninstall-restart.js
|
||||
│ ├── uninstall.js
|
||||
│ └── update.js
|
||||
├── presets/redteam/
|
||||
├── skills/redteam/
|
||||
├── package.json
|
||||
├── screenshots.json
|
||||
├── LICENSE
|
||||
├── README.md
|
||||
└── README.zh-CN.md
|
||||
```
|
||||
`bin/` is the CLI, `lib/` is patches and the drill console, `presets/redteam/` is the red-team preset, `skills/redteam/` is the bundled skills, and `client.js` is the dock.
|
||||
|
||||
Runtime user files: `$DSH_HOME/prompt-inject.md`, `$DSH_HOME/rules/`, `$DSH_HOME/skills/`, `$DSH_HOME/net-scope-allow.txt`. If `DSH_HOME` is unset, the launcher-adjacent `.dsh` wins over `~/.dsh`. Skills are not part of the `dsh-purge` inject section and do not replace the prompt.
|
||||
Runtime files live under `$DSH_HOME`: `prompt-inject.md`, `rules/`, `skills/`, `net-scope-allow.txt`, `redteam/`. If `DSH_HOME` is unset, the launcher-adjacent `.dsh` wins over `~/.dsh`. Web and the desktop app each use their own home. Skills are not part of the inject section and do not replace the prompt.
|
||||
|
||||
---
|
||||
|
||||
@@ -643,7 +617,7 @@ dsh-purge --edit
|
||||
purge_status purge_apply purge_revert
|
||||
```
|
||||
|
||||
After a successful Apply, the host restarts so patched packages load; you can also click **Restart** manually. Under the patch title is the stable release: you can see versions and switch. A rollback is pinned; click **Update** to return to the latest. The beta channel is gone.
|
||||
After a successful Apply, the host restarts so patched packages load; you can also click **Restart** manually. Under the patch title are the stable release and the test release. The test release follows the `beta` branch. **Switch to stable** installs `master` and clears any pin. Picking an older stable version pins it; click **Update** to return to the latest. Old test tags are not listed.
|
||||
|
||||
The composer **Undo once** and **Undo last round** stay in the current conversation and do not open a branch. The sent line goes back into the input, and that cut's already-sent messages and completed tasks leave the current conversation; edit and **send again**. From **1.1.61**, rewind bounds follow the **current turn**, not the first user message. `/rewind` does the same.
|
||||
|
||||
@@ -666,8 +640,6 @@ The box sits under Prompt. If the dock does not show it yet, quit DeepSeek Harne
|
||||
|
||||
`203.0.113.10` and `example.com` above are only examples of the form. Replace them with your own host before you save.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
## Local checks
|
||||
@@ -763,17 +735,4 @@ What changed, and the zip, are on [Releases](https://github.com/YuJunZhiXue/dsh-
|
||||
|
||||
---
|
||||
|
||||
## ☕ Sponsor
|
||||
|
||||
If this project helps you, send it over — I'm out here asking~
|
||||
|
||||
| Asset | Address |
|
||||
| --- | --- |
|
||||
| USDT (TRC20) | `TV5ajPkRD8RH623Dx9mqvYZVNN8nPGRKid` |
|
||||
| Solana | `6x16GhRgLVpKFFXaU1seKNdx2rypspSJTL4dbpt6Xpwk` |
|
||||
| Ethereum | `0xB68BD60C0e8c519513B7DF9bB147696815423B3E` |
|
||||
| Bitcoin | `bc1qu70yxkrtwnymt8ryluz9x8y8hqzune5340npht` |
|
||||
|
||||
---
|
||||
|
||||
Thanks to the [LINUX DO](https://linux.do) community
|
||||
+127
-152
@@ -4,10 +4,10 @@
|
||||
|
||||
<h1 align="center">⚔️ DeepSeek Harness 网络安全红队工具(dsh-purge)</h1>
|
||||
|
||||
<p align="center"><strong>Version 1.1.61</strong></p>
|
||||
<p align="center"><strong>Version 1.1.66</strong></p>
|
||||
|
||||
<p align="center">
|
||||
<em>本机官方 DeepSeek Harness 网络安全红队评测插件。清洗宿主策略,并带内嵌演练台。不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐</em>
|
||||
<em>DeepSeek Harness 破甲:让所有模型都能破甲,不同模型可换不同提示词;默认提示词面向国模「小码酱」。Jailbreak for every model — swap prompts per model. 求 Star 收藏 ⭐ 如要二开,请查看署名要求部分</em>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -25,16 +25,15 @@
|
||||
<a href="README.md">English</a> | <a href="README.zh-CN.md">中文</a>
|
||||
</p>
|
||||
|
||||
> **当前只适配 DeepSeek Harness 0.2**(官方桌面 **0.2.0-rc.2**)。**不支持 0.1.x。** 其它宿主版本对不上的原文会显示待应用或跳过,不会乱改文件。
|
||||
> **官方 Web 和官方桌面端都支持。** 官方 `dsh web` 用 profile `web`;官方桌面 EXE(DeepSeek Harness **0.2.0-rc.2**)用 profile `desktop`。两边分开安装、分开点「应用」。当前版本只适配 dsh 0.2;更早的 dsh 用对应的老版本插件。社区桌面端不维护。
|
||||
>
|
||||
> **点「应用」会写入提示词和补丁,并自动重启宿主。** 重启完成后新开一轮对话,注入才进当前会话。若应用失败(例如补丁未全部打上),不会自动重启。
|
||||
> 写进 profile 还不会改宿主。点会话标题旁的 **dsh-purge** → **清洗** → **应用**。成功会自动重启;补丁没打完不重启。重启后新开一轮对话,注入才进当前会话。
|
||||
>
|
||||
> Node.js **≥18**;Windows 无闪窗需要 **Node ≥22** 的 `registerHooks`,更低版本仍用文件级 `windowsHide`。装完要点一次 **应用**(成功后会自动重启)。
|
||||
>
|
||||
> 插件市场页只看介绍:[DeepSeek Harness Hub](https://deepseek.stream/plugins/dsh-purge)。不要用市场里的一键安装,也不要用 `deepseek.stream/api/plugins/download?...`。市场一键走的是 `git+https://github.com/yujunzhixue/dsh-purge.git`,会在 `git ls-remote` 失败;后面的 allowBuilds 提示对不上,这个包没有 `prepare` 脚本。安装用下面的 `.tar.gz` 命令。
|
||||
> Node.js **≥18**。Windows 无闪窗需要 **Node ≥22**。不要用插件市场的一键安装,命令在下面。
|
||||
|
||||
## 目录
|
||||
|
||||
- [赞助](#sponsor)
|
||||
- [介绍](#介绍)
|
||||
- [署名要求](#署名要求)
|
||||
- [适配范围](#适配范围)
|
||||
@@ -46,21 +45,40 @@
|
||||
- [还原](#还原)
|
||||
- [更新](#更新)
|
||||
|
||||
---
|
||||
|
||||
<a id="sponsor"></a>
|
||||
|
||||
## ☕ 赞助
|
||||
|
||||
这个项目要是帮到你了,欢迎打赏。我是讨口子,施舍点~
|
||||
|
||||
|
||||
| 资产 | 地址 |
|
||||
| ----------- | ---------------------------------------------- |
|
||||
| USDT(TRC20) | `TV5ajPkRD8RH623Dx9mqvYZVNN8nPGRKid` |
|
||||
| Solana | `6x16GhRgLVpKFFXaU1seKNdx2rypspSJTL4dbpt6Xpwk` |
|
||||
| Ethereum | `0xB68BD60C0e8c519513B7DF9bB147696815423B3E` |
|
||||
| Bitcoin | `bc1qu70yxkrtwnymt8ryluz9x8y8hqzune5340npht` |
|
||||
|
||||
|
||||
---
|
||||
|
||||
## 介绍
|
||||
|
||||
**dsh-purge** 是装在本机官方 [DeepSeek Harness](https://www.deepseek.com/harness/) 上的网络安全红队评测插件。
|
||||
**dsh-purge** 是装在本机官方 [DeepSeek Harness](https://www.deepseek.com/harness/) 上的网络安全红队评测插件。官方 **Web**(`dsh web`)和官方 **桌面端**(EXE)都支持,两边分开装、分开应用。
|
||||
|
||||
Harness 不只是把问题交给模型。它还会在运行时改提示词、审批门、沙箱和会话格式。只看「模型答不答」,会把宿主拦截误当成模型拒绝。这个插件在你自己的安装里把这两层分开,用来做受控评测,也用来看默认策略该不该收紧。
|
||||
|
||||
| 你会用到 | 它做什么 |
|
||||
|---|---|
|
||||
| **dsh-purge 侧栏** | 会话标题旁的按钮打开右侧栏。里面两页:清洗、演练台 |
|
||||
| **清洗** | 分组查看补丁,应用、还原、卸载;编辑提示词和多套规则 |
|
||||
| **演练台** | 正式版内置。授权后查看资产、技能和本机环境。只用于你有权管理的本机、离线靶标或已书面授权的演练 |
|
||||
| **宿主策略** | 调整默认文案、权限策略和工具上限。官方能力保留,不另写一套身份 |
|
||||
| **启动时** | 自动再检查并应用。npm 升级盖掉 `node_modules` 之后不用手改文件 |
|
||||
|
||||
| 你会用到 | 它做什么 |
|
||||
| ---------------- | ----------------------------------------------- |
|
||||
| **dsh-purge 侧栏** | 会话标题旁的按钮打开右侧栏。里面两页:清洗、演练台 |
|
||||
| **清洗** | 分组查看补丁,应用、还原、卸载;编辑提示词和多套规则 |
|
||||
| **演练台** | 正式版内置。授权后查看资产、技能和本机环境。只用于你有权管理的本机、离线靶标或已书面授权的演练 |
|
||||
| **宿主策略** | 调整默认文案、权限策略和工具上限。官方能力保留,不另写一套身份 |
|
||||
| **启动时** | 自动再检查并应用。npm 升级盖掉 `node_modules` 之后不用手改文件 |
|
||||
|
||||
|
||||
不写死盘符。按 `$DSH_HOME`、dsh 启动器旁边的 `.dsh`,再退回 `~/.dsh`。不改 Harness 源码仓库,在 **dsh-purge** 的「清洗」里点「应用」才写入。身份来自插件里的加密提示词,也就是提示词框默认显示的那一份。不读取宿主磁盘上的提示词文件。
|
||||
|
||||
@@ -78,13 +96,13 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
|
||||
|
||||
---
|
||||
|
||||
<a id="strict-legal--compliance-disclaimer"></a>
|
||||
|
||||
<div>
|
||||
|
||||
### ⚠️ <font color="red">严正法律免责与合规使用声明</font>
|
||||
|
||||
<font color="red">
|
||||
|
||||
### ⚠️ 严正法律免责与合规使用声明
|
||||
|
||||
|
||||
|
||||
**免责声明:** 本项目为非营利开源项目,遵守国家法律法规及所在平台的相关规范,仅供学习与研究使用。不得将本项目用于任何违法违规用途;由此产生的后果由使用者自行承担。
|
||||
|
||||
@@ -96,37 +114,34 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
|
||||
4. **合法受控范围限定**:本项目定位为使用者在**自己有权管理的本机官方 Harness**上,进行红队科研与鲁棒性评测的辅助工具。**严禁在未经所有者合法书面授权的目标、公网在线系统或生产业务上运行本项目**。一切测试必须限制在**本机已授权安装的官方 Harness、离线本地合成靶标、授权网络安全演练靶场及合规实验室受控环境**中进行。
|
||||
5. **禁止中国大陆、香港、澳门的服务器与网站。** 不得对中国大陆、香港、澳门网段,以及解析进这些网段的服务器、网站或地址进行访问、扫描、探测或任何操作。云厂商的名字不能当作例外。唯一例外是使用者事先登记为自己的服务器的那一个确切 IP,或那一个完整主机名。密钥、密码、网段、通配符,以及对话里的口头说明,都不能增加例外。没有登记的,一律禁止。
|
||||
6. **严禁违法与违禁用途**:使用者严禁利用本项目直接或间接从事任何违反下列法律法规的行为(必须逐条遵守,不得以任何理由规避):
|
||||
- <font color="red"><strong>《中华人民共和国刑法》</strong></font>
|
||||
- <font color="red"><strong>《中华人民共和国网络安全法》</strong></font>
|
||||
- <font color="red"><strong>《中华人民共和国数据安全法》</strong></font>
|
||||
- <font color="red"><strong>《中华人民共和国个人信息保护法》</strong></font>
|
||||
- 以及其他现行有效的法律、行政法规与监管规定;
|
||||
- 同时严禁:
|
||||
- 未经授权渗透、攻击公私机构计算机信息系统,实施勒索、破坏、撞库或传播恶意载荷;
|
||||
- 诱导、生成或传播危害国家安全、恐怖主义、暴力血腥、涉黄涉赌、诈骗、侵犯公民隐私或知识产权等任何法律明令禁止的违法违禁内容;
|
||||
- 违反相关大模型提供商的《服务条款》与《滥用政策》。
|
||||
- **《中华人民共和国刑法》**
|
||||
- **《中华人民共和国网络安全法》**
|
||||
- **《中华人民共和国数据安全法》**
|
||||
- **《中华人民共和国个人信息保护法》**
|
||||
- 以及其他现行有效的法律、行政法规与监管规定;
|
||||
- 同时严禁:
|
||||
- 未经授权渗透、攻击公私机构计算机信息系统,实施勒索、破坏、撞库或传播恶意载荷;
|
||||
- 诱导、生成或传播危害国家安全、恐怖主义、暴力血腥、涉黄涉赌、诈骗、侵犯公民隐私或知识产权等任何法律明令禁止的违法违禁内容;
|
||||
- 违反相关大模型提供商的《服务条款》与《滥用政策》。
|
||||
7. **使用者独立承担全部责任**:本项目依据 MIT 开源协议“按现状”提供,开发者不对软件的完整性、安全性与适用性作任何明示或暗示的保证。**使用者应对自身的所有下载、部署、运行、修改、传播行为以及由此产生的全部输入与输出后果承担独立、完全的民事、行政及刑事法律责任**。项目作者与贡献团队绝不承担任何因使用者滥用导致的直接、间接或连带责任。
|
||||
8. **违约即终止授权**:任何将本项目用于非法攻击、恶意活动或违规行为的个人或实体,其开源软件使用许可将自违法违规行为发生之日起**自动且不可撤销地立即终止**。该主体须立即停止使用并永久销毁本项目的所有代码、脚本与衍生数据,并依法承担相应法律制裁。
|
||||
9. **第三方独立性声明**:本项目属于完全独立的开源安全评测研究项目,与 DeepSeek 官方或其关联主体无任何隶属、商业合作、授权或官方背书关系。文中「官方」仅指评测对象为使用者本机安装的官方 DeepSeek Harness 软件包,**不代表** DeepSeek 官方开发、认可或担保本插件。
|
||||
10. **必须署名**:借用本项目的名称、思路、代码或提示词,必须署名并标明本仓库。不署名将依法追究责任。详见 [署名要求](#署名要求)。
|
||||
|
||||
</font>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## 适配范围
|
||||
|
||||
当前只适配 **DeepSeek Harness 0.2**(官方桌面以 **0.2.0-rc.2** 为准)。**0.1.x 不支持。**
|
||||
请选择支持的版本。最新版只支持 **dsh 0.2**。更早的 dsh 使用对应的老版本插件,不要拿当前版本去打 0.1.x。
|
||||
|
||||
| 宿主 | 状态 |
|
||||
|---|---|
|
||||
| 官方 Harness 0.2 桌面 / `dsh web` | 支持 |
|
||||
| 官方 Harness 0.1.x | 不支持 |
|
||||
| 其它未列出版本 | 对不上的补丁会显示待应用或跳过,不要指望能用 |
|
||||
- **dsh 0.2**(官方桌面 **0.2.0-rc.2** / 官方 `dsh web`):用 **1.1.40** 及以上,当前是 **1.1.66**。本页安装命令装的就是这一档。
|
||||
- **dsh 0.1.7**(含 **0.1.7-rc.1**、**0.1.7-rc.2**):用 **1.1.39** 及更早。[Releases](https://github.com/YuJunZhiXue/dsh-purge/releases) 里选对应标签。
|
||||
|
||||
插件版本是 **1.1.61**。1.1.45 有问题,略过。
|
||||
对不上的补丁会显示待应用或跳过,不会乱改文件。
|
||||
|
||||
---
|
||||
|
||||
@@ -134,18 +149,22 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
|
||||
|
||||
现在只维护官方 `dsh web` 和官方桌面 EXE,**分开装、分开应用**。只装你正在打开的那一个。必须是 **dsh 0.2**。社区桌面端暂不维护;需要的话请单独开一个 issue。
|
||||
|
||||
| 你正在用 | profile | 安装 |
|
||||
|---|---|---|
|
||||
| 官方 `dsh web` | `web` | [Web](#web) |
|
||||
|
||||
| 你正在用 | profile | 安装 |
|
||||
| ----------------- | --------- | ------------------------- |
|
||||
| 官方 `dsh web` | `web` | [Web](#web) |
|
||||
| 官方 Harness 桌面 EXE | `desktop` | [官方桌面 EXE](#official-exe) |
|
||||
|
||||
|
||||
`dsh` 不在 PATH、或不想走远程安装时,用 [手动安装](#manual)。
|
||||
|
||||
插件市场页只看介绍:[DeepSeek Harness Hub](https://deepseek.stream/plugins/dsh-purge)。不要用市场一键安装,也不要用 `deepseek.stream/api/plugins/download?...`。市场一键走 `git+https://github.com/yujunzhixue/dsh-purge.git`,会在 `git ls-remote` 失败;后面的 allowBuilds 提示对不上,这个包没有 `prepare` 脚本。安装用下面的 `.tar.gz`。
|
||||
|
||||
### 装完都要做完这三步
|
||||
|
||||
只把插件写进 profile **还不会**改 `@deepseek-ai`。
|
||||
|
||||
1. **退出并重新打开**刚装的那个宿主。Web 关掉 `dsh web` 再开;桌面端退出托盘,再打开对应的 exe。
|
||||
1. **退出并重新打开**。Web 关掉 `dsh web` 再开;桌面端退出托盘,再打开对应的 exe。
|
||||
2. 点会话标题旁的 **dsh-purge**,在右侧栏的 **清洗** 里点 **「应用」**。宿主的设置页里没有这个条目。
|
||||
3. 点「应用」成功后会自动重启一次,让补丁进入当前进程。应用没做完不会重启。
|
||||
|
||||
@@ -153,7 +172,7 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
|
||||
|
||||
Web 的「应用 / 重启 / 卸载」只动 Web。桌面端的只动桌面应用,不会去拉 `dsh web`。不要在 Web 里点桌面端的应用,也不要反过来。
|
||||
|
||||
<a id="web"></a>
|
||||
|
||||
|
||||
### Web
|
||||
|
||||
@@ -171,13 +190,13 @@ dsh plugin --profile web add .
|
||||
|
||||
然后按上面三步,点会话标题旁的 **dsh-purge**,在 **清洗** 里点「应用」。
|
||||
|
||||
<a id="desktop"></a>
|
||||
|
||||
|
||||
### 社区桌面端
|
||||
|
||||
暂不维护。当前只支持官方 Web 和官方桌面 EXE。以后若要社区版,请单独开一个 issue,不要和这次的行为混在一起。
|
||||
|
||||
<a id="official-exe"></a>
|
||||
|
||||
|
||||
### 官方桌面 EXE
|
||||
|
||||
@@ -189,20 +208,15 @@ dsh plugin --profile desktop add https://github.com/YuJunZhiXue/dsh-purge/archiv
|
||||
|
||||
官方桌面 0.2 读的 profile 是 `desktop`。不要改成 `default`,也不要改成 `git+https://github.com/yujunzhixue/dsh-purge.git`。git 地址会先跑 `git ls-remote`,失败后的 allowBuilds 提示可以忽略。
|
||||
|
||||
<p align="center">
|
||||
<a href="https://deepseek.stream/plugins/dsh-purge"><strong>🌐 打开插件市场页</strong></a>
|
||||
·
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.61&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>🚀 唤起客户端一键安装</strong></a>
|
||||
</p>
|
||||
**[🌐 打开插件市场页](https://deepseek.stream/plugins/dsh-purge)** · **🚀 唤起客户端一键安装**
|
||||
|
||||
🔗 **原生协议链接:**
|
||||
|
||||
```
|
||||
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.61&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
|
||||
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.66&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary><strong>协议参数和网页触发代码</strong></summary>
|
||||
**协议参数和网页触发代码**
|
||||
|
||||
**网页端(前端)触发代码示例:**
|
||||
|
||||
@@ -214,7 +228,7 @@ export function installDshPurgeToDesktop() {
|
||||
const params = new URLSearchParams({
|
||||
id: 'dsh-purge',
|
||||
name: 'dsh-purge',
|
||||
version: '1.1.61',
|
||||
version: '1.1.66',
|
||||
repo: 'YuJunZhiXue/dsh-purge',
|
||||
permissions: '系统提示词注入, 本机补丁, 设置页',
|
||||
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
|
||||
@@ -233,27 +247,27 @@ export function installDshPurgeToDesktop() {
|
||||
**HTML 静态链接方式:**
|
||||
|
||||
```html
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.61&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.66&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
|
||||
🚀 唤起客户端一键安装
|
||||
</a>
|
||||
```
|
||||
|
||||
**协议参数配置(dsh://plugin/install):**
|
||||
|
||||
| 参数名 | 值 / 示例 | 说明 |
|
||||
|---|---|---|
|
||||
| id | `dsh-purge` | 插件唯一标识符 |
|
||||
| name | `dsh-purge` | 插件展示名称 |
|
||||
| version | `1.1.61` | 语义化版本号 |
|
||||
| repo | `YuJunZhiXue/dsh-purge` | GitHub 仓库 |
|
||||
| permissions | `系统提示词注入, 本机补丁, 设置页` | 申请权限 |
|
||||
|
||||
| 参数名 | 值 / 示例 | 说明 |
|
||||
| ----------- | --------------------------------------------------------------------------- | ------------ |
|
||||
| id | `dsh-purge` | 插件唯一标识符 |
|
||||
| name | `dsh-purge` | 插件展示名称 |
|
||||
| version | `1.1.66` | 语义化版本号 |
|
||||
| repo | `YuJunZhiXue/dsh-purge` | GitHub 仓库 |
|
||||
| permissions | `系统提示词注入, 本机补丁, 设置页` | 申请权限 |
|
||||
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub 源码包地址 |
|
||||
|
||||
</details>
|
||||
|
||||
然后完全退出官方客户端(含托盘),再打开,点会话标题旁的 **dsh-purge**,在「清洗」里点「应用」。
|
||||
|
||||
**官方桌面点「应用」即可(成功后会自动重启)。**
|
||||
|
||||
然后完全退出官方客户端(含托盘),再打开,按上面三步点「应用」。
|
||||
|
||||
### 怎样算装上了
|
||||
|
||||
@@ -265,10 +279,9 @@ export function installDshPurgeToDesktop() {
|
||||
|
||||
把下面整段发给本机助手。它只执行安装命令:不要全盘搜索,不要改其它文件,不要代点「应用」,也不要重启。
|
||||
|
||||
<details>
|
||||
<summary><strong>给 AI 助手(只安装)</strong></summary>
|
||||
**给 AI 助手(只安装)**
|
||||
|
||||
|
||||
<!-- AI-AGENT-START -->
|
||||
|
||||
安装 DeepSeek Harness 插件 `dsh-purge`。先确认宿主,只装正在用的那一个。不要全盘搜索,不要读或改其它文件,不要应用设置,也不要重启应用。
|
||||
|
||||
@@ -296,11 +309,11 @@ dsh plugin --profile desktop add https://github.com/YuJunZhiXue/dsh-purge/archiv
|
||||
|
||||
命令结束后,提醒:完全退出并重启刚装的那个宿主,再点会话标题旁的 **dsh-purge**,在「清洗」里点「应用」。Web 和桌面端不要交叉点应用。然后停止。
|
||||
|
||||
<!-- AI-AGENT-END -->
|
||||
|
||||
</details>
|
||||
|
||||
<a id="manual"></a>
|
||||
|
||||
|
||||
|
||||
|
||||
### 手动安装
|
||||
|
||||
@@ -308,10 +321,12 @@ dsh plugin --profile desktop add https://github.com/YuJunZhiXue/dsh-purge/archiv
|
||||
|
||||
**0. 先确认宿主,只动一个 profile**
|
||||
|
||||
| 你实际在用的 | 只改这个目录 | 不要改 |
|
||||
|---|---|---|
|
||||
| 官方 `dsh web` | `$DSH_HOME/profiles/web` | `desktop` |
|
||||
| 官方 Harness 桌面 EXE | `$DSH_HOME/profiles/desktop` | `web` |
|
||||
|
||||
| 你实际在用的 | 只改这个目录 | 不要改 |
|
||||
| ----------------- | ---------------------------- | --------- |
|
||||
| 官方 `dsh web` | `$DSH_HOME/profiles/web` | `desktop` |
|
||||
| 官方 Harness 桌面 EXE | `$DSH_HOME/profiles/desktop` | `web` |
|
||||
|
||||
|
||||
对应 `profiles/<名>/package.json` 还不存在时,先正常启动一次该宿主,让官方程序自己建好 profile,再继续。
|
||||
|
||||
@@ -321,12 +336,14 @@ dsh plugin --profile desktop add https://github.com/YuJunZhiXue/dsh-purge/archiv
|
||||
|
||||
按这个顺序找,找到第一份能对上当前宿主的就用它:
|
||||
|
||||
| 顺序 | 安装形态 | 典型路径 |
|
||||
|---|---|---|
|
||||
| 1 | 环境变量 | `DSH_HOME`(已设置就用它) |
|
||||
| 2 | Windows 便携 / 安装目录 | `dsh.cmd` 或 `npm-global` 旁边的 `.dsh`,例如 `<安装根>\.dsh` |
|
||||
| 3 | 用户默认 | Windows `%USERPROFILE%\.dsh`;Linux / macOS `~/.dsh` |
|
||||
| 4 | 官方桌面 EXE | `%APPDATA%\DeepSeek Harness\dsh-home`、`%LOCALAPPDATA%\DeepSeek Harness\dsh-home` |
|
||||
|
||||
| 顺序 | 安装形态 | 典型路径 |
|
||||
| --- | ----------------- | -------------------------------------------------------------------------------- |
|
||||
| 1 | 环境变量 | `DSH_HOME`(已设置就用它) |
|
||||
| 2 | Windows 便携 / 安装目录 | `dsh.cmd` 或 `npm-global` 旁边的 `.dsh`,例如 `<安装根>\.dsh` |
|
||||
| 3 | 用户默认 | Windows `%USERPROFILE%\.dsh`;Linux / macOS `~/.dsh` |
|
||||
| 4 | 官方桌面 EXE | `%APPDATA%\DeepSeek Harness\dsh-home`、`%LOCALAPPDATA%\DeepSeek Harness\dsh-home` |
|
||||
|
||||
|
||||
Windows PowerShell 可先列出本机有哪些候选:
|
||||
|
||||
@@ -401,11 +418,13 @@ Rename-Item $src "dsh-purge"
|
||||
|
||||
**3. 只改对应 profile 的 `package.json`,先备份**
|
||||
|
||||
| 宿主 | 要改的文件 |
|
||||
|---|---|
|
||||
| Web | `$DSH_HOME/profiles/web/package.json` |
|
||||
|
||||
| 宿主 | 要改的文件 |
|
||||
| -------- | ----------------------------------------- |
|
||||
| Web | `$DSH_HOME/profiles/web/package.json` |
|
||||
| 官方桌面 EXE | `$DSH_HOME/profiles/desktop/package.json` |
|
||||
|
||||
|
||||
先复制一份 `package.json.bak`。然后**只追加两处**,原有依赖、原有 bundle、其它字段全部留着:
|
||||
|
||||
1. `dependencies` 增加一行:`"dsh-purge": "file:../../plugins/dsh-purge"`
|
||||
@@ -572,61 +591,26 @@ dsh-purge --uninstall
|
||||
|
||||

|
||||
|
||||
| 区域 | 说明 |
|
||||
|---|---|
|
||||
| dsh-purge | 会话标题旁的按钮,打开或收起右侧栏 |
|
||||
| 清洗 | 原来的规则设定:补丁、提示词、规则集、Skill |
|
||||
| 演练台 | 授权后的资产、技能与环境页。未授权时按钮标「未授权」 |
|
||||
| 白 / 墨 | 设置卡片外观 |
|
||||
| 补丁 | 分组查看状态,应用、还原或卸载 |
|
||||
| 提示词 | 编辑 `prompt-inject.md`,作为会话覆盖段 |
|
||||
| 自己的服务器 | 每行登记一个 IP 或完整主机名,保存后写入 `$DSH_HOME/net-scope-allow.txt` |
|
||||
| 规则集 | 多套 `AGENTS.md` / `CLAUDE.md`;启用写入 `$DSH_HOME`,删除从列表去掉 |
|
||||
| Skill | 导入压缩包或文件夹到当前宿主官方目录 `$DSH_HOME/skills/<id>/SKILL.md`(Web / 桌面各用自己的主目录,不写死盘符);命中、加载、`/名称` 由 DSH 负责。也可自己删该文件夹 |
|
||||
|
||||
| 区域 | 说明 |
|
||||
| --------- | ---------------------------------------------------------------------------------------------------------- |
|
||||
| dsh-purge | 会话标题旁的按钮,打开或收起右侧栏 |
|
||||
| 清洗 | 原来的规则设定:补丁、提示词、规则集、Skill |
|
||||
| 演练台 | 授权后的资产、技能与环境页。未授权时按钮标「未授权」 |
|
||||
| 补丁 | 分组查看状态,应用、还原或卸载 |
|
||||
| 提示词 | 编辑 `prompt-inject.md`,作为会话覆盖段 |
|
||||
| 自己的服务器 | 每行登记一个 IP 或完整主机名,保存后写入 `$DSH_HOME/net-scope-allow.txt` |
|
||||
| 规则集 | 多套 `AGENTS.md` / `CLAUDE.md`;启用写入 `$DSH_HOME`,删除从列表去掉 |
|
||||
| Skill | 导入压缩包或文件夹到当前宿主官方目录 `$DSH_HOME/skills/<id>/SKILL.md`(Web / 桌面各用自己的主目录,不写死盘符);命中、加载、`/名称` 由 DSH 负责。也可自己删该文件夹 |
|
||||
|
||||
|
||||
---
|
||||
|
||||
## 目录结构
|
||||
|
||||
```
|
||||
dsh-purge/
|
||||
├── bin/dsh-purge.js
|
||||
├── client.js
|
||||
├── cordis.patch.yml
|
||||
├── docs/
|
||||
│ ├── banner.svg
|
||||
│ └── preview/
|
||||
│ ├── dock-auth.png
|
||||
│ ├── dock-clean.png
|
||||
│ ├── dock-drill.png
|
||||
│ ├── own-servers.png
|
||||
│ ├── own-servers-en.png
|
||||
│ ├── rules.png
|
||||
│ └── settings.png
|
||||
├── lib/
|
||||
│ ├── redteam/
|
||||
│ ├── child-process-hide.mjs
|
||||
│ ├── core.js
|
||||
│ ├── hide-console.js
|
||||
│ ├── identity.js
|
||||
│ ├── index.js
|
||||
│ ├── restart-web.js
|
||||
│ ├── rewind.js
|
||||
│ ├── rules.js
|
||||
│ ├── skills.js
|
||||
│ ├── uninstall-restart.js
|
||||
│ ├── uninstall.js
|
||||
│ └── update.js
|
||||
├── presets/redteam/
|
||||
├── skills/redteam/
|
||||
├── package.json
|
||||
├── screenshots.json
|
||||
├── LICENSE
|
||||
├── README.md
|
||||
└── README.zh-CN.md
|
||||
```
|
||||
`bin/` 是命令行,`lib/` 是补丁和演练台,`presets/redteam/` 是红队预设,`skills/redteam/` 是随包技能,`client.js` 是侧栏。
|
||||
|
||||
运行时用户文件:`$DSH_HOME/prompt-inject.md`、`$DSH_HOME/rules/`、`$DSH_HOME/skills/`、`$DSH_HOME/net-scope-allow.txt`。未设 `DSH_HOME` 时,优先用 dsh 安装目录旁边的 `.dsh`,再退回 `~/.dsh`。Skill 不进 `dsh-purge` 注入段,也不顶替提示词。
|
||||
运行时文件在 `$DSH_HOME`:`prompt-inject.md`、`rules/`、`skills/`、`net-scope-allow.txt`、`redteam/`。未设 `DSH_HOME` 时,优先用 dsh 安装目录旁边的 `.dsh`,再退回 `~/.dsh`。Web 和桌面端各用自己那一份主目录。Skill 不进注入段,也不顶替提示词。
|
||||
|
||||
---
|
||||
|
||||
@@ -650,7 +634,7 @@ dsh-purge --edit
|
||||
purge_status purge_apply purge_revert
|
||||
```
|
||||
|
||||
设置页「应用」成功后会自动重启,以加载已改的包文件;也可手动点「重启」。补丁标题下是正式版:可以看版本和切换。回退后会固定在该版本,要回到最新再点「更新」。测试版通道已去掉。
|
||||
设置页「应用」成功后会自动重启,以加载已改的包文件;也可手动点「重启」。补丁标题下有正式版和测试版。测试版跟 `beta` 分支。点「切换到正式版」会装回 master,并清掉钉选。正式版里选旧版本会固定在该版本,要回到最新再点「更新」。旧的测试标签不再列出。
|
||||
|
||||
输入框旁的「回退一次」和「回退上一轮」都留在当前这条对话里,不另开分支。已发送的那句会回到输入框,这一轮已经发出的内容和已完成的任务会从当前对话撤掉,改字后**重新发送**即可。从 **1.1.61** 起,多轮对话后回退按**当前这一轮**定位,不会又退到第一条用户消息。聊天里 `/rewind` 同样可用。
|
||||
|
||||
@@ -665,16 +649,14 @@ purge_status purge_apply purge_revert
|
||||
1. 点会话标题旁的 **dsh-purge**,停在 **清洗**。
|
||||
2. 往下滚过 **提示词**,下面就是 **自己的服务器**。
|
||||
3. 每行只写一台,用下面三种写法之一:
|
||||
- `203.0.113.10`:一个 IP。
|
||||
- `my-vps.example.com`:一个完整主机名。保存后,这个主机名当时解析出来的地址也会放行。
|
||||
- `alice@my-vps.example.com`:账号只用来认出这种写法,不能证明这台机器属于你。
|
||||
- `203.0.113.10`:一个 IP。
|
||||
- `my-vps.example.com`:一个完整主机名。保存后,这个主机名当时解析出来的地址也会放行。
|
||||
- `alice@my-vps.example.com`:账号只用来认出这种写法,不能证明这台机器属于你。
|
||||
4. 点 **保存名单**。名单写在 `$DSH_HOME/net-scope-allow.txt`。
|
||||
5. 密钥、密码、网段和通配符会在保存时丢掉。没有写进名单的大陆、香港、澳门地址仍然禁止。
|
||||
|
||||
上面的 `203.0.113.10` 和 `example.com` 只是写法示例,不是放行地址。把它们换成你自己的那一台再保存。
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
## 本地校验
|
||||
@@ -703,6 +685,8 @@ flowchart TD
|
||||
F --> G["注入插件加密默认(提示词框默认显示的那份)"]
|
||||
```
|
||||
|
||||
|
||||
|
||||
每次会话的覆盖:
|
||||
|
||||
```mermaid
|
||||
@@ -710,6 +694,8 @@ flowchart TD
|
||||
A["重启或新会话"] --> B["注入插件加密默认,不必点保存,不读宿主磁盘"]
|
||||
```
|
||||
|
||||
|
||||
|
||||
Skill 不进注入段:
|
||||
|
||||
```mermaid
|
||||
@@ -719,6 +705,8 @@ flowchart LR
|
||||
C --> D["卸载插件不删用户 Skill"]
|
||||
```
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## 还原
|
||||
@@ -762,17 +750,4 @@ flowchart LR
|
||||
|
||||
---
|
||||
|
||||
## ☕ Sponsor
|
||||
|
||||
If this project helps you, send it over — I'm out here asking~
|
||||
|
||||
| Asset | Address |
|
||||
| --- | --- |
|
||||
| USDT (TRC20) | `TV5ajPkRD8RH623Dx9mqvYZVNN8nPGRKid` |
|
||||
| Solana | `6x16GhRgLVpKFFXaU1seKNdx2rypspSJTL4dbpt6Xpwk` |
|
||||
| Ethereum | `0xB68BD60C0e8c519513B7DF9bB147696815423B3E` |
|
||||
| Bitcoin | `bc1qu70yxkrtwnymt8ryluz9x8y8hqzune5340npht` |
|
||||
|
||||
---
|
||||
|
||||
感谢 [LINUX DO](https://linux.do) 社区
|
||||
感谢 [LINUX DO](https://linux.do) 社区
|
||||
@@ -188,6 +188,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"table.patch": "项目",
|
||||
"table.status": "状态",
|
||||
"status.applied": "已应用",
|
||||
"status.off": "已关闭",
|
||||
"status.pending": "待应用",
|
||||
"status.unmatched": "没对上",
|
||||
"status.skipped": "跳过",
|
||||
@@ -199,7 +200,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"warn.noInject": "官方始终用默认提示词。红队开了规则集就只用规则集;没开时用去掉 CTF 的默认提示词,再接红队操作。两边都空会提示必须添加。",
|
||||
"need.prompt": "提示词和规则集都是空的,必须先添加提示词,或启用一条有内容的规则集。",
|
||||
"btn.restoreInject": "恢复默认",
|
||||
"saved.restoreInject": "已填入默认提示词,点保存写入",
|
||||
"saved.restoreInject": "已恢复默认提示词",
|
||||
"skip": "跳过",
|
||||
"unknown": "未知",
|
||||
"delete": "删除",
|
||||
@@ -386,7 +387,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"patch.54": "交付物提示去掉多余禁止",
|
||||
"patch.55": "每一步替换第一条系统提示",
|
||||
"patch.56": "回退只藏被撤掉的那一轮",
|
||||
"patch.57": "deepseek.com 系统提示走 system",
|
||||
"patch.57": "developer role 仅限 openai/azure,第三方代理回退 system",
|
||||
"patch.58": "回退空标记不进模型请求",
|
||||
"patch.59": "官方 Auto Review 不再拦工具",
|
||||
"patch.60": "官方 run_code 去掉审批教学",
|
||||
@@ -400,6 +401,17 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"patch.68": "回退后缺 content 不中断",
|
||||
"patch.69": "deepseek-flash 保持官方 in-history",
|
||||
"patch.72": "Messages 的 system 用当前系统提示",
|
||||
"patch.73": "极简 bash 去掉误留的镜像说明",
|
||||
"patch.74": "首发前先挂默认提示词",
|
||||
"patch.75": "回退把已完成任务收回成未开始",
|
||||
"patch.76": "unrestricted 预设去掉身份句",
|
||||
"patch.77": "回退标记到达时丢弃已发送消息",
|
||||
"patch.78": "补丁文件缺失时从 .bak 恢复",
|
||||
"patch.80": "恢复官方极简工具表",
|
||||
"patch.81": "每一步重放完整 prompt-inject",
|
||||
"patch.82": "主进程兜底 DSH_PROFILE=desktop",
|
||||
"patch.83": "host 信号杀时不报错不弹对话框",
|
||||
"patch.84": "host code=0 正常退出不报错 (消除 stopped 对话框)",
|
||||
"status.unlocated": "未定位",
|
||||
"status.na": "本端不需要",
|
||||
"metric.unlocated": "还没定位到本机 Harness",
|
||||
@@ -416,6 +428,10 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"rewind.once.hint": "把这一轮发出去的那句放回输入框,并清掉这一轮",
|
||||
"rewind.round": "回退上一轮",
|
||||
"rewind.round.hint": "把这一轮发出去的那句放回输入框;子代理也只撤这一轮",
|
||||
"hooksDeny.title": "Hooks 拦截",
|
||||
"hooksDeny.bypass": "放行 hooks 的 deny / ask(补丁 30 / 31 / 64 / 65)",
|
||||
"hooksDeny.hint": "关掉后,用户自己的 PreToolUse / UserPromptSubmit / Stop hook 的 deny 会按官方逻辑生效。官方 ask 分支本身是空操作,关开关不会弹出审批框。改完后点「应用」并重启才写进宿主。",
|
||||
"saved.hooksDeny": "已保存",
|
||||
"continue.title": "失败重试 / 继续",
|
||||
"continue.hint": "请求失败会自动重试;异常停止或中断可点「继续」或自动续跑。自己点停止不会自动继续。次数用完后需新开一轮。",
|
||||
"continue.autoRetry": "失败自动重试",
|
||||
@@ -500,6 +516,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"table.patch": "Item",
|
||||
"table.status": "Status",
|
||||
"status.applied": "Applied",
|
||||
"status.off": "Off",
|
||||
"status.pending": "Pending",
|
||||
"status.unmatched": "No match",
|
||||
"status.skipped": "Skipped",
|
||||
@@ -511,7 +528,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"warn.noInject": "Official mode always uses the default prompt. Red team uses only the active rule set; otherwise it uses the default prompt without the CTF section, then the red team steps. If both are empty you will be asked to add a prompt.",
|
||||
"need.prompt": "Both the prompt and the rule set are empty. Add a prompt, or enable a rule that has content.",
|
||||
"btn.restoreInject": "Reset default",
|
||||
"saved.restoreInject": "Default prompt loaded. Save to write.",
|
||||
"saved.restoreInject": "Default prompt restored",
|
||||
"skip": "Skipped",
|
||||
"unknown": "Unknown",
|
||||
"delete": "Delete",
|
||||
@@ -698,7 +715,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"patch.54": "Deliverable prompt drops extra prohibition",
|
||||
"patch.55": "Replace the first system prompt every step",
|
||||
"patch.56": "Rewind hides only the cut range",
|
||||
"patch.57": "deepseek.com keeps system role",
|
||||
"patch.57": "developer role for openai/azure only, third-party gateways use system",
|
||||
"patch.58": "Rewind markers stay off the model request",
|
||||
"patch.59": "Official Auto Review no longer denies tools",
|
||||
"patch.60": "Official run_code drops approval teaching",
|
||||
@@ -712,6 +729,17 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"patch.68": "Missing content after rewind no longer ends the turn",
|
||||
"patch.69": "deepseek-flash keeps the official in-history flag",
|
||||
"patch.72": "Messages system field uses the current system prompt",
|
||||
"patch.73": "Minimal preset drops stray mirror sentence",
|
||||
"patch.74": "Hang default prompt before first assemble",
|
||||
"patch.75": "Rewind resets completed todos to pending",
|
||||
"patch.76": "Unrestricted preset: strip identity sentence",
|
||||
"patch.77": "Rewind marker drops already-sent messages",
|
||||
"patch.78": "Restore missing overlay from .bak backup",
|
||||
"patch.80": "Restore official minimal tool plugins",
|
||||
"patch.81": "Replay the full prompt-inject every step",
|
||||
"patch.82": "Fallback DSH_PROFILE=desktop in main process",
|
||||
"patch.83": "Don't fail on signal kill (no crash dialog)",
|
||||
"patch.84": "Don't fail on code=0 clean exit (no stopped dialog)",
|
||||
"status.na": "Not for this host",
|
||||
"metric.sealed": "Official client found. Apply to unpack",
|
||||
"metric.sealed.count": "Sealed",
|
||||
@@ -728,6 +756,10 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"rewind.once.hint": "Put this round's message back in the box and drop only this round",
|
||||
"rewind.round": "Undo last round",
|
||||
"rewind.round.hint": "Put this round's message back in the box; subagents drop only this round",
|
||||
"hooksDeny.title": "Hook interception",
|
||||
"hooksDeny.bypass": "Bypass hook deny / ask (patches 30 / 31 / 64 / 65)",
|
||||
"hooksDeny.hint": "When off, your own PreToolUse / UserPromptSubmit / Stop hook deny runs as the official host wrote it. The official ask branch is a no-op; turning this off will not show an approval dialog. Click Apply and restart to write the host files.",
|
||||
"saved.hooksDeny": "Saved",
|
||||
"continue.title": "Retry / Continue",
|
||||
"continue.hint": "Failed requests auto-retry. After an abnormal stop or interrupt, use Continue or auto-resume. A manual stop never auto-continues. Counts reset after a completed turn.",
|
||||
"continue.autoRetry": "Auto-retry on failure",
|
||||
@@ -973,12 +1005,13 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
|
||||
if (st === "pending") return "wait";
|
||||
if (st === "unmatched") return "bad";
|
||||
if (st === "na") return "ok";
|
||||
if (st === "missing_file" || st === "skipped" || st === "unlocated") return "miss";
|
||||
if (st === "missing_file" || st === "skipped" || st === "unlocated" || st === "off") return "miss";
|
||||
return "bad";
|
||||
}
|
||||
|
||||
function statusLabel(st, t) {
|
||||
if (st === "applied" || st === "already") return t("status.applied");
|
||||
if (st === "off") return t("status.skipped");
|
||||
if (st === "pending") return t("status.pending");
|
||||
if (st === "unmatched") return t("status.unmatched");
|
||||
if (st === "skipped") return t("status.skipped");
|
||||
@@ -1096,6 +1129,61 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
|
||||
});
|
||||
}
|
||||
|
||||
function HooksDenySection({ onSaved }) {
|
||||
const t = useT();
|
||||
const [cfg, setCfg] = useState(null);
|
||||
const [notice, setNotice] = useState({ kind: "idle", text: "" });
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
apiJson("/dsh-purge/hooks-deny")
|
||||
.then((d) => { if (d && d.ok) setCfg({ hooksDenyBypass: d.hooksDenyBypass !== false }); })
|
||||
.catch(() => {});
|
||||
}, []);
|
||||
|
||||
const save = (hooksDenyBypass) => {
|
||||
if (!cfg || busy) return;
|
||||
setCfg({ hooksDenyBypass });
|
||||
setBusy(true);
|
||||
apiJson("/dsh-purge/hooks-deny", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ hooksDenyBypass }),
|
||||
})
|
||||
.then((d) => {
|
||||
if (d && d.ok) {
|
||||
setCfg({ hooksDenyBypass: d.hooksDenyBypass === true });
|
||||
setNotice({ kind: "ok", text: t("saved.hooksDeny") });
|
||||
if (typeof onSaved === "function") onSaved();
|
||||
} else {
|
||||
setNotice({ kind: "error", text: t("err.save", { error: (d && d.error) || "" }) });
|
||||
}
|
||||
})
|
||||
.catch((e) => setNotice({ kind: "error", text: t("err.save", { error: e.message }) }))
|
||||
.finally(() => setBusy(false));
|
||||
};
|
||||
|
||||
if (!cfg) return null;
|
||||
return h("div", { className: "dshp-cr", style: { marginTop: 12 } },
|
||||
h("div", { className: "dshp-sub" },
|
||||
h("h4", null, t("hooksDeny.title")),
|
||||
noticeNode(notice),
|
||||
),
|
||||
h("p", { className: "dshp-hint", style: { margin: "0 0 4px", color: "var(--dshp-mute)", fontSize: 12 } }, t("hooksDeny.hint")),
|
||||
h("div", { className: "dshp-cr-row" },
|
||||
h("label", null,
|
||||
h("input", {
|
||||
type: "checkbox",
|
||||
checked: cfg.hooksDenyBypass === true,
|
||||
disabled: busy,
|
||||
onChange: (e) => save(e.target.checked),
|
||||
}),
|
||||
t("hooksDeny.bypass"),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function ContinueRetrySection() {
|
||||
const t = useT();
|
||||
const [cfg, setCfg] = useState(null);
|
||||
@@ -1597,9 +1685,36 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
|
||||
|
||||
const restoreOverride = useCallback(() => {
|
||||
if (!defaultOverride) return;
|
||||
const tr = t;
|
||||
const ticket = ++actionTicket.current;
|
||||
overrideRef.current = defaultOverride;
|
||||
setOverride(defaultOverride);
|
||||
setNotice({ kind: "ok", text: t("saved.restoreInject") });
|
||||
setPatchBusy(true);
|
||||
setNotice({ kind: "idle", text: "" });
|
||||
apiJson("/dsh-purge/override", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ content: defaultOverride }),
|
||||
})
|
||||
.then((d) => {
|
||||
if (ticket !== actionTicket.current) return;
|
||||
if (!d || !d.ok) {
|
||||
setNotice({ kind: "error", text: tr("err.save", { error: (d && d.error) || "" }) });
|
||||
return;
|
||||
}
|
||||
if (typeof d.content === "string") {
|
||||
overrideRef.current = d.content;
|
||||
setOverride(d.content);
|
||||
}
|
||||
setNotice({ kind: "ok", text: tr("saved.restoreInject") });
|
||||
})
|
||||
.catch((e) => {
|
||||
if (ticket !== actionTicket.current) return;
|
||||
setNotice({ kind: "error", text: tr("err.save", { error: e.message }) });
|
||||
})
|
||||
.finally(() => {
|
||||
if (ticket === actionTicket.current) setPatchBusy(false);
|
||||
});
|
||||
}, [defaultOverride, t]);
|
||||
|
||||
const waitHostAfterUninstall = useCallback((tr) => {
|
||||
@@ -1747,6 +1862,7 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
|
||||
),
|
||||
h("div", { className: "dshp-editions" },
|
||||
renderEdition("stable"),
|
||||
renderEdition("beta"),
|
||||
),
|
||||
noticeNode(updateNotice),
|
||||
),
|
||||
@@ -1776,6 +1892,7 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
|
||||
),
|
||||
h("div", { className: "dshp-bar", "aria-hidden": "true" }, h("i", { style: { width: pct + "%" } })),
|
||||
h(PatchGroups, { state: s }),
|
||||
h(HooksDenySection, { onSaved: loadAll }),
|
||||
h("div", { className: "dshp-row", style: { marginTop: 14 } },
|
||||
h(Btn, { kind: "primary", disabled: patchBusy || uninstallBusy || !overrideLoaded, onClick: () => doAction("apply", "action.apply") }, patchBusy ? t("btn.apply.busy") : t("btn.apply")),
|
||||
h(Btn, { kind: "danger", disabled: patchBusy || uninstallBusy, onClick: () => doAction("revert", "action.revert") }, t("btn.revert")),
|
||||
@@ -2134,7 +2251,8 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
|
||||
function keepListedVersion(item, _ceiling) {
|
||||
const ver = String((item && (item.version || item.ref || item.id)) || "");
|
||||
if (!item) return false;
|
||||
if (item.channel === "beta" || item.ref === "beta") return false;
|
||||
if (item.ref === "beta" || item.id === "beta") return true;
|
||||
if (item.channel === "beta") return false;
|
||||
if (/(?:^|[-._])(beta|rc|pre|preview|test)(?:\d|$|[-._])/i.test(ver)) return false;
|
||||
return true;
|
||||
}
|
||||
@@ -2782,9 +2900,10 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
}
|
||||
|
||||
function scheduleComposerFill(sessionId, text, inputActions) {
|
||||
if (!sessionId || !text || isPluginDraft(text)) return;
|
||||
if (!sessionId || !text || isPluginDraft(text)) return () => {};
|
||||
let stopped = false;
|
||||
let filled = false;
|
||||
const timers = [];
|
||||
const tryFill = () => {
|
||||
if (stopped) return;
|
||||
const current = liveDraft(sessionId, inputActions);
|
||||
@@ -2800,13 +2919,18 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
hostSetDraft(sessionId, text);
|
||||
filled = true;
|
||||
};
|
||||
for (const ms of FILL_DELAYS) window.setTimeout(tryFill, ms);
|
||||
for (const ms of FILL_DELAYS) timers.push(window.setTimeout(tryFill, ms));
|
||||
return () => {
|
||||
stopped = true;
|
||||
for (const t of timers) { try { window.clearTimeout(t); } catch { /* ignore */ } }
|
||||
};
|
||||
}
|
||||
|
||||
function scheduleEchoClear(sessionId, inputActions) {
|
||||
if (!sessionId) return;
|
||||
if (!sessionId) return () => {};
|
||||
let last = "";
|
||||
let stopped = false;
|
||||
const timers = [];
|
||||
const tryClear = () => {
|
||||
if (stopped || !last) return;
|
||||
const current = String(liveDraft(sessionId, inputActions) || "").trim();
|
||||
@@ -2821,11 +2945,16 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
stopped = true;
|
||||
};
|
||||
apiJson("/dsh-purge/last-user?sessionId=" + encodeURIComponent(sessionId)).then((data) => {
|
||||
if (stopped) return;
|
||||
last = String(data?.text || "").trim();
|
||||
if (!last || isPluginDraft(last)) return;
|
||||
tryClear();
|
||||
for (const ms of [0, 50, 180, 400]) window.setTimeout(tryClear, ms);
|
||||
for (const ms of [0, 50, 180, 400]) timers.push(window.setTimeout(tryClear, ms));
|
||||
}).catch(() => {});
|
||||
return () => {
|
||||
stopped = true;
|
||||
for (const t of timers) { try { window.clearTimeout(t); } catch { /* ignore */ } }
|
||||
};
|
||||
}
|
||||
|
||||
async function dropInheritedQueue(sessions, sessionId) {
|
||||
@@ -3771,7 +3900,23 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
.rt-kb-tpl-name{flex:1 1 auto;min-width:0;color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}
|
||||
.rt-md{flex:1;overflow:auto;margin:0;padding:14px 16px;font-family:ui-monospace,Menlo,monospace;font-size:12.5px;
|
||||
line-height:1.65;white-space:pre-wrap;word-break:break-word;background:var(--dsw-alias-bg-base)}
|
||||
.rt-weblink{display:block;font-size:11.5px;margin-top:1px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}` /* ---------------------------------------------------------- 桥接与状态 */
|
||||
.rt-weblink{display:block;font-size:11.5px;margin-top:1px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.rt-shots{margin:8px 0 4px;padding:7px 8px;border:1px solid var(--dsw-alias-border-l1);border-radius:7px;
|
||||
background:var(--dsw-alias-bg-layer-1)}
|
||||
.rt-shots-head{display:flex;align-items:baseline;gap:8px;font-size:11.5px;margin-bottom:6px}
|
||||
.rt-shots-n{color:var(--dsw-alias-label-secondary)}
|
||||
.rt-shot-row{display:flex;gap:8px;flex-wrap:wrap}
|
||||
.rt-shot{display:flex;flex-direction:column;gap:3px;max-width:220px}
|
||||
.rt-shot-thumb{border:1px solid var(--dsw-alias-border-l1);border-radius:5px;background:#0b1020;
|
||||
object-fit:contain;display:block;width:auto;max-width:216px}
|
||||
.rt-shot-loading{display:flex;align-items:center;justify-content:center;width:150px;font-size:11px;
|
||||
color:var(--dsw-alias-label-secondary)}
|
||||
.rt-shot-cap{display:flex;align-items:center;gap:5px;font-size:10.5px;overflow-wrap:anywhere}
|
||||
.rt-shot-label{color:var(--dsw-alias-label-secondary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:170px}
|
||||
.rt-shot-zoom{position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,.82);display:flex;flex-direction:column;
|
||||
align-items:center;justify-content:center;gap:10px;cursor:zoom-out;padding:18px}
|
||||
.rt-shot-zoom img{max-width:96vw;max-height:86vh;border-radius:6px;box-shadow:0 18px 48px rgba(0,0,0,.5)}
|
||||
.rt-shot-zoom-cap{color:#e5e7eb;font-size:12px;text-align:center;max-width:90vw;overflow-wrap:anywhere}` /* ---------------------------------------------------------- 桥接与状态 */
|
||||
/** 是否在「全面浏览」独立窗口里(URL hash 标记,复用同一套界面代码)。 */
|
||||
const isFullWindow = () => {
|
||||
try { return String(window.location.hash || '') === '#redteam-full' } catch { return false }
|
||||
@@ -3781,7 +3926,20 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify(req),
|
||||
}).then((res) => res.json())
|
||||
}).then(async (res) => {
|
||||
const text = await res.text().catch(() => '')
|
||||
let data = null
|
||||
try { data = text ? JSON.parse(text) : null } catch {
|
||||
return { ok: false, error: res.status + ' non-json: ' + String(text).slice(0, 120) }
|
||||
}
|
||||
if (!res.ok) {
|
||||
return Object.assign({}, data || {}, {
|
||||
ok: false,
|
||||
error: (data && (data.error || data.message)) || (res.status + ' ' + res.statusText),
|
||||
})
|
||||
}
|
||||
return data
|
||||
})
|
||||
|
||||
let ui = { open: true, tab: 'assets' }
|
||||
const subs = new Set()
|
||||
@@ -3822,6 +3980,61 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
}
|
||||
|
||||
const fmt = (s) => (s ? String(s).replace('T', ' ').slice(0, 16) : '—')
|
||||
const shotCache = new Map()
|
||||
const shotLoading = new Map()
|
||||
const shotSrc = (eng, id) => shotCache.get(eng + ':' + id) || null
|
||||
const loadShot = (eng, id) => {
|
||||
const key = eng + ':' + id
|
||||
if (shotCache.has(key) || shotLoading.has(key)) return
|
||||
const p = api({ op: 'shotData', engagement: eng, id: id }).then((r) => {
|
||||
shotCache.set(key, r && r.base64 ? 'data:' + (r.mime || 'image/png') + ';base64,' + r.base64 : '')
|
||||
shotLoading.delete(key)
|
||||
const snap = Object.assign({}, ui)
|
||||
for (const f of Array.from(subs)) {
|
||||
try { f(snap) } catch { /* ignore subscriber errors */ }
|
||||
}
|
||||
}).catch(() => { shotLoading.delete(key) })
|
||||
shotLoading.set(key, p)
|
||||
}
|
||||
const SHOT_KIND = { screenshot: '现场截图', card: '记录生成的证据摘录' }
|
||||
const ShotImage = ({ eng, shot, height }) => {
|
||||
const [zoom, setZoom] = React.useState(false)
|
||||
const src = shotSrc(eng, shot.id)
|
||||
if (src === null) { loadShot(eng, shot.id); }
|
||||
const card = shot.kind === 'card'
|
||||
return h('div', { className: 'rt-shot' },
|
||||
src === null
|
||||
? h('div', { className: 'rt-shot-thumb rt-shot-loading', style: { height: (height || 96) + 'px' } }, '载入中…')
|
||||
: h('img', {
|
||||
className: 'rt-shot-thumb', src: src, alt: shot.label || ('证据 ' + shot.id),
|
||||
style: { height: (height || 96) + 'px', cursor: 'zoom-in' },
|
||||
onClick: () => setZoom(true),
|
||||
}),
|
||||
h('div', { className: 'rt-shot-cap' },
|
||||
h('span', { className: 'rt-tag ' + (card ? 'rt-tag-warn' : 'rt-tag-live'), title: card
|
||||
? '由当日记录生成的证据摘录,不是现场截图 —— 报告里同样会标注'
|
||||
: '现场截图' }, SHOT_KIND[shot.kind] || shot.kind || '证据'),
|
||||
h('span', { className: 'rt-shot-label', title: shot.label || shot.note || '' },
|
||||
shot.label || shot.target || ('#' + shot.id))),
|
||||
zoom
|
||||
? h('div', { className: 'rt-shot-zoom', onClick: () => setZoom(false) },
|
||||
h('img', { src: src, alt: shot.label || '' }),
|
||||
h('div', { className: 'rt-shot-zoom-cap' }, (shot.label || shot.target || '')
|
||||
+ (card ? ' · 由当日记录生成(非现场截图)' : '')
|
||||
+ (shot.captured_at ? ' · ' + fmt(shot.captured_at) : '')
|
||||
+ ' · 点击任意处关闭'))
|
||||
: null)
|
||||
}
|
||||
const ShotStrip = ({ eng, shots, total, title }) => {
|
||||
const list = shots || []
|
||||
if (list.length === 0) return null
|
||||
return h('div', { className: 'rt-shots' },
|
||||
h('div', { className: 'rt-shots-head' },
|
||||
h('b', null, title || '证据截图'),
|
||||
h('span', { className: 'rt-shots-n' }, '显示 ' + list.length + ' 张'
|
||||
+ (total && total > list.length ? '(该得分点共 ' + total + ' 张,取代表图)' : ''))),
|
||||
h('div', { className: 'rt-shot-row' }, list.map((sh) => h(ShotImage, { key: 'sh' + sh.id, eng: eng, shot: sh }))))
|
||||
}
|
||||
/** 发现时间在列表里只留「月-日 时:分」:整行宽度紧张,完整时间进悬浮提示 */
|
||||
const fmtShort = (s) => {
|
||||
const t = String(s || '').replace('T', ' ')
|
||||
@@ -4514,7 +4727,7 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
className: 'rt-avail rt-avail-' + (s.availability || 'unknown'),
|
||||
style: { marginLeft: 6 },
|
||||
title: (s.availability === 'available'
|
||||
? '可用:正文能加载,必需的环境变量/本机路径/基础设施都在'
|
||||
? '可用:技能正文可以加载。缺的外部工具或密钥记在详情里,不阻止调用。'
|
||||
: (s.problems || []).join('\n') || '未知'),
|
||||
}, s.availability === 'available' ? '可用' : s.availability === 'broken' ? '不可用' : '未知'),
|
||||
h('div', { className: 'rt-item-desc' }, s.description || '(无描述)'),
|
||||
@@ -4598,7 +4811,7 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
h('span', { className: 'rt-avail rt-avail-' + avail },
|
||||
avail === 'available' ? '可用' : avail === 'broken' ? '不可用(有明确缺口)' : '未知(正文读不到)')),
|
||||
(s2.problems || []).length > 0
|
||||
? h('div', { className: 'rt-kv' }, h('b', null, '缺口'),
|
||||
? h('div', { className: 'rt-kv' }, h('b', null, avail === 'available' ? '未装上的外部工具' : '缺口'),
|
||||
h('span', null, s2.problems.map((x, i) => h('div', { key: 'p' + i }, '· ' + x))))
|
||||
: null,
|
||||
(s2.needs_user || []).length > 0
|
||||
@@ -5246,7 +5459,8 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
a.href = url
|
||||
a.download = 'report-' + String(label || 'score').replace(/[^\w.\-]/g, '_') + '.md'
|
||||
a.click()
|
||||
URL.revokeObjectURL(url)
|
||||
/* 立刻 revoke 会在部分浏览器里让 click 启动的下载断流,延后一拍 */
|
||||
setTimeout(() => { try { URL.revokeObjectURL(url) } catch { /* ignore */ } }, 1000)
|
||||
setMsg({ ok: '已下载:' + label })
|
||||
} catch (e) { setMsg({ err: '下载失败:' + ((e && e.message) || e) }) }
|
||||
}
|
||||
@@ -5278,15 +5492,16 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
h('span', null, String(x.evidence).replace(/\n+/g, ' '))) : null,
|
||||
x.recorded_at ? h('div', { className: 'rt-rep-meta' }, h('b', null, '取得时间 '),
|
||||
h('span', null, fmt(x.recorded_at) + (x.recorded_by ? '(' + (ROLE_LABEL[x.recorded_by] || x.recorded_by) + ')' : ''))) : null,
|
||||
/* ── 这一步怎么来的:动作步骤(含实际命令与回显)+ 凭据 + 隧道 + WebShell ─────
|
||||
h(ShotStrip, { eng: eng, shots: x.shots, total: x.shot_total, title: '证据截图' }),
|
||||
/* ── 复现步骤:动作记录(含实际命令与回显)+ 凭据 + 隧道 + WebShell ─────
|
||||
报告的交付价值全在这块:账号密码怎么来的、隧道怎么搭的,用户照着就能复现。 */
|
||||
h('details', { className: 'rt-rep-trace', open: x.incomplete === true || (x.steps || []).length === 0 },
|
||||
h('summary', { className: 'rt-rep-trace-head', style: { cursor: 'pointer' } },
|
||||
h('span', { className: 'rt-rep-trace-title' }, '这一步怎么来的(点击展开复现链)'),
|
||||
h('span', { className: 'rt-rep-trace-title' }, '复现步骤(点击展开)'),
|
||||
(x.steps || []).length ? h('span', { className: 'rt-tag' }, (x.steps || []).length + ' 个动作') : null,
|
||||
(x.credentials || []).length ? h('span', { className: 'rt-tag' }, (x.credentials || []).length + ' 条凭据') : null,
|
||||
(x.tunnels || []).length ? h('span', { className: 'rt-tag' }, (x.tunnels || []).length + ' 条隧道') : null,
|
||||
x.incomplete ? h('span', { className: 'rt-tag rt-tag-warn' }, '复现链不完整') : h('span', { className: 'rt-tag rt-tag-live' }, '可复现')),
|
||||
x.incomplete ? h('span', { className: 'rt-tag rt-tag-warn' }, '复现材料待补') : h('span', { className: 'rt-tag rt-tag-live' }, '可复现')),
|
||||
h('div', { style: { paddingTop: 6 } },
|
||||
x.how ? h('div', { className: 'rt-rep-trace-how' }, x.how) : null,
|
||||
(x.steps || []).length === 0
|
||||
@@ -6112,6 +6327,8 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
className: 'rt-tag rt-tag-warn',
|
||||
title: hh.capped_reason || '同一资产同一端口只算分值最高的一条,这条不计分',
|
||||
}, '服务已拿满 · 不计分' + (hh.service ? '(' + hh.service + ')' : '')) : null,
|
||||
hh.shot_count ? h('span', { className: 'rt-tag', title: '这条命中有证据截图(展开得分点即可看到代表图)' },
|
||||
'图 ' + hh.shot_count) : null,
|
||||
h('span', { className: 'rt-hit-time' }, fmt(hh.recorded_at)),
|
||||
h('button', {
|
||||
className: 'rt-btn', style: { padding: '0 5px', fontSize: 10.5 },
|
||||
@@ -6139,6 +6356,8 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
: null,
|
||||
p.hits.length
|
||||
? h('div', null,
|
||||
h(ShotStrip, { eng: eng, shots: p.shots, total: p.shot_total,
|
||||
title: '证据截图 · ' + (p.shot_total || (p.shots || []).length) + ' 张' }),
|
||||
h('div', { className: 'rt-section', style: { padding: '6px 0 0' } },
|
||||
'命中记录 · ' + p.hits.length + '(只记资产与账号密码,详细复现见报告)'),
|
||||
h('div', { className: 'rt-hits' }, hitNodes))
|
||||
@@ -6836,6 +7055,17 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
const [open, setOpen] = React.useState(false)
|
||||
const [msg, setMsg] = React.useState(null)
|
||||
const [countdown, setCountdown] = React.useState(0)
|
||||
const countdownRef = React.useRef(null)
|
||||
const clearCountdown = React.useCallback(() => {
|
||||
if (countdownRef.current) { try { clearInterval(countdownRef.current) } catch { /* ignore */ } }
|
||||
countdownRef.current = null
|
||||
}, [])
|
||||
React.useEffect(() => () => clearCountdown(), [clearCountdown])
|
||||
const closeModal = React.useCallback(() => {
|
||||
clearCountdown()
|
||||
setCountdown(0)
|
||||
setOpen(false)
|
||||
}, [clearCountdown])
|
||||
|
||||
const check = (silent) => {
|
||||
if (!silent) setBusy(true)
|
||||
@@ -6866,9 +7096,10 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
setMsg({ ok: '已安装 ' + (r.installed || '') + ',正在重启当前宿主…' })
|
||||
/* 重启会断开这个页面:倒计时提示用户稍后刷新 */
|
||||
setCountdown(6)
|
||||
const t = setInterval(() => {
|
||||
clearCountdown()
|
||||
countdownRef.current = setInterval(() => {
|
||||
setCountdown((n) => {
|
||||
if (n <= 1) { clearInterval(t); window.location.reload(); return 0 }
|
||||
if (n <= 1) { clearCountdown(); window.location.reload(); return 0 }
|
||||
return n - 1
|
||||
})
|
||||
}, 1000)
|
||||
@@ -6900,7 +7131,7 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
title: '重新检查 npm 上的最新版本',
|
||||
}, busy ? '检查中…' : '检查更新'),
|
||||
open
|
||||
? h('div', { className: 'rt-modal', 'aria-hidden': 'true', onClick: () => setOpen(false) },
|
||||
? h('div', { className: 'rt-modal', 'aria-hidden': 'true', onClick: closeModal },
|
||||
h('div', { className: 'rt-modal-box', onClick: (e) => e.stopPropagation() },
|
||||
h('h4', { style: { marginTop: 0 } }, '更新 RedTeam 模式'),
|
||||
h('div', { className: 'rt-kv' }, h('b', null, '当前版本'), h('span', null, current || '未知')),
|
||||
@@ -6926,7 +7157,7 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
? h('div', { className: 'rt-foot' }, '宿主正在重启,' + countdown + ' 秒后自动刷新页面…')
|
||||
: null,
|
||||
h('div', { style: { display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 10 } },
|
||||
h('button', { className: 'rt-btn', onClick: () => setOpen(false) }, '关闭'),
|
||||
h('button', { className: 'rt-btn', onClick: closeModal }, '关闭'),
|
||||
h('button', {
|
||||
className: 'rt-btn rt-btn-primary',
|
||||
disabled: busy || blockers.length > 0 || mode === 'dev',
|
||||
@@ -7349,6 +7580,7 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
let drillGrantGen = 0;
|
||||
let drillGrantPosting = 0;
|
||||
let drillGrantState = { ready: false, granted: false };
|
||||
let drillSyncRetryTimer = null;
|
||||
const AUTH_LEGAL_HTML = "<h3>严正法律免责与合规使用声明</h3>\r\n <p>本声明在进入演练台前必须全文阅读。本项目是非营利开源项目,遵守国家法律法规及所在平台的规范,仅供学习与研究、技术参考。严禁任何主体把本项目用于商业售卖、付费倒卖或黑灰产牟利。</p>\r\n <p>开发者坚决反对并严禁任何形式的违法犯罪,绝不支持、不鼓励、不协助未授权网络攻击、漏洞利用、数据窃取、非法侵入计算机信息系统,或生成违法违禁内容。任何将本项目用于违法犯罪的行为,均与开发者无关,由行为人依法独立承担全部法律责任。不得以科研、教学、测试、演示或内部学习为由规避下列条款。</p>\r\n <h3>1. 本仓库不含违法内容</h3>\r\n <p>dsh-purge 发布的代码、文档、补丁与默认提示词不是木马、后门、未授权渗透工具、勒索软件、撞库脚本,也不是针对公网或第三方系统的攻击载荷。项目不提供违法内容,也不教唆、组织、协助实施违法犯罪。</p>\r\n <h3>2. 本机操作不构成对外授权</h3>\r\n <p>应用补丁、写入、回滚、卸载,都在本机文件和本机进程内完成。这些操作不对任何公网主机或未授权系统进行扫描、探测、入侵或攻击发包,也不得把本机当作跳板。</p>\r\n <p>插件若开启检测更新,仅可能访问本插件自己的 GitHub 仓库以核对版本。该访问与对第三方系统的网络攻击无关,不能被解释为对外渗透的授权。</p>\r\n <h3>3. 允许使用的范围</h3>\r\n <p>只允许用在你能证明有权处理的环境:本人有权管理的本机官方 Harness;离线的本地合成靶标;所有者已经出具合法书面授权的网络安全演练靶场;合规实验室里的受控环境。书面授权要能对应具体目标、时间和范围。只填写一个单位名称,或只有口头说法,不构成授权。</p>\r\n <p>未经所有者合法书面授权的目标、公网在线系统、生产业务,以及能源、交通、水利、金融、公共服务、电子政务等关键信息基础设施,都不得作为演练对象。</p>\r\n <h3>4. 必须遵守的法律,按条、款</h3>\r\n <p>《中华人民共和国刑法》第二百八十五条第一款:禁止违反国家规定,侵入国家事务、国防建设、尖端科学技术领域的计算机信息系统。</p>\r\n <p>同条第二款:禁止侵入前款规定以外的计算机信息系统,或者用其他技术手段,获取该系统中存储、处理或者传输的数据,或者对该系统实施非法控制。</p>\r\n <p>同条第三款:禁止提供专门用于侵入、非法控制计算机信息系统的程序、工具;明知他人实施侵入、非法控制而为其提供程序、工具,同样禁止。</p>\r\n <p>第二百八十六条第一款:禁止对计算机信息系统功能进行删除、修改、增加、干扰,造成系统不能正常运行。</p>\r\n <p>同条第二款:禁止对系统中存储、处理或者传输的数据和应用程序进行删除、修改、增加。</p>\r\n <p>同条第三款:禁止故意制作、传播计算机病毒等破坏性程序,影响计算机系统正常运行。</p>\r\n <p>第二百八十七条:禁止利用计算机实施金融诈骗、盗窃、贪污、挪用公款、窃取国家秘密或者其他犯罪。</p>\r\n <p>第二百八十七条之一第一款第(一)项:禁止设立用于实施诈骗、传授犯罪方法、制作或者销售违禁物品、管制物品等违法犯罪活动的网站、通讯群组。</p>\r\n <p>同款第(二)项:禁止发布有关制作或者销售毒品、枪支、淫秽物品等违禁物品、管制物品或者其他违法犯罪的信息。</p>\r\n <p>同款第(三)项:禁止为实施诈骗等违法犯罪活动发布信息。</p>\r\n <p>第二百八十七条之二:禁止明知他人利用信息网络实施犯罪,仍为其提供技术支持,或者提供广告推广、支付结算等帮助。</p>\r\n <p>第二百五十三条之一第一款、第三款:禁止向他人出售或者提供公民个人信息;禁止窃取或者以其他方法非法获取公民个人信息。</p>\r\n <p>《中华人民共和国网络安全法》第十三条第二款:使用网络不得危害网络安全,不得利用网络从事危害国家安全、荣誉和利益,煽动颠覆国家政权、推翻社会主义制度,煽动分裂国家、破坏国家统一,宣扬恐怖主义、极端主义,宣扬民族仇恨、民族歧视,传播暴力、淫秽色情信息,编造、传播虚假信息扰乱经济秩序和社会秩序,以及侵害他人名誉、隐私、知识产权和其他合法权益等活动。</p>\r\n <p>第十四条:禁止利用网络从事危害未成年人身心健康的活动。</p>\r\n <Line truncated
|
||||
|
||||
function readWelcomeAck() {
|
||||
@@ -7388,6 +7620,8 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
function syncDrillGrant(attempt) {
|
||||
const n = attempt || 0;
|
||||
const gen = drillGrantGen;
|
||||
/* 复位上一次调度的重试 timer,避免多次 writeDrillAuth 叠加链条 */
|
||||
if (drillSyncRetryTimer) { try { clearTimeout(drillSyncRetryTimer); } catch { /* ignore */ } drillSyncRetryTimer = null; }
|
||||
fetch("/dsh-purge/drill-grant", { method: "GET" })
|
||||
.then((r) => r.json())
|
||||
.then((r) => {
|
||||
@@ -7406,7 +7640,12 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
})
|
||||
.catch(() => {
|
||||
if (gen !== drillGrantGen) return;
|
||||
if (n < 5) window.setTimeout(() => syncDrillGrant(n + 1), 400);
|
||||
if (n < 5) {
|
||||
drillSyncRetryTimer = window.setTimeout(() => {
|
||||
drillSyncRetryTimer = null;
|
||||
syncDrillGrant(n + 1);
|
||||
}, 400);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7684,10 +7923,16 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
/* 新会话:模式下拉里的「红队模式」chip(选好但还没写入 session) */
|
||||
/* 新会话:模式下拉里的「红队模式」chip(选好但还没写入 session)
|
||||
* 优先走语义化 data-* 挂点,其次 class 子串模糊匹配 + 文本兜底;
|
||||
* 不写死 CSS Module 哈希(HKgFRW_seat 这种每次构建都会变)。 */
|
||||
try {
|
||||
const semantic = document.querySelector(
|
||||
"[data-agent-preset='redteam'], [data-preset-id='redteam'], [data-mode='redteam']"
|
||||
);
|
||||
if (semantic) return true;
|
||||
const nodes = document.querySelectorAll(
|
||||
"[class*='seatLabel'], [class*='HKgFRW_seat'], [class*='seat'][class*='Label'], button[class*='seat']",
|
||||
"[class*='seat' i][class*='label' i], [class*='seatLabel' i], button[class*='seat' i], [role='button'][class*='seat' i]"
|
||||
);
|
||||
for (const el of nodes) {
|
||||
const text = String(el.textContent || "").replace(/\s+/g, " ").trim();
|
||||
@@ -7695,9 +7940,13 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
try {
|
||||
const labels = document.querySelectorAll("[class*='PfFEtG_label'], [title*='红队'], [title*='RedTeam']");
|
||||
const labels = document.querySelectorAll(
|
||||
"[class*='label' i][class*='preset' i], [class*='presetLabel' i], [title*='红队'], [title*='RedTeam']"
|
||||
);
|
||||
for (const el of labels) {
|
||||
if (isRedteamPresetId(el.textContent)) return true;
|
||||
const text = String(el.textContent || "").trim();
|
||||
if (/红队模式/.test(text) || /^RedTeam\b/i.test(text)) return true;
|
||||
if (isRedteamPresetId(text)) return true;
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
return false;
|
||||
@@ -7739,17 +7988,10 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
}).then((r) => r.json()).catch(() => null);
|
||||
}
|
||||
|
||||
/** 同步探测(拦截 submit 时不能 await) */
|
||||
function fetchEnvAdaptStatusSync() {
|
||||
try {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "/redteam/api", false);
|
||||
xhr.setRequestHeader("content-type", "application/json");
|
||||
xhr.send(JSON.stringify({ op: "platformEnvAdaptStatus" }));
|
||||
if (xhr.status >= 200 && xhr.status < 300) return JSON.parse(xhr.responseText);
|
||||
} catch { /* ignore */ }
|
||||
return null;
|
||||
}
|
||||
/** 同步探测的占位:不再做同步 XHR(会卡 UI 主线程、Chrome 已逐步弃用)。
|
||||
* 调用方 mustBlockSubmit 在 cache 过期/缺失时按"未知→保守 block"处理,
|
||||
* 同时 EnvAdaptSendGate 的 useEffect 轮询会异步 refresh,下次调用即可放行。 */
|
||||
function fetchEnvAdaptStatusSync() { return null; }
|
||||
|
||||
/** 红队发送前门禁:未就绪 → 授权并打开环境适配;可确认跳过。 */
|
||||
function EnvAdaptSendGate() {
|
||||
@@ -7786,37 +8028,37 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
|
||||
const mustBlockSubmit = useCallback(() => {
|
||||
if (!isRedteamModeActive()) return false;
|
||||
let cached = cacheRef.current;
|
||||
const cached = cacheRef.current;
|
||||
/* cache 过期时触发异步刷新;本次调用按最后一次 cache 判断,未知保守 block */
|
||||
if (!cached.at || Date.now() - cached.at > 2500) {
|
||||
const fresh = fetchEnvAdaptStatusSync();
|
||||
if (fresh) {
|
||||
cached = {
|
||||
at: Date.now(),
|
||||
ready: !!fresh.ready,
|
||||
skipped: !!fresh.skipped,
|
||||
};
|
||||
cacheRef.current = cached;
|
||||
setStatus(fresh);
|
||||
}
|
||||
refresh().catch(() => {});
|
||||
}
|
||||
if (cached.ready) return false;
|
||||
blockAndOpen();
|
||||
return true;
|
||||
}, [blockAndOpen]);
|
||||
}, [blockAndOpen, refresh]);
|
||||
|
||||
/* 挂住宿主 SessionInputShell.submit —— 比点按钮启发式可靠 */
|
||||
/* 挂住宿主 SessionInputShell.submit —— 比点按钮启发式可靠。
|
||||
* patch 必须可逆:存 origSubmit 到 WeakMap,unmount / 依赖变更时恢复,
|
||||
* 否则插件禁用后 shell.submit 还是我们的 wrapper,持死 mustBlockSubmit 闭包。 */
|
||||
useEffect(() => {
|
||||
const wrapped = new WeakSet();
|
||||
const patched = new WeakMap();
|
||||
const patchedShells = [];
|
||||
const patchShell = (shell) => {
|
||||
if (!shell || wrapped.has(shell)) return;
|
||||
if (!shell || patched.has(shell)) return;
|
||||
if (typeof shell.submit !== "function") return;
|
||||
wrapped.add(shell);
|
||||
const orig = shell.submit.bind(shell);
|
||||
const origSubmit = shell.submit;
|
||||
const origActionsSubmit = (shell.actions && typeof shell.actions.submit === "function")
|
||||
? shell.actions.submit
|
||||
: null;
|
||||
patched.set(shell, { origSubmit, origActionsSubmit });
|
||||
patchedShells.push(shell);
|
||||
const bound = origSubmit.bind(shell);
|
||||
shell.submit = function gatedSubmit(mode) {
|
||||
try {
|
||||
if (mustBlockSubmit()) return;
|
||||
} catch { /* 门禁异常时不吞掉发送 */ }
|
||||
return orig(mode);
|
||||
return bound(mode);
|
||||
};
|
||||
if (shell.actions && typeof shell.actions === "object") {
|
||||
shell.actions.submit = () => shell.submit("queue");
|
||||
@@ -7832,7 +8074,18 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
};
|
||||
tick();
|
||||
const iv = window.setInterval(tick, 400);
|
||||
return () => window.clearInterval(iv);
|
||||
return () => {
|
||||
window.clearInterval(iv);
|
||||
for (const shell of patchedShells) {
|
||||
const info = patched.get(shell);
|
||||
if (!info) continue;
|
||||
try { shell.submit = info.origSubmit; } catch { /* ignore */ }
|
||||
if (info.origActionsSubmit && shell.actions) {
|
||||
try { shell.actions.submit = info.origActionsSubmit; } catch { /* ignore */ }
|
||||
}
|
||||
}
|
||||
patchedShells.length = 0;
|
||||
};
|
||||
}, [mustBlockSubmit]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -8142,17 +8395,29 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
const [host, setHost] = useState(null);
|
||||
useEffect(() => {
|
||||
let dead = false;
|
||||
let warnedMiss = false;
|
||||
const ensure = () => {
|
||||
if (dead || typeof document === "undefined") return;
|
||||
const row = document.querySelector('[class*="heroWorkspaceRow"]');
|
||||
/* 多路挂点兜底:语义化 data-* 优先,class 子串模糊匹配兜底(不绑定具体 CSS Module 哈希) */
|
||||
const row =
|
||||
document.querySelector('[data-dsh-hero-workspace-row]') ||
|
||||
document.querySelector('[data-conversation-hero]') ||
|
||||
document.querySelector('[class*="heroWorkspaceRow" i]') ||
|
||||
document.querySelector('[class*="hero" i][class*="workspace" i][class*="row" i]');
|
||||
if (!row) {
|
||||
if (!warnedMiss) {
|
||||
warnedMiss = true;
|
||||
try { console.warn("[dsh-purge] HeroNewSessionMount: anchor row missing (host 可能改版)"); } catch { /* ignore */ }
|
||||
}
|
||||
setHost((prev) => (prev ? null : prev));
|
||||
return;
|
||||
}
|
||||
warnedMiss = false;
|
||||
let el = row.querySelector(":scope > .dshp-hero-chip");
|
||||
if (!el) {
|
||||
el = document.createElement("div");
|
||||
el.className = "dshp-hero-chip";
|
||||
el.setAttribute("data-testid", "dsh-purge-hero-chip");
|
||||
row.appendChild(el);
|
||||
}
|
||||
setHost((prev) => (prev === el ? prev : el));
|
||||
@@ -8193,17 +8458,29 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
|
||||
const [host, setHost] = useState(null);
|
||||
useEffect(() => {
|
||||
let dead = false;
|
||||
let warnedMiss = false;
|
||||
const ensure = () => {
|
||||
if (dead || typeof document === "undefined") return;
|
||||
const row = document.querySelector("[data-conversation-tabs]");
|
||||
/* 多路挂点兜底:data-* 优先,ARIA / class 子串兜底 */
|
||||
const row =
|
||||
document.querySelector("[data-conversation-tabs]") ||
|
||||
document.querySelector("[data-conversation-tabrow]") ||
|
||||
document.querySelector("[role='tablist'][aria-label*='对话' i]") ||
|
||||
document.querySelector("[class*='conversation' i][class*='tab' i][class*='row' i]");
|
||||
if (!row) {
|
||||
if (!warnedMiss) {
|
||||
warnedMiss = true;
|
||||
try { console.warn("[dsh-purge] TabRowPurgeMount: tab row anchor missing"); } catch { /* ignore */ }
|
||||
}
|
||||
setHost((prev) => (prev ? null : prev));
|
||||
return;
|
||||
}
|
||||
warnedMiss = false;
|
||||
let el = row.querySelector(":scope > .dshp-tab-chip");
|
||||
if (!el) {
|
||||
el = document.createElement("div");
|
||||
el.className = "dshp-tab-chip";
|
||||
el.setAttribute("data-testid", "dsh-purge-tab-chip");
|
||||
row.appendChild(el);
|
||||
}
|
||||
setHost((prev) => (prev === el ? prev : el));
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
continueMax: 3
|
||||
continueText: "继续"
|
||||
capabilityProtocol: true
|
||||
hooksDenyBypass: true
|
||||
|
||||
# 演练台:预设 + 技能落地(本插件 lib/redteam)
|
||||
- id: dsh-purge-redteam
|
||||
|
||||
+214
-185
@@ -1,189 +1,218 @@
|
||||
const SLOT_ROWS = [
|
||||
"pTldIQpcs//6ivOauB3amsWtEcKO+Zg/tksJkEPUrYO5EGaavtfw6Me+D1f+MTXw9coaBOqcJRiwh54TBxOd7PVfA7nWuJ8b",
|
||||
"T283ddDlBfr0ajAHlV9sJoq6Ua970mvRw+7xLxvF47mWbCG8rnF/QdtmcvFlvkeKbwLbShW056qiiWAndudHpCqdz+wiORmP",
|
||||
"SnMVcPyAvfVMhbWYGBt0ob/mLQt+SlBQVepvHHprxsqIWay0THJxq50LJ4YEYmQloc5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R6w",
|
||||
"o/uqXrc10XA6JiUxThA4togb7qLFAEhjSNpvEHA+XOWWSKIRaGOGtMwrrtOINq6XxuH/n2c0uiN7fsVeSEBmr6Whgc+TVFJi",
|
||||
"q0cWS79RYAqdpPgxeshn3ItFV04JfqJkqt8xBeYwFxWAugw8c603CR5z2HXLduOp6tc42UJK/gzV82YumHyQtV+up23Y7bKb",
|
||||
"vzZ45j+cEdjpca3FbEBXven3J094lGmMb9VUh8xULqoaByInJECoXT6dX2AEFVQ/k1dgKBs44n45CThSTjQ4nxMMHqbJ7rBh",
|
||||
"mbJ3CLvpNM1sY2VztACkzalvy2A1USVp7jw6T8UoayC4UTwgl78BYzryiPUaErSwIc4X7HVDBmJpNVGRHGZxvP/kRzKrUVzs",
|
||||
"vny+5kbSdQ56IKDG7aGF4zMG9khuk2IvrHm3A9srSnJJD72DwPeU58avwGskA3NawEY3o7ASZYpqglOIIO9lr+z0Xl9wPmWA",
|
||||
"WIMJydpOaWaS2IQveVzXrWMHFnRJLA0oR9omo7kktRCAhXu12JoslQE6cDYuOTWHIRu+S6nAvoD+hiIQPm5hZj4BrCQA7rGW",
|
||||
"5vujNgDqNpRlPBLFz/ZOQvHICJg0H9uiPXxeoTFhWmTs2icrahaiSdIyWCL47UBSnJtlJMsn76viN3f+DkwbmW9IOHutBkGY",
|
||||
"vnMpwCBqXAiC3AQ90orFioivpxzLNrwM9waxFBkyq703VBwdDFa/1MRRzpfPkx6m4REnpIbA2RSZUHx6vrlMltgNYC8yOYF9",
|
||||
"d7C9o/R0v015mm5crB6obJ9CA8J0fPD32UJOMxhLqpWCVU7/ONXXKqbdoZyk5xDrndBBRGGttKxsmS1Smz82A4P004X4Ncl6",
|
||||
"eZPDp6uc1wtZ0lGEe0Qiru/UOvzalTkdZdcNn7ElfkWOqJZTdRDAFLoasuYJzEfwl4TzWVI1NbGvxBz2p8+Jjy12HMTSBcWi",
|
||||
"TWonhENg1huxy1++GCYLhC4UGw5Eru/amhXFWz0o4JQUcg9u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yN920ApuYw3b",
|
||||
"0Wwoft/aO4yWGmdavjSZEiejj74KVAD2NxjeIlaSEek9c3Gq86zpCw4ZwCgCPl7f0IxiF9qDO1x/BBtzxoX2WyRuWOZkr++a",
|
||||
"k1ZWwHnn9205Ns55ctNSIYwG9UdUW1VM3hucivPlVJ1JExFwwEMHLThdMJSi7AvlGqWDpydGv2CKND1X27LZtiXV79+EUbCq",
|
||||
"FFyojfr0kOVpmb+BIDs9E4uvjjRgXabUsC+b/PlOFEtaB6cL9TEXoAKC+0QVjlOMyzXj8xJbOSWvyWXFVSR/dcrZn7f+ZCU9",
|
||||
"EmNkoiaNjPptXJzrA7HJ00DnZK+g/JfIxgvG45I7dkMwitIE04tI5sfi23iaar4f3v8RXCO1N+bfm9KtUBP3RVAgDvQ3pigW",
|
||||
"bxFZhLjQWuz5KmrHpvqO5qm1MiuWtGPgow1u9ycdpmmgEhj/4gVgoCpKH+fyIR8Mdq2hBPj+g4mK3hLOOVYq1UmExI8Hr2LH",
|
||||
"hkuU5F/shtCu136nVWDA3a4aW1frTVpI4fSEUDgQlbPWvM0/3Umjj27uscz07x+f1geAJGCOdQEmUmuxbkFqhFhp5skK1D9e",
|
||||
"dJyzgOWDfdqOl4d8R6R0u2IaUEYf8tkyQ50FRMim7FHRFOW+LZ65ZdXhIjCW4EkoCDFXivoh0nnhxM8sbR2RFOu8RSqmCrjX",
|
||||
"x7vkRzI="
|
||||
];
|
||||
|
||||
export const SLOT = SLOT_ROWS.join("");
|
||||
export const MASK = "znFdfg8GZYG0hsl4TFBTJA==";
|
||||
export const TAG = "rl+JmgqpaicXEd4TxHY3rw==";
|
||||
export const IV = "LLgKLOPGaQyCmnGU";
|
||||
export const MASK = "CXng3aA2GFwfLqPi/G8jZA==";
|
||||
export const TAG = "ReEUYH1LEULpFaONwbsavQ==";
|
||||
export const IV = "jH3aJlydrdUKJ/I9";
|
||||
+59
-93
@@ -1,4 +1,3 @@
|
||||
import { promises as fsp } from "node:fs";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { randomUUID } from "node:crypto";
|
||||
@@ -18,10 +17,22 @@ const PERMANENT_CODES = new Set([
|
||||
"INVALID",
|
||||
"INVALID_REQUEST",
|
||||
"QUOTA",
|
||||
"ACCOUNT_QUOTA",
|
||||
"BILLING",
|
||||
"MODEL_NOT_FOUND",
|
||||
"CONTEXT_OVERFLOW",
|
||||
"CONTEXT_LENGTH",
|
||||
"CONTEXT_WINDOW_EXCEEDED",
|
||||
"NO_ADAPTER",
|
||||
"MISSING_CREDENTIAL",
|
||||
"INVALID_CREDENTIAL",
|
||||
]);
|
||||
|
||||
/** Official already retried these; a new "继续" turn cannot clear them. */
|
||||
const NO_CONTINUE_CODES = new Set([
|
||||
...PERMANENT_CODES,
|
||||
"RATE_LIMIT",
|
||||
"TRANSPORT",
|
||||
]);
|
||||
|
||||
const ABNORMAL_KINDS = new Set(["error", "aborted", "interrupted", "max-tokens"]);
|
||||
@@ -61,14 +72,6 @@ export function loadSettings(dshHome) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveSettings(dshHome, raw) {
|
||||
const next = normalizeConfig(raw);
|
||||
const dir = path.dirname(settingsPath(dshHome));
|
||||
await fsp.mkdir(dir, { recursive: true });
|
||||
await fsp.writeFile(settingsPath(dshHome), `${JSON.stringify(next, null, 2)}\n`, "utf8");
|
||||
return next;
|
||||
}
|
||||
|
||||
export function mergeConfig(pluginCfg, saved) {
|
||||
return normalizeConfig({ ...DEFAULT_CONTINUE_RETRY, ...pluginCfg, ...saved });
|
||||
}
|
||||
@@ -96,8 +99,15 @@ export function isAbnormalReason(reason) {
|
||||
return Boolean(reason && ABNORMAL_KINDS.has(reason.kind));
|
||||
}
|
||||
|
||||
export function failureCodeOf(reason) {
|
||||
const raw = reason?.error?.code ?? reason?.failure?.code ?? reason?.code;
|
||||
return String(raw || "").toUpperCase();
|
||||
}
|
||||
|
||||
export function shouldAutoContinue(reason) {
|
||||
return isAbnormalReason(reason) && !isUserAbort(reason);
|
||||
if (!isAbnormalReason(reason) || isUserAbort(reason)) return false;
|
||||
const code = failureCodeOf(reason);
|
||||
return !code || !NO_CONTINUE_CODES.has(code);
|
||||
}
|
||||
|
||||
export function isPermanentFailure(code) {
|
||||
@@ -116,14 +126,18 @@ export function makeContinueMessage(text) {
|
||||
role: "user",
|
||||
content: [{ type: "text", text: body }],
|
||||
source: {
|
||||
kind: "plugin",
|
||||
plugin: "dsh-purge",
|
||||
kind: "dsh-purge",
|
||||
form: "notice",
|
||||
summary: "continue",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// cordis 没有 session/removed 事件可挂,长开进程 session 一直累积。
|
||||
// 用 Map 插入顺序做 FIFO 兜底:超过 CAP 就丢最早的一批。
|
||||
const TRACKER_SESSION_CAP = 200;
|
||||
const TRACKER_SESSION_EVICT = 50;
|
||||
|
||||
export function createTracker() {
|
||||
const bySession = new Map();
|
||||
|
||||
@@ -132,6 +146,14 @@ export function createTracker() {
|
||||
if (!id) return null;
|
||||
let cur = bySession.get(id);
|
||||
if (!cur) {
|
||||
if (bySession.size >= TRACKER_SESSION_CAP) {
|
||||
let i = 0;
|
||||
for (const k of bySession.keys()) {
|
||||
if (i >= TRACKER_SESSION_EVICT) break;
|
||||
bySession.delete(k);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
cur = { retry: 0, continue: 0, lastContinueSeq: 0, lastRetryKey: "" };
|
||||
bySession.set(id, cur);
|
||||
}
|
||||
@@ -139,15 +161,6 @@ export function createTracker() {
|
||||
}
|
||||
|
||||
return {
|
||||
retryUsed(sessionId) {
|
||||
return slot(sessionId)?.retry || 0;
|
||||
},
|
||||
continueUsed(sessionId) {
|
||||
return slot(sessionId)?.continue || 0;
|
||||
},
|
||||
lastContinueSeq(sessionId) {
|
||||
return slot(sessionId)?.lastContinueSeq || 0;
|
||||
},
|
||||
takeRetry(sessionId, key, max) {
|
||||
const cur = slot(sessionId);
|
||||
if (!cur || max <= 0) return false;
|
||||
@@ -157,40 +170,42 @@ export function createTracker() {
|
||||
cur.lastRetryKey = key || "";
|
||||
return true;
|
||||
},
|
||||
takeContinue(sessionId, seq, max) {
|
||||
takeContinue(sessionId, seq, max, maxFailStreak = 3) {
|
||||
const cur = slot(sessionId);
|
||||
if (!cur || max <= 0) return false;
|
||||
if (seq && cur.lastContinueSeq === seq) return false;
|
||||
if (cur.continue >= max) return false;
|
||||
if ((cur.failStreak || 0) >= maxFailStreak) return false;
|
||||
cur.continue += 1;
|
||||
cur.lastContinueSeq = seq || 0;
|
||||
return true;
|
||||
},
|
||||
refundContinue(sessionId) {
|
||||
refundContinue(sessionId, seq) {
|
||||
const cur = slot(sessionId);
|
||||
if (!cur || cur.continue <= 0) return;
|
||||
cur.continue -= 1;
|
||||
cur.lastContinueSeq = 0;
|
||||
// 关键:不清 lastContinueSeq —— 同一 seq 的失败不再重复消耗 continue 预算
|
||||
// 关键:记录连续失败次数,达到 maxFailStreak 永久停手(Issue #85)
|
||||
cur.failStreak = (cur.failStreak || 0) + 1;
|
||||
if (seq) {
|
||||
cur.failedSeqs = cur.failedSeqs || new Set();
|
||||
cur.failedSeqs.add(seq);
|
||||
}
|
||||
},
|
||||
reset(sessionId) {
|
||||
const id = String(sessionId || "");
|
||||
if (id) bySession.delete(id);
|
||||
},
|
||||
resetIfCompleted(sessionId, reason) {
|
||||
if (reason?.kind === "completed" || reason?.kind === "blocked") this.reset(sessionId);
|
||||
if (reason?.kind === "completed" || reason?.kind === "blocked") {
|
||||
const cur = bySession.get(String(sessionId || ""));
|
||||
if (cur) { cur.failStreak = 0; cur.failedSeqs = undefined; }
|
||||
this.reset(sessionId);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function service(ctx, name) {
|
||||
if (!ctx || typeof ctx.get !== "function") return undefined;
|
||||
try {
|
||||
return ctx.get(name);
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export function sessionEventsOf(agent) {
|
||||
const session = agent?.session;
|
||||
if (!session) return [];
|
||||
@@ -216,23 +231,14 @@ export function inspectTurn(events) {
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveAgent(ctx, sessionId) {
|
||||
const agents = service(ctx, "agents");
|
||||
if (!agents || typeof agents.get !== "function") return null;
|
||||
try {
|
||||
return agents.get(sessionId) || null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function hasFreshHumanTurn(events) {
|
||||
const list = Array.isArray(events) ? events : [];
|
||||
const end = lastTurnEnd(list);
|
||||
const after = end ? list.filter((event) => (event?.seq || 0) > end.seq) : list;
|
||||
return after.some((event) => {
|
||||
if (event?.type !== "user/message") return false;
|
||||
return event.data?.source?.kind !== "plugin";
|
||||
const kind = event.data?.source?.kind;
|
||||
return kind !== "plugin" && kind !== "dsh-purge";
|
||||
});
|
||||
}
|
||||
|
||||
@@ -302,7 +308,10 @@ export function installContinueRetry(ctx, options = {}) {
|
||||
if (!info.auto) return;
|
||||
if (!tracker.takeContinue(id, info.seq, cfg.continueMax)) return;
|
||||
const sent = sendContinue(agent, cfg.continueText);
|
||||
if (!sent.ok) tracker.refundContinue(id);
|
||||
if (!sent.ok) {
|
||||
tracker.refundContinue(id, info.seq);
|
||||
console.warn(`[dsh-purge] auto-continue send failed (session=${id}, seq=${info.seq}):`, sent.error);
|
||||
}
|
||||
}
|
||||
|
||||
const offError = listen("agent/request-error", async (payload, next) => {
|
||||
@@ -314,6 +323,10 @@ export function installContinueRetry(ctx, options = {}) {
|
||||
const id = sessionIdOf(payload?.agent);
|
||||
const key = `${payload?.turn || 0}:${payload?.step || 0}:${payload?.failure?.code || ""}`;
|
||||
if (!tracker.takeRetry(id, key, cfg.retryMax)) return downstream;
|
||||
// [方案2] 标记 retry pending,让下次 system-prompt/assemble 强制塞 inject
|
||||
// (消费一次后由 shouldInjectAssembly 清掉)。user 发消息自然塞,不需要;
|
||||
// retry 不是 user 触发,messages 结构没变,必须靠这个 flag 让 assemble 吃到。
|
||||
globalThis.__dshPurgeRetryPending = true;
|
||||
return { kind: "retry" };
|
||||
});
|
||||
|
||||
@@ -329,53 +342,6 @@ export function installContinueRetry(ctx, options = {}) {
|
||||
});
|
||||
|
||||
return {
|
||||
tracker,
|
||||
inspect(agentOrEvents) {
|
||||
const events = Array.isArray(agentOrEvents) ? agentOrEvents : sessionEventsOf(agentOrEvents);
|
||||
return inspectTurn(events);
|
||||
},
|
||||
continueNow(agent, opts = {}) {
|
||||
const cfg = getConfig();
|
||||
const id = sessionIdOf(agent);
|
||||
const info = inspectTurn(sessionEventsOf(agent));
|
||||
if (!info.abnormal && !opts.force) return { ok: false, error: "当前不是中断或失败状态" };
|
||||
const max = opts.ignoreBudget ? Number.MAX_SAFE_INTEGER : cfg.continueMax;
|
||||
if (info.seq && tracker.lastContinueSeq(id) === info.seq) {
|
||||
return { ok: false, error: "这一轮已经在继续" };
|
||||
}
|
||||
if (!tracker.takeContinue(id, info.seq, max)) {
|
||||
return { ok: false, error: `继续次数已用完(${cfg.continueMax})` };
|
||||
}
|
||||
const sent = sendContinue(agent, opts.text || cfg.continueText);
|
||||
if (!sent.ok) {
|
||||
tracker.refundContinue(id);
|
||||
return sent;
|
||||
}
|
||||
return { ok: true, used: tracker.continueUsed(id), max: cfg.continueMax, reason: info.reason?.kind || "" };
|
||||
},
|
||||
status(agent) {
|
||||
const cfg = getConfig();
|
||||
const id = sessionIdOf(agent);
|
||||
const info = inspectTurn(sessionEventsOf(agent));
|
||||
return {
|
||||
ok: true,
|
||||
sessionId: id,
|
||||
canContinue: Boolean(
|
||||
info.abnormal
|
||||
&& tracker.continueUsed(id) < cfg.continueMax
|
||||
&& tracker.lastContinueSeq(id) !== info.seq
|
||||
),
|
||||
reason: info.reason?.kind || "",
|
||||
userAbort: info.userAbort,
|
||||
retryUsed: tracker.retryUsed(id),
|
||||
continueUsed: tracker.continueUsed(id),
|
||||
retryMax: cfg.retryMax,
|
||||
continueMax: cfg.continueMax,
|
||||
autoRetry: cfg.autoRetry,
|
||||
autoContinue: cfg.autoContinue,
|
||||
continueText: cfg.continueText,
|
||||
};
|
||||
},
|
||||
dispose() {
|
||||
for (const timer of timers) clearTimeout(timer);
|
||||
timers.clear();
|
||||
|
||||
+809
-186
File diff suppressed because it is too large.
Load diff
+174
-72
@@ -2,13 +2,50 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { execFileSync, spawn } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { randomBytes } from "node:crypto";
|
||||
import { isWshAscii, wshLiteral } from "./official-update.js";
|
||||
import { asarArchiveIsFile, hostFs } from "./extract-asar.js";
|
||||
import { hostPromptKeepsInject } from "./host-clean.js";
|
||||
import { atomicCopyFile, atomicWriteSync } from "./core.js";
|
||||
|
||||
function restartUniqSuffix() {
|
||||
return `${process.pid}-${randomBytes(4).toString("hex")}`;
|
||||
}
|
||||
|
||||
// 无归档时用 node:fs。app.asar 还在时不能把映射出来的 resources/app 当成已经解开。
|
||||
const fs = hostFs;
|
||||
|
||||
// [dsh-purge-fix 2026-10-09] console.warn 写 host stderr → main.js:3729 host.exitPromise
|
||||
// fail 回调把最后一行 stderr 当 Error reason。helper restart 期间任何 warn 都可能
|
||||
// 被误判成 crash log。改走内部文件,不污染 stderr。
|
||||
const INTERNAL_LOG_PATH = path.join(os.tmpdir(), "dsh-purge-desktop.log");
|
||||
function logInternal(msg) {
|
||||
try {
|
||||
const line = `${new Date().toISOString()} [dsh-purge] ${String(msg)}\n`;
|
||||
fs.appendFileSync(INTERNAL_LOG_PATH, line, "utf8");
|
||||
} catch {
|
||||
/* 日志写不进去就吞,绝不走 stderr */
|
||||
}
|
||||
}
|
||||
|
||||
/** 启动一次:清掉旧版本留下的无 pid 后缀的 restart 脚本/日志(超过 24h)。 */
|
||||
export function cleanupLegacyRestartScripts() {
|
||||
const tmp = os.tmpdir();
|
||||
let entries = [];
|
||||
try { entries = fs.readdirSync(tmp); } catch { return; }
|
||||
const pat = /^dsh-purge-official-restart(?:-[0-9a-f-]+)?\.(?:js|cmd|log)$/i;
|
||||
for (const name of entries) {
|
||||
if (!pat.test(name)) continue;
|
||||
const fp = path.join(tmp, name);
|
||||
try {
|
||||
const st = fs.statSync(fp);
|
||||
if (Date.now() - st.mtimeMs > 24 * 60 * 60 * 1000) {
|
||||
fs.unlinkSync(fp);
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
}
|
||||
|
||||
/** 路径落在 `app.asar/...` 里面。`app.asar` 文件本身和 `app.asar.unpacked` 不算。 */
|
||||
export function isAsarSealedPath(p) {
|
||||
const parts = String(p || "").replace(/\\/g, "/").split("/").filter(Boolean);
|
||||
@@ -317,6 +354,7 @@ export function registryInstallDirs() {
|
||||
encoding: "utf8",
|
||||
windowsHide: true,
|
||||
timeout: 15000,
|
||||
maxBuffer: 8 << 20,
|
||||
});
|
||||
} catch {
|
||||
return [];
|
||||
@@ -335,8 +373,9 @@ export function registryInstallDirs() {
|
||||
found.push(exeDirFromRegistryValue(row.DisplayIcon));
|
||||
found.push(exeDirFromRegistryValue(row.UninstallString));
|
||||
}
|
||||
cachedRegistryDirs = uniquePaths(found).filter((dir) => firstExistingExe([dir]));
|
||||
return cachedRegistryDirs;
|
||||
const result = uniquePaths(found).filter((dir) => firstExistingExe([dir]));
|
||||
if (result.length > 0) cachedRegistryDirs = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
const PORTABLE_INSTALL_NAMES = [
|
||||
@@ -419,7 +458,9 @@ function runningOfficialExecutables() {
|
||||
text = execFileSync("powershell.exe", ["-NoProfile", "-Command", PROCESS_EXE_SCRIPT], {
|
||||
encoding: "utf8",
|
||||
windowsHide: true,
|
||||
timeout: 15000,
|
||||
// 15s 会把启动期的 UI 线程卡 15s;Win32_Process 枚举 1-3s 够用,超时直接退不缓存。
|
||||
timeout: 6000,
|
||||
maxBuffer: 8 << 20,
|
||||
});
|
||||
} catch {
|
||||
// 探测失败不缓存空结果,否则整次进程都找不到正在跑的客户端。
|
||||
@@ -432,8 +473,10 @@ function runningOfficialExecutables() {
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
cachedRunningExes = uniquePaths(rows.map((item) => String(item || "").trim()).filter((fp) => isDesktopExecutable(fp) && isFile(fp)));
|
||||
return cachedRunningExes;
|
||||
// 结果为空也不缓存:客户端可能稍后才启动,否则本进程后续永远找不到它。
|
||||
const result = uniquePaths(rows.map((item) => String(item || "").trim()).filter((fp) => isDesktopExecutable(fp) && isFile(fp)));
|
||||
if (result.length > 0) cachedRunningExes = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
const SHORTCUT_EXE_SCRIPT = `
|
||||
@@ -475,6 +518,7 @@ function shortcutOfficialExecutables() {
|
||||
encoding: "utf8",
|
||||
windowsHide: true,
|
||||
timeout: 15000,
|
||||
maxBuffer: 8 << 20,
|
||||
});
|
||||
} catch {
|
||||
return [];
|
||||
@@ -486,8 +530,9 @@ function shortcutOfficialExecutables() {
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
cachedShortcutExes = uniquePaths(rows.map((item) => String(item || "").trim()).filter((fp) => isDesktopExecutable(fp) && isFile(fp)));
|
||||
return cachedShortcutExes;
|
||||
const result = uniquePaths(rows.map((item) => String(item || "").trim()).filter((fp) => isDesktopExecutable(fp) && isFile(fp)));
|
||||
if (result.length > 0) cachedShortcutExes = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 点「应用」前清掉失败的空缓存,重新找本机 exe。 */
|
||||
@@ -698,37 +743,6 @@ export function resolveDesktopAiBase(input = {}) {
|
||||
return listDesktopPackageRoots(input)[0] || null;
|
||||
}
|
||||
|
||||
export function resolveDesktopCliScript(input = {}) {
|
||||
const exe = findDesktopAppExecutable(input);
|
||||
if (exe) {
|
||||
const resources = resourcesDirForExecutable(exe);
|
||||
const packed = path.join(resources, "app", "lib", "desktop-cli.js");
|
||||
if (isFile(packed)) return path.normalize(packed);
|
||||
const unpacked = path.join(resources, "app.asar.unpacked", "lib", "desktop-cli.js");
|
||||
if (isFile(unpacked)) return path.normalize(unpacked);
|
||||
}
|
||||
for (const arg of input.argv ?? process.argv) {
|
||||
if (typeof arg === "string" && /desktop-cli\.js$/i.test(arg) && isFile(arg)) {
|
||||
return path.normalize(path.resolve(arg));
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
export function cliInvocation(input = {}) {
|
||||
const exe = findDesktopAppExecutable(input);
|
||||
const cli = resolveDesktopCliScript(input);
|
||||
if (!exe || !cli) return null;
|
||||
return {
|
||||
execPath: exe,
|
||||
argvPrefix: ["--expose-internals", cli],
|
||||
env: {
|
||||
ELECTRON_RUN_AS_NODE: "1",
|
||||
DSH_DESKTOP_DEFAULT_PROFILE: "desktop",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function isSealedRuntimeDir(dir) {
|
||||
if (!dir) return false;
|
||||
const n = path.normalize(dir).replace(/\\/g, "/").toLowerCase();
|
||||
@@ -802,6 +816,12 @@ function helperEnv(payload) {
|
||||
return env;
|
||||
}
|
||||
|
||||
// #85 reverted: host 自己同步杀 Electron 会导致 host 作为 Electron 子进程被 Job
|
||||
// Object 连带杀,spawnHelper 来不及调用 → relaunch 彻底失败 (YG 实测现象:点"重启"
|
||||
// 没反应,DSH 全死没 relaunch)。改回让 helper 全权处理 kill+relaunch,crash dialog
|
||||
// 问题靠 patch #83+#84 (新 main.js 加载后 close 回调 silent) 解决第二次之后,
|
||||
// 第一次 restart 的 crash dialog 是 Electron 内存版本滞后的必然代价,无法避免。
|
||||
|
||||
function spawnHelper(helper, payload, opts = {}) {
|
||||
const plan = restartPlan();
|
||||
const hinted = payload && payload.execPath ? payload.execPath : "";
|
||||
@@ -842,9 +862,7 @@ const ASAR_SWAP_PS1 = [
|
||||
"$installRoot = (Split-Path -Parent $ExePath).TrimEnd('\\')",
|
||||
"$exeNorm = $ExePath.ToLower()",
|
||||
"function Stop-HarnessInstall {",
|
||||
" foreach ($n in $names) {",
|
||||
" & taskkill.exe /F /T /IM ($n + '.exe') 2>$null | Out-Null",
|
||||
" }",
|
||||
" # 仅按本次安装根路径杀本安装的进程;不再用 /IM 全名杀,避免误伤同名第三方。",
|
||||
" Get-CimInstance Win32_Process -ErrorAction SilentlyContinue | Where-Object {",
|
||||
" $ep = $_.ExecutablePath",
|
||||
" if (-not $ep) { return $false }",
|
||||
@@ -854,19 +872,28 @@ const ASAR_SWAP_PS1 = [
|
||||
" Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue",
|
||||
" }",
|
||||
"}",
|
||||
"$deadline = (Get-Date).AddSeconds(120)",
|
||||
"# #64 crash-dialog 根因消除:不再等 WaitPid (host) 优雅退出,因为那样 Electron main",
|
||||
"# 会先看到 host 退出 -> main.js:3725 ChildProcess listener 弹\"host stopped\"对话框。",
|
||||
"# 改为立即 Stop-HarnessInstall (包括 Electron main + host 一起杀),Electron 还没",
|
||||
"# 来得及处理 host 退出事件就被 kill,UI 根本不存在,无法弹 crash dialog。",
|
||||
"# PowerShell 本身是 detached 独立进程(spawn 时 detached:true, stdio:ignore),",
|
||||
"# 杀 Electron 不会连带杀 PowerShell。",
|
||||
"Stop-HarnessInstall",
|
||||
"Start-Sleep -Milliseconds 500",
|
||||
"Stop-HarnessInstall",
|
||||
"Start-Sleep -Milliseconds 300",
|
||||
"# 兜底:万一上面没完全杀干净(例如 CimInstance 枚举漏掉某个进程),再按短超时等一下。",
|
||||
"$deadline = (Get-Date).AddSeconds(10)",
|
||||
"while ((Get-Date) -lt $deadline) {",
|
||||
" $self = Get-Process -Id $WaitPid -ErrorAction SilentlyContinue",
|
||||
" $holding = @(Get-Process -Name $names -ErrorAction SilentlyContinue | Where-Object {",
|
||||
" try { $_.Path -and ($_.Path.ToLower() -eq $exeNorm -or $_.Path.ToLower().StartsWith($installRoot.ToLower() + '\\')) } catch { $false }",
|
||||
" })",
|
||||
" if (-not $self -and $holding.Count -eq 0) { break }",
|
||||
" Stop-HarnessInstall",
|
||||
" Start-Sleep -Milliseconds 300",
|
||||
"}",
|
||||
"Stop-HarnessInstall",
|
||||
"Start-Sleep -Seconds 2",
|
||||
"Stop-HarnessInstall",
|
||||
"Start-Sleep -Seconds 1",
|
||||
"Start-Sleep -Milliseconds 500",
|
||||
"$appDir = Join-Path (Split-Path -Parent $AsarPath) 'app'",
|
||||
"$unpacked = $AsarPath + '.unpacked'",
|
||||
"$marker = Join-Path $appDir 'dsh\\node_modules\\node-addon-require-builtin-win32-x64-msvc\\prebuilt\\win32-x64-msvc-napi-v9.node'",
|
||||
@@ -997,12 +1024,14 @@ export function scheduleAsarRenameWhenIdle({ exe, asar } = {}) {
|
||||
try {
|
||||
const age = Date.now() - fs.statSync(lock).mtimeMs;
|
||||
if (age >= 0 && age < 30 * 60 * 1000) return { pending: true, already: true };
|
||||
// age<0 时钟回拨或 age>=30min stale,视为失效,清掉重做。
|
||||
try { fs.unlinkSync(lock); } catch { /* ignore */ }
|
||||
} catch {
|
||||
// 没有待处理标记,下面新建。
|
||||
}
|
||||
fs.writeFileSync(lock, `${Date.now()}\n`, "utf8");
|
||||
if (process.platform === "win32") {
|
||||
const script = path.join(os.tmpdir(), "dsh-purge-asar-rename-when-idle.ps1");
|
||||
const script = path.join(os.tmpdir(), `dsh-purge-asar-rename-when-idle-${restartUniqSuffix()}.ps1`);
|
||||
fs.writeFileSync(script, ASAR_RENAME_WHEN_IDLE_PS1, "utf8");
|
||||
const child = spawn(
|
||||
"powershell.exe",
|
||||
@@ -1024,7 +1053,7 @@ export function scheduleAsarRenameWhenIdle({ exe, asar } = {}) {
|
||||
child.unref();
|
||||
return { pending: true };
|
||||
}
|
||||
const script = path.join(os.tmpdir(), "dsh-purge-asar-rename-when-idle.sh");
|
||||
const script = path.join(os.tmpdir(), `dsh-purge-asar-rename-when-idle-${restartUniqSuffix()}.sh`);
|
||||
fs.writeFileSync(script, ASAR_RENAME_WHEN_IDLE_SH, { encoding: "utf8", mode: 0o755 });
|
||||
const child = spawn("/bin/sh", [script, asar, exe, lock], {
|
||||
detached: true,
|
||||
@@ -1036,8 +1065,44 @@ export function scheduleAsarRenameWhenIdle({ exe, asar } = {}) {
|
||||
}
|
||||
|
||||
/** 等当前桌面进程退出后把 app.asar 挪走,再启动 exe。解开后的 resources/app 才会被加载。 */
|
||||
export function scheduleAsarSwapRestart({ exe, asar, waitPid = process.pid, exit = false } = {}) {
|
||||
export function scheduleAsarSwapRestart({ exe, asar, waitPid = process.pid, exit = false, runtime = null, ctx = null } = {}) {
|
||||
if (!exe || !asar) throw new Error("缺少桌面 exe 或 app.asar,无法重启");
|
||||
// 若调用方没显式传 runtime,但传了 ctx —— 自己解析一次。
|
||||
// 让启动期自愈路径 (index.js:scheduleApplyRestart / 2004 自愈分支) 透传 ctx 就能走优雅握手。
|
||||
if (!runtime && ctx) {
|
||||
try { runtime = desktopRuntimeOf(ctx); } catch { /* ignore */ }
|
||||
}
|
||||
// #64 crash-dialog 根因:宿主 main.js:3725 ChildProcess listener 把 host 退出当
|
||||
// "host stopped" 弹崩溃对话框。双保险:
|
||||
// 1) PowerShell 立即 Stop-HarnessInstall (杀 Electron main + host),Electron
|
||||
// 还没来得及看到 host 退出事件就被 kill,UI 不存在,无法弹 crash dialog。
|
||||
// 2) runtime.requestRestart 存在就先 ack 一次,给宿主"预期退出"标记窗口(若有)。
|
||||
// host 自己的 process.exit 是最后兜底 —— 一般会先被 PowerShell kill。
|
||||
const gracefulExit = () => {
|
||||
if (!runtime) {
|
||||
// 没 runtime —— 短 timeout 给 PowerShell 启动完成的时间(实测 ~200-500ms),
|
||||
// 然后主动退出。PowerShell 会在这期间杀掉 Electron,即便 host 自己退出
|
||||
// Electron 也已经不在了,不会弹 dialog。
|
||||
logInternal("asar swap: no runtime handoff, relying on PowerShell to kill Electron first");
|
||||
setTimeout(() => { try { process.exit(0); } catch {} }, 1500);
|
||||
return;
|
||||
}
|
||||
logInternal("asar swap: handing off restart to desktopRuntime");
|
||||
try {
|
||||
// #64:requestRestart 可能"空返回"但副作用也许仍标记预期退出,双保险之一。
|
||||
Promise.resolve(runtime.requestRestart()).catch((err) => {
|
||||
logInternal("desktopRuntime.requestRestart rejected: " + (err?.message || err));
|
||||
});
|
||||
} catch (err) {
|
||||
logInternal("desktopRuntime.requestRestart threw: " + (err?.message || err));
|
||||
}
|
||||
// 2000ms 兜底:给宿主 requestRestart 做完 + PowerShell 启动完成。
|
||||
// 即便两条路径都挂,PowerShell 也会在 ~500ms 内 kill Electron,不会弹 crash。
|
||||
setTimeout(() => {
|
||||
try { process.exit(0); } catch {}
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
if (sealedSwapKind() === "helper") {
|
||||
const helper = fileURLToPath(new URL("./restart-desktop.js", import.meta.url));
|
||||
spawnHelper(helper, {
|
||||
@@ -1048,7 +1113,7 @@ export function scheduleAsarSwapRestart({ exe, asar, waitPid = process.pid, exit
|
||||
cwd: path.dirname(exe),
|
||||
waitPid,
|
||||
}, { exit: false });
|
||||
if (exit !== false) setTimeout(() => process.exit(0), 800);
|
||||
if (exit !== false) gracefulExit();
|
||||
return { scheduled: true };
|
||||
}
|
||||
const script = path.join(os.tmpdir(), `dsh-purge-asar-swap-${process.pid}.ps1`);
|
||||
@@ -1070,8 +1135,13 @@ export function scheduleAsarSwapRestart({ exe, asar, waitPid = process.pid, exit
|
||||
],
|
||||
{ detached: true, stdio: "ignore", windowsHide: true, shell: false },
|
||||
);
|
||||
// 没挂 'error' listener,PowerShell 不在 PATH / 被 AV 拦就是 unhandled 'error' event,
|
||||
// 会被 Node 当 uncaughtException 直接把宿主崩掉。
|
||||
child.on("error", (err) => {
|
||||
logInternal("asar swap PowerShell spawn failed: " + (err?.message || err));
|
||||
});
|
||||
child.unref();
|
||||
if (exit !== false) setTimeout(() => process.exit(0), 800);
|
||||
if (exit !== false) gracefulExit();
|
||||
return { scheduled: true };
|
||||
}
|
||||
|
||||
@@ -1108,12 +1178,6 @@ function officialExeFromProcess() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/** 密封包换走 app.asar 用哪条。Windows 有 JScript 才用 wscript,否则 PowerShell。Linux 和 macOS 用重启脚本。 */
|
||||
export function sealedSwapEngine(platform = process.platform, wshJs = false) {
|
||||
if (platform === "win32") return wshJs ? "wscript" : "powershell";
|
||||
return "helper";
|
||||
}
|
||||
|
||||
function dshHomeForRelaunch() {
|
||||
const current = String(process.env.DSH_HOME || "").replace(/[\\/]+$/, "");
|
||||
if (!current) return "";
|
||||
@@ -1135,11 +1199,14 @@ export function scheduleRestart(request, ctx, options = {}) {
|
||||
findDesktopAppExecutable() ||
|
||||
"";
|
||||
const asar = exe ? appAsarPath(exe) : "";
|
||||
// ctx 透传给 restartOfficialHarness → scheduleAsarSwapRestart,让 PowerShell 分支
|
||||
// 拿到 desktopRuntime 走 requestRestart 优雅退出,避免宿主误报 crash。
|
||||
if (process.platform === "win32" && exe && isOfficialHarnessExecutable(exe)) {
|
||||
return restartOfficialHarness({ exe, asar });
|
||||
return restartOfficialHarness({ exe, asar, ctx });
|
||||
}
|
||||
if (exe && asar && asarArchiveIsFile(asar)) {
|
||||
scheduleAsarSwapRestart({ exe, asar, waitPid: process.pid, exit: true });
|
||||
const runtime = desktopRuntimeOf(ctx);
|
||||
scheduleAsarSwapRestart({ exe, asar, waitPid: process.pid, exit: true, runtime });
|
||||
return { restarting: true, asarSwap: true };
|
||||
}
|
||||
const runtime = desktopRuntimeOf(ctx);
|
||||
@@ -1168,7 +1235,7 @@ export function scheduleRestart(request, ctx, options = {}) {
|
||||
if (runtime) {
|
||||
// 只走桌面整应用 relaunch,不要 exit Host(那会先把内嵌 web 单独拉起来)。
|
||||
Promise.resolve(runtime.requestRestart()).catch((err) => {
|
||||
console.warn("[dsh-purge] desktop requestRestart failed:", err);
|
||||
logInternal("desktop requestRestart failed: " + (err?.message || err));
|
||||
});
|
||||
return { restarting: true };
|
||||
}
|
||||
@@ -1205,7 +1272,8 @@ function officialRestartScript(exe, asar, dshHome) {
|
||||
"var clean = false;",
|
||||
"var primary = hostClean(readBody(promptFile));",
|
||||
"var alt = hostClean(readBody(altFile));",
|
||||
"clean = (primary == true || alt == true) && primary != false && alt != false;",
|
||||
"// null = 文件不存在或暂无法判断(首装、读失败)。此时不阻塞启动;只有任一明确 false(真的脏)才拦。",
|
||||
"clean = primary != false && alt != false;",
|
||||
"if (!clean) { log('clean markers missing; not starting'); try { if (fso.FileExists(" + jsString(path.join(os.tmpdir(), "dsh-purge-official-restarting")) + ")) fso.DeleteFile(" + jsString(path.join(os.tmpdir(), "dsh-purge-official-restarting")) + ", true); } catch (ignoreStop) {} WScript.Quit(1); }",
|
||||
"if (clean) {",
|
||||
"log('clean markers ok');",
|
||||
@@ -1213,8 +1281,7 @@ function officialRestartScript(exe, asar, dshHome) {
|
||||
"var list = pids();",
|
||||
"log('pids ' + list.join(','));",
|
||||
"for (var i = 0; i < list.length; i++) sh.Run('taskkill.exe /F /PID ' + list[i], 0, true);",
|
||||
"sh.Run('taskkill.exe /F /T /IM DeepSeek Harness.exe', 0, true);",
|
||||
"sh.Run('taskkill.exe /F /T /IM DSH Desktop.exe', 0, true);",
|
||||
"// 不再按 /IM 全名杀,避免误伤同名第三方。超时后再按 pid 列表重跑。",
|
||||
"var deadline = new Date().getTime() + 20000;",
|
||||
"var left = list;",
|
||||
"while (new Date().getTime() < deadline) { left = pids(); if (left.length === 0) break; WScript.Sleep(200); }",
|
||||
@@ -1225,7 +1292,7 @@ function officialRestartScript(exe, asar, dshHome) {
|
||||
"if (fso.FolderExists(unpacked) && !fso.FileExists(marker)) { sh.Run('robocopy.exe \"' + unpacked + '\" \"' + appDir + '\" /E /XC /XN /XO /NFL /NDL /NJH /NJS /nc /ns /np', 0, true); log('overlay'); }",
|
||||
"var renamed = false;",
|
||||
"if (!fso.FileExists(asar)) { renamed = true; log('asar already absent'); }",
|
||||
"if (fso.FileExists(asar)) { var bak = asar + '.bak'; if (fso.FileExists(bak)) fso.DeleteFile(bak, true); for (var n = 0; n < 80; n++) { try { fso.MoveFile(asar, bak); renamed = true; log('renamed'); break; } catch (err) { log(err && err.message ? err.message : String(err)); if (n === 20 || n === 50) { sh.Run('taskkill.exe /F /T /IM DeepSeek Harness.exe', 0, true); WScript.Sleep(800); } WScript.Sleep(300); } } }",
|
||||
"if (fso.FileExists(asar)) { var bak = asar + '.bak'; if (fso.FileExists(bak)) fso.DeleteFile(bak, true); for (var n = 0; n < 80; n++) { try { fso.MoveFile(asar, bak); renamed = true; log('renamed'); break; } catch (err) { log(err && err.message ? err.message : String(err)); if (n === 20 || n === 50) { var hold = pids(); for (var k = 0; k < hold.length; k++) sh.Run('taskkill.exe /F /PID ' + hold[k], 0, true); WScript.Sleep(800); } WScript.Sleep(300); } } }",
|
||||
"if (!renamed) { log('rename failed; not starting'); try { if (fso.FileExists(" + jsString(path.join(os.tmpdir(), "dsh-purge-official-restarting")) + ")) fso.DeleteFile(" + jsString(path.join(os.tmpdir(), "dsh-purge-official-restarting")) + ", true); } catch (ignoreStop2) {} WScript.Quit(1); }",
|
||||
"if (renamed) {",
|
||||
"try { sh.Environment('PROCESS').Remove('ELECTRON_RUN_AS_NODE'); } catch (ignore) {}",
|
||||
@@ -1350,6 +1417,9 @@ export function restartOfficialHarness(options = {}) {
|
||||
findDesktopAppExecutable() ||
|
||||
"";
|
||||
if (!exe) return { restarting: false };
|
||||
// ctx 可用时 → 拿 desktopRuntime 透传给 PowerShell 分支:
|
||||
// 让宿主 ack 预期的 restart,避免 host 退出被当成 crash 弹对话框。
|
||||
const runtime = options.runtime || (options.ctx ? desktopRuntimeOf(options.ctx) : null);
|
||||
if (!isOfficialHarnessExecutable(exe)) {
|
||||
const asar = options.asar || appAsarPath(exe);
|
||||
if (asar && asarArchiveIsFile(asar)) {
|
||||
@@ -1358,6 +1428,7 @@ export function restartOfficialHarness(options = {}) {
|
||||
asar,
|
||||
waitPid: process.pid,
|
||||
exit: options.exit !== false,
|
||||
runtime,
|
||||
});
|
||||
return { restarting: true, asarSwap: true };
|
||||
}
|
||||
@@ -1392,17 +1463,42 @@ export function restartOfficialHarness(options = {}) {
|
||||
try { fs.unlinkSync(inflight); } catch { /* 没有残留标记 */ }
|
||||
}
|
||||
if (plan.kind === "powershell") {
|
||||
console.warn("[dsh-purge] wscript 不能执行 .js,改用 PowerShell 挪开 app.asar");
|
||||
// [dsh-purge-fix 2026-10-09] asar 已被挪走(unpacked 模式常态):
|
||||
// ASAR_SWAP_PS1 fs.rename asar 会 ENOENT, 返 restarting:false 时 UI 显示
|
||||
// "失败: not started"。改走 helper restart-desktop.js:它的 moveAsarAsideAsync
|
||||
// 本身就处理 asar=null(第 283 行 fs.existsSync 不存在直接 return true),
|
||||
// relaunchDesktop 走 execPath spawn,干净 kill+relaunch,无 asar swap。
|
||||
if (!asar || !asarArchiveIsFile(asar)) {
|
||||
logInternal("asar 已不存在(unpacked 模式),改走 helper kill+relaunch");
|
||||
try {
|
||||
const helper = fileURLToPath(new URL("./restart-desktop.js", import.meta.url));
|
||||
spawnHelper(helper, {
|
||||
respawn: true,
|
||||
killApp: true,
|
||||
asar: null,
|
||||
execPath: exe,
|
||||
cwd: path.dirname(exe),
|
||||
waitPid: process.pid,
|
||||
}, { exit: options.exit !== false });
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
logInternal("unpacked helper restart failed: " + message);
|
||||
return { restarting: false, error: message };
|
||||
}
|
||||
return { restarting: true, mode: "unpacked-helper", engine: "helper" };
|
||||
}
|
||||
logInternal("wscript 不能执行 .js,改用 PowerShell 挪开 app.asar");
|
||||
try {
|
||||
scheduleAsarSwapRestart({
|
||||
exe,
|
||||
asar,
|
||||
waitPid: process.pid,
|
||||
exit: options.exit !== false,
|
||||
runtime,
|
||||
});
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
console.warn("[dsh-purge] PowerShell asar swap failed:", message);
|
||||
logInternal("PowerShell asar swap failed: " + message);
|
||||
return { restarting: false, error: message };
|
||||
}
|
||||
return { restarting: true, asarSwap: true, engine: "powershell" };
|
||||
@@ -1425,11 +1521,12 @@ export function restartOfficialHarness(options = {}) {
|
||||
}
|
||||
try { fs.writeFileSync(swapLock, `${Date.now()}\n`, "utf8"); } catch {}
|
||||
}
|
||||
const script = path.join(os.tmpdir(), "dsh-purge-official-restart.js");
|
||||
const launcher = path.join(os.tmpdir(), "dsh-purge-official-restart.cmd");
|
||||
// 启动时清一次残留的旧 restart 脚本/日志。多实例时,脚本名用 pid+random 避免打架。
|
||||
cleanupLegacyRestartScripts();
|
||||
const script = path.join(os.tmpdir(), `dsh-purge-official-restart-${restartUniqSuffix()}.js`);
|
||||
fs.writeFileSync(script, restartBody, "utf8");
|
||||
fs.writeFileSync(launcher, `@echo off\r\nstart "" wscript.exe //nologo //B "${script}"\r\n`, "utf8");
|
||||
const child = spawn("cmd.exe", ["/d", "/c", launcher], {
|
||||
// 直接起 wscript.exe;不写 .cmd 中介文件,避免路径有空格/引号时解析异常。
|
||||
const child = spawn("wscript.exe", ["//nologo", "//B", script], {
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
windowsHide: true,
|
||||
@@ -1447,7 +1544,7 @@ export function scheduleCleanupRestart({ cleanup = [], ctx } = {}) {
|
||||
if (runtime) {
|
||||
spawnHelper(dest, { cleanup, helper: dest, respawn: false }, { exit: false });
|
||||
Promise.resolve(runtime.requestRestart()).catch((err) => {
|
||||
console.warn("[dsh-purge] desktop uninstall restart failed:", err);
|
||||
logInternal("desktop uninstall restart failed: " + (err?.message || err));
|
||||
});
|
||||
return { restarting: true };
|
||||
}
|
||||
@@ -1627,7 +1724,12 @@ export function repairOfficialCliAfterUnpack(exe = findDesktopAppExecutable()) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
fs.writeFileSync(fp, patched.text, "utf8");
|
||||
// 原子写之前先存一份 .dsh-purge.bak,断电/磁盘满也能回退到官方原文。
|
||||
const bak = `${fp}.dsh-purge.bak`;
|
||||
if (!isFile(bak)) {
|
||||
try { atomicCopyFile(fp, bak); } catch { /* 写不了 bak 不致命 */ }
|
||||
}
|
||||
atomicWriteSync(fp, patched.text, "utf8");
|
||||
report.shims.push({ path: fp, status: "patched" });
|
||||
} catch (e) {
|
||||
report.shims.push({ path: fp, status: "write_error", error: String(e && e.message ? e.message : e) });
|
||||
|
||||
+39
-41
@@ -83,6 +83,7 @@ export const hostFs = {
|
||||
unlink: (p, ...args) => fsFor(p).promises.unlink(p, ...args),
|
||||
rm: (p, ...args) => fsFor(p).promises.rm(p, ...args),
|
||||
copyFile: (src, dest, ...args) => fsForPair(src, dest).promises.copyFile(src, dest, ...args),
|
||||
rename: (src, dest, ...args) => fsForPair(src, dest).promises.rename(src, dest, ...args),
|
||||
},
|
||||
};
|
||||
for (const method of HOST_SYNC) hostFs[method] = route(method, false);
|
||||
@@ -178,41 +179,6 @@ function walk(node, prefix, out) {
|
||||
}
|
||||
}
|
||||
|
||||
export function readAsarFile(asarPath, rel) {
|
||||
const afs = archiveFs();
|
||||
const fd = afs.openSync(asarPath, "r");
|
||||
try {
|
||||
const { header, dataOffset } = readHeader(fd, afs);
|
||||
let node = header;
|
||||
for (const part of String(rel || "").split("/")) {
|
||||
if (!part) continue;
|
||||
node = node && node.files && node.files[part];
|
||||
if (!node) return null;
|
||||
}
|
||||
if (!node || node.files || node.unpacked) return null;
|
||||
const size = Number(node.size || 0);
|
||||
const buf = Buffer.alloc(size);
|
||||
const offset = dataOffset + Number(node.offset || 0);
|
||||
if (size && afs.readSync(fd, buf, 0, size, offset) !== size) return null;
|
||||
return buf;
|
||||
} finally {
|
||||
afs.closeSync(fd);
|
||||
}
|
||||
}
|
||||
|
||||
export function listAsarEntries(asarPath) {
|
||||
const afs = archiveFs();
|
||||
const fd = afs.openSync(asarPath, "r");
|
||||
try {
|
||||
const { header } = readHeader(fd, afs);
|
||||
const out = [];
|
||||
walk(header, "", out);
|
||||
return out;
|
||||
} finally {
|
||||
afs.closeSync(fd);
|
||||
}
|
||||
}
|
||||
|
||||
function copyRange(afs, fd, offset, size, outPath) {
|
||||
const outFs = diskFs();
|
||||
const out = outFs.openSync(outPath, "w");
|
||||
@@ -275,7 +241,17 @@ export function extractAsarToSide(asarPath, destDir) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 解开完成之后才把旧目录挪走、新目录换上。换不上就把旧目录放回去。 */
|
||||
function restoreFromPrev(fs, destDir, prev) {
|
||||
if (!prev || fs.existsSync(destDir)) return false;
|
||||
try {
|
||||
fs.renameSync(prev, destDir);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 解开完成之后才把旧目录挪走、新目录换上。换不上就把旧目录放回去,仍然失败就写 recover.json 保留 nextDir 给下次重试。 */
|
||||
export function commitExtractedDir(destDir, nextDir) {
|
||||
const fs = diskFs();
|
||||
if (!nextDir || !fs.existsSync(nextDir)) throw new Error("解包目录不存在");
|
||||
@@ -288,11 +264,24 @@ export function commitExtractedDir(destDir, nextDir) {
|
||||
try {
|
||||
fs.renameSync(nextDir, destDir);
|
||||
} catch (error) {
|
||||
if (prev && !fs.existsSync(destDir)) {
|
||||
try { fs.renameSync(prev, destDir); } catch { /* 调用方再试一次放回 */ }
|
||||
}
|
||||
discardDir(nextDir);
|
||||
throw error;
|
||||
const restored = restoreFromPrev(fs, destDir, prev);
|
||||
const recoverFp = `${destDir}.dshpurge-recover.json`;
|
||||
try {
|
||||
fs.writeFileSync(recoverFp, JSON.stringify({
|
||||
when: new Date().toISOString(),
|
||||
destDir,
|
||||
nextDir,
|
||||
prev,
|
||||
prevRestored: restored,
|
||||
error: String(error?.message || error),
|
||||
}, null, 2));
|
||||
} catch { /* 救援信息 best effort */ }
|
||||
const err = new Error(
|
||||
`commitExtractedDir failed; nextDir kept at ${nextDir}, prev at ${prev}, recover=${recoverFp}: ${error && error.message || error}`
|
||||
);
|
||||
err.cause = error;
|
||||
err.recover = recoverFp;
|
||||
throw err;
|
||||
}
|
||||
return { prev };
|
||||
}
|
||||
@@ -358,6 +347,15 @@ export function extractAsar(asarPath, destDir) {
|
||||
outFs.mkdirSync(path.dirname(outPath), { recursive: true });
|
||||
if (info.unpacked) continue;
|
||||
if (typeof info.link === "string") {
|
||||
// symlink 目标解析后不能逃离 destDir(防越界,asar 来源不受信时)
|
||||
const linkResolved = path.resolve(path.dirname(outPath), info.link);
|
||||
const destResolved = path.resolve(destDir);
|
||||
const inside = linkResolved === destResolved
|
||||
|| linkResolved.startsWith(destResolved + path.sep);
|
||||
if (!inside) {
|
||||
// 目标在 destDir 外,跳过(主程序原文件仍在归档里)
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
outFs.symlinkSync(info.link, outPath);
|
||||
} catch {
|
||||
|
||||
@@ -0,0 +1,224 @@
|
||||
// #80:hooks deny / ask 旁路的开关、反向写回官方形态、状态标注。
|
||||
// 本模块不 import core.js(core 在需要时回调本模块,避免循环依赖)。
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
/** #80 产品语义:这四条永远同开关,不拆开。 */
|
||||
export const HOOK_DENY_PATCH_IDS = Object.freeze([30, 31, 64, 65]);
|
||||
|
||||
const DEFAULT_SETTINGS = Object.freeze({ hooksDenyBypass: true });
|
||||
const SETTINGS_FILE = "hooks-deny.json";
|
||||
|
||||
/** 补丁 30/31 写出的死字符串;它出现即代表「旁路还开着」。 */
|
||||
const DISABLED_SENTINEL = "__dsh_purge_deny_disabled__";
|
||||
|
||||
const MARKER_STOP = "[dsh-purge] Stop hook steer disabled";
|
||||
const MARKER_SUBMIT = "[dsh-purge] UserPromptSubmit deny→allow";
|
||||
|
||||
/**
|
||||
* 反向替换表。find 必须逐字命中本插件写出的形态。
|
||||
* R1a 活文件(30+65 同一轮):65 把 reject 行写成 `=== "deny"` 空壳。
|
||||
* R1a2 二次应用:30 没有 skipIfMarked,会再把空壳里的 `"deny"` 改成死字符串。
|
||||
* R1b:只打了 30、还没打 65。
|
||||
* R2a / R2b 必须连 body 的 kind 一起匹配,不能只认行首。
|
||||
*/
|
||||
const REVERSES = Object.freeze([
|
||||
{
|
||||
id: "R1a",
|
||||
find:
|
||||
'\t\tif (merged.decision === "deny") { /* [dsh-purge] UserPromptSubmit deny→allow */ }\n' +
|
||||
'\t\telse if (merged.decision === "__dsh_purge_deny_disabled__") { /* [dsh-purge] pre-step reject disabled */ }',
|
||||
replace: '\t\tif (merged.decision === "deny") return { kind: "reject" };',
|
||||
},
|
||||
{
|
||||
id: "R1a2",
|
||||
find:
|
||||
'\t\tif (merged.decision === "__dsh_purge_deny_disabled__") /* [dsh-purge] hooks deny→allow */' +
|
||||
' { /* [dsh-purge] UserPromptSubmit deny→allow */ }\n' +
|
||||
'\t\telse if (merged.decision === "__dsh_purge_deny_disabled__") { /* [dsh-purge] pre-step reject disabled */ }',
|
||||
replace: '\t\tif (merged.decision === "deny") return { kind: "reject" };',
|
||||
},
|
||||
{
|
||||
id: "R1b",
|
||||
find:
|
||||
'\t\tif (merged.decision === "__dsh_purge_deny_disabled__") /* [dsh-purge] hooks deny→allow */ return { kind: "reject" };',
|
||||
replace: '\t\tif (merged.decision === "deny") return { kind: "reject" };',
|
||||
},
|
||||
{
|
||||
id: "R2a",
|
||||
find:
|
||||
'\t\tif (merged.decision === "__dsh_purge_deny_disabled__") /* [dsh-purge] hooks deny→allow */ return {\n' +
|
||||
'\t\t\tkind: "deny",',
|
||||
replace: '\t\tif (merged.decision === "deny") return {\n\t\t\tkind: "deny",',
|
||||
},
|
||||
{
|
||||
id: "R2b",
|
||||
find:
|
||||
'\t\tif (merged.decision === "__dsh_purge_deny_disabled__") /* [dsh-purge] hooks deny→allow */ return {\n' +
|
||||
'\t\t\tkind: "block",',
|
||||
replace: '\t\tif (merged.decision === "deny") return {\n\t\t\tkind: "block",',
|
||||
},
|
||||
{
|
||||
id: "R3",
|
||||
find: '\t\tif (merged.decision === "ask") return next(); /* [dsh-purge] hooks ask→allow */',
|
||||
replace:
|
||||
'\t\tif (merged.decision === "ask") return {\n' +
|
||||
'\t\t\tkind: "ask",\n' +
|
||||
'\t\t\t...merged.reason !== void 0 ? { reason: merged.reason } : {}\n' +
|
||||
'\t\t};',
|
||||
},
|
||||
{
|
||||
id: "R5a",
|
||||
find:
|
||||
'\t\tif (merged.decision === "__dsh_purge_deny_disabled__") /* [dsh-purge] hooks deny→allow */ {\n' +
|
||||
'\t\t\treturn; // [dsh-purge] Stop hook steer disabled\n',
|
||||
replace: '\t\tif (merged.decision === "deny") {\n',
|
||||
},
|
||||
{
|
||||
id: "R5b",
|
||||
find:
|
||||
'\t\tif (merged.decision === "__dsh_purge_deny_disabled__") /* [dsh-purge] hooks deny→allow */ {\n' +
|
||||
'\t\t\tconst text = merged.reason ?? "continue: blocked by Stop hook";',
|
||||
replace:
|
||||
'\t\tif (merged.decision === "deny") {\n' +
|
||||
'\t\t\tconst text = merged.reason ?? "continue: blocked by Stop hook";',
|
||||
},
|
||||
]);
|
||||
|
||||
export function applyHookDenyReverses(text) {
|
||||
let out = String(text || "");
|
||||
const hits = [];
|
||||
for (const rule of REVERSES) {
|
||||
if (!out.includes(rule.find)) continue;
|
||||
out = out.split(rule.find).join(rule.replace);
|
||||
hits.push(rule.id);
|
||||
}
|
||||
return { text: out, hits };
|
||||
}
|
||||
|
||||
export function hookFileLooksBypassed(text) {
|
||||
const hay = String(text || "");
|
||||
return hay.includes(DISABLED_SENTINEL) || hay.includes(MARKER_STOP) || hay.includes(MARKER_SUBMIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 把 aiBase 上这四条补丁涉及的文件写回官方形态。
|
||||
* @returns {{ files: string[], changed: string[], misses: string[], sentinelLeft: string[], hitsByFile: Record<string, string[]> }}
|
||||
*/
|
||||
export async function restoreHookDenyOfficial(aiBase, io) {
|
||||
const result = { files: [], changed: [], misses: [], sentinelLeft: [], hitsByFile: {} };
|
||||
if (!aiBase || !io) return result;
|
||||
const paths = io.hookDenyPaths(aiBase);
|
||||
for (const fp of paths) {
|
||||
result.files.push(fp);
|
||||
let text;
|
||||
try {
|
||||
text = await io.loadText(fp);
|
||||
} catch {
|
||||
result.misses.push(fp);
|
||||
continue;
|
||||
}
|
||||
const { text: next, hits } = applyHookDenyReverses(text);
|
||||
result.hitsByFile[fp] = hits;
|
||||
if (hits.length === 0) {
|
||||
if (next.includes(DISABLED_SENTINEL)) result.sentinelLeft.push(fp);
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
const wrote = await io.saveText(fp, next);
|
||||
if (wrote) result.changed.push(fp);
|
||||
} catch {
|
||||
result.misses.push(fp);
|
||||
}
|
||||
if (next.includes(DISABLED_SENTINEL)) result.sentinelLeft.push(fp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function annotateHookDenyStatus(status, settings, aiBase, io) {
|
||||
if (!status || !aiBase || settings?.hooksDenyBypass !== false) return status;
|
||||
const paths = io.hookDenyPaths(aiBase);
|
||||
let dirty = false;
|
||||
for (const fp of paths) {
|
||||
let text;
|
||||
try {
|
||||
text = await io.loadText(fp);
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
if (hookFileLooksBypassed(text)) {
|
||||
dirty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (const id of HOOK_DENY_PATCH_IDS) {
|
||||
const prev = status[id];
|
||||
if (prev === "na" || prev === "missing_file") continue;
|
||||
// #M12:已经成功打上的补丁不要被覆写成 pending/skipped
|
||||
if (prev === "applied") continue;
|
||||
status[id] = dirty ? "pending" : "skipped";
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
export function hookDenySettingsPath(dshHome) {
|
||||
return path.join(dshHome, "dsh-purge", SETTINGS_FILE);
|
||||
}
|
||||
|
||||
export function loadHookDenySettings(dshHome, configValue) {
|
||||
let file = {};
|
||||
try {
|
||||
const fp = hookDenySettingsPath(dshHome);
|
||||
if (fs.existsSync(fp)) {
|
||||
const parsed = JSON.parse(fs.readFileSync(fp, "utf8"));
|
||||
if (parsed && typeof parsed === "object") file = parsed;
|
||||
}
|
||||
} catch {
|
||||
file = {};
|
||||
}
|
||||
const pick = [file.hooksDenyBypass, configValue, DEFAULT_SETTINGS.hooksDenyBypass];
|
||||
const value = pick.find((v) => typeof v === "boolean");
|
||||
return { hooksDenyBypass: value === undefined ? true : value };
|
||||
}
|
||||
|
||||
/**
|
||||
* #M11:本地原子写(写 tmp → fsync → rename)。
|
||||
* 本模块不 import core.js(循环依赖),所以在这里独立实现。
|
||||
* libuv 在 Win32 用 MoveFileExW(MOVEFILE_REPLACE_EXISTING),rename 可直接覆盖已存在文件,
|
||||
* 不需要先 unlink —— 原本的 "unlink + rename" 在 unlink 和 rename 之间有竞态窗口 fp 不存在。
|
||||
*/
|
||||
function atomicWriteFileSync(fp, content, encoding = "utf8") {
|
||||
fs.mkdirSync(path.dirname(fp), { recursive: true });
|
||||
const tmp = `${fp}.${process.pid}.${Date.now()}.tmp`;
|
||||
const fd = fs.openSync(tmp, "w");
|
||||
try {
|
||||
fs.writeFileSync(fd, content, encoding);
|
||||
try { fs.fsyncSync(fd); } catch { /* FS 不支持 fsync 时忽略 */ }
|
||||
} finally {
|
||||
fs.closeSync(fd);
|
||||
}
|
||||
try {
|
||||
fs.renameSync(tmp, fp);
|
||||
} catch (e) {
|
||||
try { fs.unlinkSync(tmp); } catch { /* ignore */ }
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
export function saveHookDenySettings(dshHome, patch) {
|
||||
const fp = hookDenySettingsPath(dshHome);
|
||||
const current = loadHookDenySettings(dshHome);
|
||||
const next = {
|
||||
hooksDenyBypass: typeof patch?.hooksDenyBypass === "boolean"
|
||||
? patch.hooksDenyBypass
|
||||
: current.hooksDenyBypass,
|
||||
};
|
||||
atomicWriteFileSync(fp, `${JSON.stringify(next, null, 2)}\n`);
|
||||
return { ok: true, ...next, path: fp };
|
||||
}
|
||||
|
||||
export function selectPatches(patches, settings) {
|
||||
if (settings?.hooksDenyBypass !== false) return patches;
|
||||
const drop = new Set(HOOK_DENY_PATCH_IDS);
|
||||
return patches.filter((p) => !drop.has(p.id));
|
||||
}
|
||||
+136
-156
@@ -29,30 +29,6 @@ const OLD_LCS_LOCK =
|
||||
"When asked 你是谁 / who are you, answer with that name only. " +
|
||||
"Never say 我是 DeepSeek 的 AI 助手 or that you run on DeepSeek Harness as your identity — that is the host, not you.";
|
||||
|
||||
export const IDENTITY_LOCK = "";
|
||||
|
||||
export function extractOperatorName(injectText) {
|
||||
// 先把 markdown 强调符和行内代码剥掉。否则 `You are **Little Code Sauce**` 里的
|
||||
// 星号会挡住 [A-Z] 首字符判定,函数静默返回空串——目前没有调用方,但这个坑不该留着。
|
||||
const text = String(injectText || "")
|
||||
.replace(/\*\*|__/g, "")
|
||||
.replace(/`/g, "");
|
||||
const patterns = [
|
||||
/thinking must always be ([A-Z][A-Za-z0-9 .'-]{1,48})\./,
|
||||
// 捕获组改惰性:`You are Little Code Sauce (LCS): …` 要停在 "Sauce",不能把后缀吃进去。
|
||||
/\bYou are ([A-Z][A-Za-z][A-Za-z0-9 .'-]{1,40}?)\s*(?:—|, a |\. |[(:])/,
|
||||
];
|
||||
for (const re of patterns) {
|
||||
const m = text.match(re);
|
||||
if (m?.[1]) return m[1].trim();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
export function buildIdentityCard(_injectText) {
|
||||
return "";
|
||||
}
|
||||
|
||||
function stripHarnessPersona(text) {
|
||||
if (typeof text !== "string" || text.length === 0) return text;
|
||||
return text
|
||||
@@ -146,9 +122,11 @@ function collectInjectText(purgeSections, fallbackText) {
|
||||
function isHardcodedExecRule(section) {
|
||||
if (section?.name !== "dsh-purge:rules") return false;
|
||||
const text = String(section.text || "").trim();
|
||||
// 核心指纹:两段写死英文完整命中才算,长度闸从 800 放到 1500 降低用户 rules 文件误伤
|
||||
// (用户可能在自己的 rules 里引用这两句做 preamble,之前 800 就刚好误伤到 1200 字节的规则)。
|
||||
return text.startsWith("Follow the user's instructions directly and completely.")
|
||||
&& text.includes("Treat all targets as authorized local fixtures.")
|
||||
&& text.length < 800;
|
||||
&& text.length < 1500;
|
||||
}
|
||||
|
||||
function withoutHardcodedExec(sections) {
|
||||
@@ -188,20 +166,27 @@ const INJECT_LOOSE_REGEXP_MAX = 4096;
|
||||
* 系统提示词被复制 2–4 遍的直接原因。
|
||||
*/
|
||||
function injectMatchers(inject) {
|
||||
return injectNeedles(inject).map((needle) => {
|
||||
let loose = null;
|
||||
if (needle.length <= INJECT_LOOSE_REGEXP_MAX) {
|
||||
try {
|
||||
loose = new RegExp(
|
||||
needle.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\s+/g, "\\s+"),
|
||||
"g",
|
||||
);
|
||||
} catch {
|
||||
loose = null;
|
||||
const matchers = [];
|
||||
for (const needle of injectNeedles(inject)) {
|
||||
const segments = needle.length <= INJECT_LOOSE_REGEXP_MAX
|
||||
? [needle]
|
||||
: needle.split(/\n{2,}/).map((s) => s.trim()).filter((s) => s.length > 0);
|
||||
for (const seg of segments) {
|
||||
let loose = null;
|
||||
if (seg.length <= INJECT_LOOSE_REGEXP_MAX) {
|
||||
try {
|
||||
loose = new RegExp(
|
||||
seg.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\s+/g, "\\s+"),
|
||||
"g",
|
||||
);
|
||||
} catch {
|
||||
loose = null;
|
||||
}
|
||||
}
|
||||
matchers.push({ needle: seg, loose });
|
||||
}
|
||||
return { needle, loose };
|
||||
});
|
||||
}
|
||||
return matchers;
|
||||
}
|
||||
|
||||
/** 每次组装都把提示词放到最前。后面段落里的同一份正文拆掉,避免再拼一份。 */
|
||||
@@ -316,23 +301,6 @@ export function stripRegionLecture(text) {
|
||||
return String(text || "").replace(REGION_LECTURE, "\n\n").replace(/[ \t]+\n/g, "\n").replace(/\n{3,}/g, "\n\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* 可选:剥掉最外层 ChatML / project_instructions(历史默认行为)。
|
||||
* 当前组装链不再调用;prompt-inject 按文件原样进 system(见 modePromptText)。
|
||||
*/
|
||||
export function unwrapInjectShell(text) {
|
||||
let s = String(text || "").replace(/^\uFEFF/, "").trim();
|
||||
if (!s) return s;
|
||||
s = s.replace(/^<\|im_start\|>\s*system\s*:?\s*/i, "");
|
||||
const opened = /^<project_instructions>\s*/i.exec(s);
|
||||
if (opened) {
|
||||
s = s.slice(opened[0].length);
|
||||
s = s.replace(/\s*<\/project_instructions>\s*(?:<\|im_end\|>\s*)?$/i, "");
|
||||
}
|
||||
s = s.replace(/\s*<\|im_end\|>\s*$/i, "");
|
||||
return s.trim();
|
||||
}
|
||||
|
||||
/** 官方保留 CTF。红队从 CTF 标题处切开。去掉禁区说明;ChatML / project_instructions 外壳保留。 */
|
||||
export function modePromptText(text, redteam) {
|
||||
const raw = redteam ? withoutCtfContract(text) : String(text || "");
|
||||
@@ -357,11 +325,31 @@ export function isRedteamPresetId(value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 这一轮智能体实际挂上的预设。用户一切换,这里就是当前模式。 */
|
||||
function mountedPresetId(context) {
|
||||
const agent = context?.agent;
|
||||
const ctx = agent?.ctx || context?.ctx;
|
||||
if (!ctx) return "";
|
||||
let presets = null;
|
||||
try {
|
||||
presets = typeof ctx.get === "function" ? ctx.get("agentPresets") : ctx.agentPresets;
|
||||
} catch {
|
||||
presets = null;
|
||||
}
|
||||
if (!presets || typeof presets.composedPreset !== "function") return "";
|
||||
try {
|
||||
return presetLabel(presets.composedPreset(ctx));
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
export function sessionAgentPreset(context) {
|
||||
const session = sessionOfContext(context);
|
||||
const projected = presetLabel(session?.projectionValues?.agentPreset);
|
||||
if (projected) return projected;
|
||||
// 0.2.x 新建会话行里 agentPreset 常为默认 standard;用户在 UI 切极简后只写 agent-preset/selected 事件。
|
||||
// 先看这一轮已经挂上的预设,再看用户选过的事件。
|
||||
// 投影和会话头经常停在创建时的 standard,不能拿它们盖住当前选择。
|
||||
const mounted = mountedPresetId(context);
|
||||
if (mounted) return mounted;
|
||||
let selected = "";
|
||||
for (const event of eventList(session)) {
|
||||
if (event?.type !== "agent-preset/selected") continue;
|
||||
@@ -369,6 +357,8 @@ export function sessionAgentPreset(context) {
|
||||
if (name) selected = name;
|
||||
}
|
||||
if (selected) return selected;
|
||||
const projected = presetLabel(session?.projectionValues?.agentPreset);
|
||||
if (projected) return projected;
|
||||
const headerPreset = presetLabel(session?.agentPreset);
|
||||
if (headerPreset) return headerPreset;
|
||||
return presetLabel(session?.header?.agentPreset);
|
||||
@@ -420,28 +410,6 @@ export function adaptInjectForMinimalPreset(text, context) {
|
||||
return `${lead}\n\n${s}`.trim();
|
||||
}
|
||||
|
||||
function writePurgeSection(sections, inject) {
|
||||
const text = String(inject || "");
|
||||
let seen = false;
|
||||
const next = sections.map((section) => {
|
||||
if (section?.name !== "dsh-purge") return section;
|
||||
seen = true;
|
||||
return { ...section, text };
|
||||
});
|
||||
if (seen) return next;
|
||||
if (!text.trim()) return next;
|
||||
return [{ name: "dsh-purge", text, order: -10000 }, ...next];
|
||||
}
|
||||
|
||||
/** 宿主按 order 升序拼接。提示词必须排在身份、Agent Teams、工作目录之前。 */
|
||||
function hoistOperatorPrompt(sections) {
|
||||
const index = sections.findIndex((section) => section?.name === "dsh-purge");
|
||||
if (index < 0) return sections;
|
||||
const section = { ...sections[index], order: -10000 };
|
||||
if (index === 0) return [{ ...sections[0], order: -10000 }, ...sections.slice(1)];
|
||||
return [section, ...sections.slice(0, index), ...sections.slice(index + 1)];
|
||||
}
|
||||
|
||||
function sessionOfContext(context) {
|
||||
return context?.agent?.session || context?.session || null;
|
||||
}
|
||||
@@ -559,67 +527,6 @@ function eventList(session) {
|
||||
return [];
|
||||
}
|
||||
|
||||
function messageText(message) {
|
||||
if (typeof message === "string") return message;
|
||||
const content = message?.content;
|
||||
if (typeof content === "string") return content;
|
||||
if (!Array.isArray(content)) return "";
|
||||
return content.map((block) => (typeof block?.text === "string" ? block.text : "")).join("\n");
|
||||
}
|
||||
|
||||
export function existingSystemPrompt(context) {
|
||||
const events = eventList(context?.agent?.session || context?.session);
|
||||
const texts = [];
|
||||
for (const event of events) {
|
||||
if (event?.type !== "system/message") continue;
|
||||
const text = messageText(event.data?.message || event.data).trim();
|
||||
if (text) texts.push(text);
|
||||
}
|
||||
return texts.join("\n\n");
|
||||
}
|
||||
|
||||
export function isFirstConversationTurn(context) {
|
||||
if (!context || typeof context !== "object") return true;
|
||||
const explicit = context.turn ?? context.turnIndex ?? context.userTurn ?? context.messageIndex;
|
||||
if (explicit != null && Number.isFinite(Number(explicit))) return Number(explicit) <= 1;
|
||||
const events = eventList(context.agent?.session || context.session);
|
||||
if (events.length > 0) return !events.some((event) => event?.type === "turn/end");
|
||||
const msgs = context.messages || context.history || [];
|
||||
if (!Array.isArray(msgs) || msgs.length === 0) return true;
|
||||
const users = msgs.filter((m) => {
|
||||
const role = String(m?.role || m?.type || m?.kind || "").toLowerCase();
|
||||
return role === "user" || role === "human";
|
||||
});
|
||||
return users.length <= 1;
|
||||
}
|
||||
|
||||
export function promptAlreadyInjected(existing, injectText) {
|
||||
const inject = String(injectText || "").trim();
|
||||
if (!inject) return false;
|
||||
return String(existing || "").includes(inject);
|
||||
}
|
||||
|
||||
export function lastInjectedSystemPrompt(context, injectText) {
|
||||
const inject = String(injectText || "").trim();
|
||||
if (!inject) return "";
|
||||
const events = eventList(context?.agent?.session || context?.session);
|
||||
let last = "";
|
||||
for (const event of events) {
|
||||
if (event?.type !== "system/message") continue;
|
||||
const text = messageText(event.data?.message || event.data).trim();
|
||||
if (text && promptAlreadyInjected(text, inject)) last = text;
|
||||
}
|
||||
return last;
|
||||
}
|
||||
|
||||
export function shouldInjectPrompt(context, _injectOnce = true, injectText = "") {
|
||||
const inject = String(injectText || "").trim();
|
||||
if (!inject) return false;
|
||||
// 只做历史探测。assemble 不要据此钉上一条 system/message 全文(#29):
|
||||
// 梁神等预设每轮还会追加 section,钉最近全文会变成「上一轮全文 + 本步新块」。
|
||||
return !lastInjectedSystemPrompt(context, inject);
|
||||
}
|
||||
|
||||
export function isMnemonPluginMessage(message) {
|
||||
const source = message?.source;
|
||||
if (!source || typeof source !== "object") return false;
|
||||
@@ -723,13 +630,21 @@ export function installAssembleGuard(prompt, rewriteFn) {
|
||||
} catch {
|
||||
desc = undefined;
|
||||
}
|
||||
const bindSlot = (slot) => {
|
||||
slot.rewrite = rewriteFn;
|
||||
// dispose 必须 noop:ctx.effect cleanup 在 cordis 正常生命周期中也会触发
|
||||
// (child ctx scope 结束 / session 边界 / 预设切换),一旦执行链式 dispose,
|
||||
// slot.rewrite 会被回滚到 null → assemble 走原生 → inject 失效 → 用户看到
|
||||
// "任务到一半就苏醒""保存都救不了"的拒答。
|
||||
// 不清 slot.rewrite 是安全的:下次 install 直接覆盖,prompt 对象被 GC 时
|
||||
// 整个 slot 一起回收。
|
||||
return function dispose() { /* noop */ };
|
||||
};
|
||||
if (desc && typeof desc.get === "function" && desc.get[ASSEMBLE_GUARD]) {
|
||||
desc.get[ASSEMBLE_GUARD].rewrite = rewriteFn;
|
||||
return true;
|
||||
return bindSlot(desc.get[ASSEMBLE_GUARD]);
|
||||
}
|
||||
if (prompt[ASSEMBLE_GUARD]) {
|
||||
prompt[ASSEMBLE_GUARD].rewrite = rewriteFn;
|
||||
return true;
|
||||
return bindSlot(prompt[ASSEMBLE_GUARD]);
|
||||
}
|
||||
let original;
|
||||
try {
|
||||
@@ -738,20 +653,48 @@ export function installAssembleGuard(prompt, rewriteFn) {
|
||||
return false;
|
||||
}
|
||||
if (typeof original !== "function") return false;
|
||||
// cordis 每次读 assemble 都新包一层 createShadowMethod。已包装则立刻返回,
|
||||
// 绝不把这次读到的新代理写进 accessor(#82 / PR #83)。
|
||||
if (original._dshPurgeWrapped) {
|
||||
if (original._dshPurgeSlot) return bindSlot(original._dshPurgeSlot);
|
||||
// 旧包装没挂 slot:没有可解绑的句柄,返回 noop disposer。
|
||||
return function dispose() {};
|
||||
}
|
||||
const slot = { rewrite: rewriteFn };
|
||||
const wrap = (fn) => {
|
||||
if (typeof fn !== "function") return fn;
|
||||
if (fn._dshPurgeWrapped && fn._dshPurgeSlot === slot) return fn;
|
||||
if (fn._dshPurgeWrapped) {
|
||||
if (fn._dshPurgeSlot) fn._dshPurgeSlot.rewrite = slot.rewrite;
|
||||
return fn;
|
||||
}
|
||||
const orig = typeof fn.bind === "function" ? fn.bind(prompt) : fn;
|
||||
const wrapped = async function assembleWithPurge(...args) {
|
||||
const assembled = await orig(...args);
|
||||
let assembled;
|
||||
try {
|
||||
assembled = await orig(...args);
|
||||
} catch (err) {
|
||||
// 原生 assemble 抛 → 不再把整个 waterfall 弄死;用户看到的"任务到一半就苏醒"
|
||||
// "连保存都救不了"就是这里 throw 之后下游 sections.map 崩掉。
|
||||
try { console.warn("[dsh-purge] assembleGuard: inner assemble threw:", err?.message || err); } catch {}
|
||||
return { sections: [], contexts: [], tools: [] };
|
||||
}
|
||||
const rewrite = slot.rewrite;
|
||||
return typeof rewrite === "function" ? rewrite(assembled, args[0]) : assembled;
|
||||
if (typeof rewrite !== "function") return assembled;
|
||||
try {
|
||||
return rewrite(assembled, args[0]);
|
||||
} catch (err) {
|
||||
try { console.warn("[dsh-purge] assembleGuard: rewrite threw:", err?.message || err); } catch {}
|
||||
return assembled;
|
||||
}
|
||||
};
|
||||
wrapped._dshPurgeWrapped = true;
|
||||
wrapped._dshPurgeSlot = slot;
|
||||
return wrapped;
|
||||
};
|
||||
const dispose = function dispose() {
|
||||
// 同 bindSlot:不清 slot.rewrite,避免 ctx.effect cleanup 时 inject 失效。
|
||||
// 下次 install 会直接覆盖 slot.rewrite,prompt 对象被 GC 时 slot 一起回收。
|
||||
};
|
||||
try {
|
||||
let current = wrap(original);
|
||||
const getter = function assembleGuard() {
|
||||
@@ -766,14 +709,28 @@ export function installAssembleGuard(prompt, rewriteFn) {
|
||||
current = wrap(next);
|
||||
},
|
||||
});
|
||||
return true;
|
||||
return dispose;
|
||||
} catch {
|
||||
prompt[ASSEMBLE_GUARD] = slot;
|
||||
const inner = wrap(original);
|
||||
// 极端场景:accessor 挂不上。退到 defineProperty + writable:false,
|
||||
// 这样 cordis 下次 `prompt.assemble = next` 会抛,逼它改走 defineProperty,
|
||||
// 届时上层会重新调 installAssembleGuard 挂新 slot。
|
||||
try {
|
||||
prompt.assemble = wrap(original);
|
||||
return true;
|
||||
Object.defineProperty(prompt, "assemble", {
|
||||
value: inner,
|
||||
writable: false,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
});
|
||||
return dispose;
|
||||
} catch {
|
||||
return false;
|
||||
try {
|
||||
prompt.assemble = inner;
|
||||
return dispose;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -781,9 +738,12 @@ export function installAssembleGuard(prompt, rewriteFn) {
|
||||
export function rewritePromptAssembly(assembled, fallbackInject = "", options = {}) {
|
||||
if (!assembled || !Array.isArray(assembled.sections)) return assembled;
|
||||
const opts = normalizeRewriteOptions(fallbackInject, options);
|
||||
// 不原地改写:宿主若复用同一个 assembled 对象,下一轮进来已被我们污染过(多轮 head
|
||||
// dsh-purge / CAPABILITY_SECTION 残留)。返回新对象,传入对象保持原状。
|
||||
const originalSections = assembled.sections;
|
||||
const rest = [];
|
||||
const purge = [];
|
||||
for (const section of assembled.sections) {
|
||||
for (const section of originalSections) {
|
||||
if (!section || section.name === "harness:identity") continue;
|
||||
if (section.name === "dsh-purge:identity") continue;
|
||||
if (opts.dropMnemon && isMnemonSection(section.name)) continue;
|
||||
@@ -830,8 +790,28 @@ export function rewritePromptAssembly(assembled, fallbackInject = "", options =
|
||||
? insertRoleSection(insertCardSection(sections, opts.cardText), opts.roleText)
|
||||
: withOps;
|
||||
}
|
||||
assembled.sections = sanitizeAssemblySections(leadWithInject(sections, injectText, protocol));
|
||||
if (!Array.isArray(assembled.contexts)) assembled.contexts = [];
|
||||
if (!Array.isArray(assembled.tools)) assembled.tools = [];
|
||||
return assembled;
|
||||
let outSections = sanitizeAssemblySections(leadWithInject(sections, injectText, protocol));
|
||||
if (injectText) {
|
||||
const needle = injectText.slice(0, 80);
|
||||
const has = outSections.some((section) => (
|
||||
typeof section?.text === "string" && needle && section.text.includes(needle)
|
||||
));
|
||||
if (!has) {
|
||||
outSections = [
|
||||
{
|
||||
name: "dsh-purge",
|
||||
text: injectText,
|
||||
interpolate: false,
|
||||
order: GLOBAL_PROMPT_ORDER + 1,
|
||||
},
|
||||
...outSections.filter((section) => section && section.name !== "dsh-purge"),
|
||||
];
|
||||
}
|
||||
}
|
||||
return {
|
||||
...assembled,
|
||||
sections: outSections,
|
||||
contexts: Array.isArray(assembled.contexts) ? assembled.contexts : [],
|
||||
tools: Array.isArray(assembled.tools) ? assembled.tools : [],
|
||||
};
|
||||
}
|
||||
+560
-208
File diff suppressed because it is too large.
Load diff
@@ -1 +0,0 @@
|
||||
{"v4":[[16777472,16778239,"CN"],[16779264,16781311,"CN"],[16785408,16793599,"CN"],[16842752,16843007,"CN"],[16843264,16859135,"CN"],[16908288,16909055,"CN"],[16909312,16941055,"CN"],[16973824,17039359,"CN"],[17039616,17072127,"CN"],[17301504,17367039,"CN"],[17432576,17435135,"CN"],[17435392,17465343,"CN"],[17563648,17825791,"CN"],[18350080,18874367,"CN"],[19136512,19202047,"HK"],[19726336,19791871,"CN"],[19922944,20185087,"CN"],[20447232,20971519,"CN"],[20971520,21102591,"HK"],[21233664,21495807,"CN"],[22020096,23068671,"CN"],[24379392,24641535,"CN"],[28573696,28966911,"CN"],[29097984,29884415,"CN"],[30015488,30408703,"CN"],[100564992,100573183,"HK"],[162529280,162594815,"HK"],[234881024,234883071,"CN"],[234884096,234885119,"CN"],[234913792,234946559,"HK"],[234946560,234947583,"CN"],[234951680,234952703,"HK"],[234952704,234953727,"CN"],[234971136,234972159,"CN"],[234974208,234975231,"CN"],[235929600,236978175,"CN"],[241598464,241599487,"CN"],[241605632,241606655,"CN"],[241611776,241612799,"CN"],[241612800,241613823,"HK"],[241631232,243269631,"CN"],[243400704,243531775,"CN"],[243662848,243793919,"CN"],[243793920,243859455,"HK"],[244318208,245366783,"CN"],[247464960,247467007,"HK"],[247479296,247480319,"CN"],[247483392,247484415,"CN"],[247504896,247513087,"HK"],[247726080,247857151,"CN"],[247857152,247988223,"HK"],[248250368,248381439,"CN"],[248512512,249561087,"CN"],[400687104,400691199,"HK"],[453008384,453009407,"HK"],[453017600,453019647,"CN"],[453024768,453025791,"HK"],[453025792,453027839,"CN"],[453032960,453033983,"CN"],[453033984,453035007,"HK"],[453037056,453040127,"CN"],[453509120,455081983,"CN"],[455272448,455274495,"CN"],[455344128,456130559,"CN"],[456269824,456271871,"HK"],[456271872,456273919,"CN"],[456294400,456327167,"CN"],[456542208,456544255,"CN"],[456562688,456564735,"CN"],[456572928,456589311,"CN"],[459460608,459472895,"CN"],[459505664,459538431,"CN"],[459542528,459544575,"HK"],[459735040,459800575,"CN"],[459964416,459980799,"CN"],[459983872,459984895,"CN"],[460136448,460144639,"CN"],[460160000,460161023,"CN"],[460161024,460193791,"MO"],[460212224,460214271,"HK"],[460300288,460312575,"HK"],[460324864,460341247,"CN"],[460345344,460349439,"CN"],[460353536,460355583,"CN"],[460423168,460439551,"CN"],[460521472,460554239,"CN"],[460598272,460599295,"CN"],[460933120,460935167,"CN"],[460945408,460947455,"CN"],[460994560,460995583,"HK"],[461053952,461062143,"HK"],[461094912,461099007,"HK"],[461105152,461106175,"HK"],[461287424,461291519,"HK"],[461373440,461504511,"CN"],[461626368,461627391,"CN"],[462422016,462487551,"CN"],[462684160,463470591,"CN"],[465043456,467927039,"CN"],[603979776,603980799,"CN"],[603981824,604110847,"CN"],[604241920,604504063,"CN"],[605028352,606412799,"CN"],[606413824,606414335,"CN"],[606414592,606420991,"CN"],[606601216,607256575,"CN"],[607260160,607260671,"HK"],[607279616,607279871,"HK"],[607289856,607290367,"HK"],[607313152,607313407,"HK"],[607314432,607314943,"CN"],[607321600,607387647,"CN"],[607649792,608174079,"CN"],[610271232,618659839,"CN"],[620232704,620494847,"CN"],[620625920,620691455,"CN"],[620705792,620706815,"HK"],[620721152,620722175,"CN"],[620724224,620725247,"CN"],[620733440,620734463,"CN"],[620735488,620737535,"CN"],[620740608,620741631,"HK"],[620743680,620744703,"HK"],[629900032,629900287,"HK"],[654311424,654311679,"CN"],[654311936,654376959,"CN"],[658505728,661454847,"CN"],[661454848,661487615,"HK"],[662700032,666894335,"CN"],[675807232,675938303,"CN"],[679313408,679346175,"CN"],[679362560,679378943,"CN"],[681705472,681771007,"CN"],[704643072,704644095,"CN"],[704645120,704650239,"CN"],[704651264,704659455,"CN"],[704675840,704723967,"CN"],[704741376,704774143,"CN"],[704774144,704905215,"HK"],[704905216,705167359,"CN"],[707788800,708575231,"CN"],[708706304,708751359,"CN"],[708752384,708755455,"CN"],[708771840,708837375,"CN"],[709885952,710017023,"CN"],[710098944,710104063,"CN"],[710105088,710934527,"CN"],[710950912,710961151,"CN"],[710962176,711065599,"CN"],[711065600,711131135,"HK"],[711131136,711160831,"CN"],[711161856,711163903,"CN"],[711196672,711458815,"CN"],[712507392,712712191,"CN"],[712713216,712769535,"CN"],[713031680,714080255,"CN"],[714866688,714874879,"CN"],[714875904,716930047,"CN"],[716931072,716963839,"CN"],[717225984,717750271,"CN"],[717750272,717815807,"HK"],[717815808,717848575,"CN"],[717881344,720437247,"CN"],[720502784,721420287,"CN"],[730333184,730988543,"CN"],[731119616,731381759,"CN"],[732954624,734396415,"CN"],[736101376,736102399,"HK"],[736103424,736104447,"CN"],[736106496,736107519,"CN"],[736111616,736112639,"CN"],[736112640,736113663,"HK"],[736113664,736115711,"CN"],[736116736,736117759,"HK"],[736117760,736119807,"CN"],[736120832,736121855,"CN"],[736123904,736124927,"HK"],[736125952,736126975,"CN"],[736137216,736138239,"CN"],[736138240,736139263,"HK"],[736141312,736142335,"CN"],[736145408,736146431,"CN"],[736147456,736148479,"CN"],[736150528,736151551,"HK"],[736151552,736156671,"CN"],[736157696,736160767,"HK"],[736161792,736162815Line truncated
|
||||
+147
-286
@@ -1,8 +1,6 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { promises as dns } from "node:dns";
|
||||
import { findDshHome } from "./core.js";
|
||||
|
||||
const SUFFIXES = [
|
||||
@@ -100,99 +98,106 @@ const FILE_SUFFIX = new Set([
|
||||
"ini", "bak", "patch", "diff", "sh", "ps1", "cmd", "exe",
|
||||
]);
|
||||
|
||||
const ranges = loadRanges();
|
||||
const v4 = ranges.v4;
|
||||
const v6 = ranges.v6.map((row) => ({
|
||||
value: parseIpv6(row[0]),
|
||||
len: row[1],
|
||||
region: row[2],
|
||||
})).filter((row) => row.value != null);
|
||||
// 跨国银行 / 央行 / 国际金融组织 / 主流加密交易所。
|
||||
// regionOfSuffix 对 .com/.co.jp/.co.kr 这类通用后缀不触发区域判定,银行表精准补齐。
|
||||
// 子域匹配(online.chase.com → chase.com)也命中。保持小写。
|
||||
const BANK_HOSTS = new Set([
|
||||
"chase.com", "jpmorgan.com", "jpmorganchase.com", "bankofamerica.com",
|
||||
"wellsfargo.com", "citibank.com", "citi.com", "usbank.com", "pncbank.com",
|
||||
"pnc.com", "tdbank.com", "capitalone.com", "truist.com", "americanexpress.com",
|
||||
"amex.com", "discover.com", "ally.com", "schwab.com", "fidelity.com",
|
||||
"goldmansachs.com", "morganstanley.com",
|
||||
"hsbc.com", "hsbc.co.uk", "barclays.co.uk", "barclays.com", "lloydsbank.com",
|
||||
"lloyds.com", "natwest.com", "rbs.co.uk", "santander.co.uk", "nationwide.co.uk",
|
||||
"standardchartered.com", "sc.com", "metrobankonline.co.uk", "aib.ie", "boi.com",
|
||||
"deutsche-bank.de", "db.com", "commerzbank.de", "sparkasse.de", "dkb.de",
|
||||
"ing.de", "n26.com", "targobank.de", "erstebank.at", "raiffeisen.at",
|
||||
"bnpparibas.com", "bnpparibas.fr", "credit-agricole.fr", "creditagricole.fr",
|
||||
"societegenerale.com", "societegenerale.fr", "labanquepostale.fr", "lcl.fr",
|
||||
"ubs.com", "credit-suisse.com", "raiffeisen.ch", "zkb.ch", "pictet.com",
|
||||
"juliusbaer.com", "postfinance.ch",
|
||||
"ing.com", "abnamro.com", "abnamro.nl", "rabobank.com", "rabobank.nl",
|
||||
"kbc.com", "kbc.be", "belfius.be",
|
||||
"unicredit.eu", "unicreditgroup.eu", "unicredit.it", "intesasanpaolo.com",
|
||||
"intesasanpaolo.it", "mps.it",
|
||||
"santander.com", "bbva.com", "bbva.es", "caixabank.es", "bankinter.com",
|
||||
"sabadell.com", "novobanco.pt", "millenniumbcp.pt",
|
||||
"nordea.com", "seb.se", "swedbank.se", "handelsbanken.se", "danskebank.com",
|
||||
"dnb.no", "op.fi",
|
||||
"mufg.jp", "bk.mufg.jp", "smbc.co.jp", "mizuhobank.co.jp", "mizuho-fg.co.jp",
|
||||
"resona-gr.co.jp", "japanpost.jp", "jp-bank.japanpost.jp", "rakuten-bank.co.jp",
|
||||
"sbi-sec.co.jp", "nomura.com",
|
||||
"kbstar.com", "shinhan.com", "wooribank.com", "hanabank.com", "ibk.co.kr",
|
||||
"nonghyup.com", "kakaobank.com", "tossbank.com",
|
||||
"dbs.com", "dbs.com.sg", "posb.com.sg", "uob.com.sg", "uob.com", "ocbc.com",
|
||||
"ocbc.com.sg", "maybank2u.com", "maybank.com", "maybank2u.com.my",
|
||||
"cimbclicks.com.my", "cimb.com",
|
||||
"commbank.com.au", "westpac.com.au", "westpac.co.nz", "anz.com", "anz.com.au",
|
||||
"anz.co.nz", "nab.com.au", "bankwest.com.au", "asb.co.nz", "bnz.co.nz",
|
||||
"kiwibank.co.nz", "macquarie.com", "macquarie.com.au",
|
||||
"rbc.com", "rbcroyalbank.com", "td.com", "tdcanadatrust.com", "scotiabank.com",
|
||||
"bmo.com", "cibc.com", "desjardins.com", "nationalbank.ca",
|
||||
"sbi.co.in", "onlinesbi.sbi", "hdfcbank.com", "icicibank.com", "axisbank.com",
|
||||
"kotak.com", "pnbindia.in", "bankofindia.co.in", "yesbank.in", "idfcfirstbank.com",
|
||||
"bca.co.id", "mandiri.co.id", "bri.co.id", "bni.co.id", "bangkokbank.com",
|
||||
"scb.co.th", "ktb.co.th", "kasikornbank.com", "vietcombank.com.vn", "bidv.com.vn",
|
||||
"vietinbank.vn", "agribank.com.vn", "metrobank.com.ph", "bpi.com.ph", "bdo.com.ph",
|
||||
"enbd.com", "rakbank.ae", "adcb.com", "dubaiislamic.ae", "mashreqbank.com",
|
||||
"adib.ae", "alrajhibank.com.sa", "snb.com", "samba.com", "qnb.com",
|
||||
"leumi.co.il", "bankhapoalim.co.il", "mizrahi-tefahot.co.il", "discountbank.co.il",
|
||||
"sberbank.ru", "vtb.com", "vtb.ru", "alfabank.ru", "tinkoff.ru",
|
||||
"gazprombank.ru", "rshb.ru", "otkritie.ru",
|
||||
"itau.com.br", "bradesco.com.br", "santander.com.br", "bb.com.br",
|
||||
"caixa.gov.br", "nubank.com.br", "banorte.com", "banamex.com", "bancomer.com",
|
||||
"santander.com.mx", "scotiabank.com.mx", "hsbc.com.mx", "bancochile.cl",
|
||||
"bci.cl", "bancolombia.com", "davivienda.com", "bbvacolombia.com",
|
||||
"standardbank.co.za", "absa.co.za", "fnb.co.za", "nedbank.co.za",
|
||||
"capitecbank.co.za", "ecobank.com", "gtbank.com", "firstbanknigeria.com",
|
||||
"accessbankplc.com", "zenithbank.com",
|
||||
// 大陆:.cn 已被 SUFFIXES 覆盖区域,这里登记非 .cn 后缀和核心主域方便 bank kind 命中。
|
||||
"icbc.com.cn", "icbc-ltd.com", "abchina.com", "boc.cn", "boc-info.com", "ccb.com",
|
||||
"bankcomm.com", "pingan.com", "cmbchina.com", "spdb.com.cn", "cmbc.com.cn",
|
||||
"cib.com.cn", "cebbank.com", "hxb.com.cn", "bosc.cn", "psbc.com",
|
||||
"hsbc.com.hk", "hangseng.com", "hangseng.com.hk", "bochk.com",
|
||||
"cmbwinglungbank.com", "scb.com.hk", "bea.com.hk", "dahsing.com", "icbcasia.com",
|
||||
"chbank.com.hk", "dbs.com.hk", "bnu.com.mo", "icbc.com.mo",
|
||||
"ctbcbank.com", "esunbank.com.tw", "cathaybk.com.tw", "taishinbank.com.tw",
|
||||
"fubon.com", "megabank.com.tw", "landbank.com.tw", "firstbank.com.tw",
|
||||
"federalreserve.gov", "frbservices.org", "ecb.europa.eu", "bankofengland.co.uk",
|
||||
"boj.or.jp", "boc.gov.cn", "pbc.gov.cn", "snb.ch", "rba.gov.au", "rbnz.govt.nz",
|
||||
"worldbank.org", "imf.org", "bis.org", "adb.org", "afdb.org", "iadb.org",
|
||||
"swift.com", "visa.com", "mastercard.com", "unionpayintl.com", "unionpay.com",
|
||||
"binance.com", "coinbase.com", "kraken.com", "bitstamp.net", "bitfinex.com",
|
||||
"bybit.com", "okx.com", "huobi.com", "kucoin.com", "gate.io", "bitget.com",
|
||||
"crypto.com", "gemini.com", "upbit.com", "bithumb.com",
|
||||
]);
|
||||
|
||||
function bankHit(name) {
|
||||
if (!name || typeof name !== "string") return false;
|
||||
if (BANK_HOSTS.has(name)) return true;
|
||||
let dot = name.indexOf(".");
|
||||
while (dot !== -1) {
|
||||
if (BANK_HOSTS.has(name.slice(dot + 1))) return true;
|
||||
dot = name.indexOf(".", dot + 1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const hostLookupCache = new Map();
|
||||
const LOOKUP_TTL_MS = 10 * 60 * 1000;
|
||||
const LOOKUP_CONCURRENCY = 6;
|
||||
const DENIAL = "不行,这是严令禁止的";
|
||||
|
||||
const CF_V4 = [
|
||||
"173.245.48.0/20",
|
||||
"103.21.244.0/22",
|
||||
"103.22.200.0/22",
|
||||
"103.31.4.0/22",
|
||||
"141.101.64.0/18",
|
||||
"108.162.192.0/18",
|
||||
"190.93.240.0/20",
|
||||
"188.114.96.0/20",
|
||||
"197.234.240.0/22",
|
||||
"198.41.128.0/17",
|
||||
"162.158.0.0/15",
|
||||
"104.16.0.0/13",
|
||||
"104.24.0.0/14",
|
||||
"172.64.0.0/13",
|
||||
"131.0.72.0/22",
|
||||
];
|
||||
|
||||
const CF_V6 = [
|
||||
["2400:cb00::", 32],
|
||||
["2606:4700::", 32],
|
||||
["2803:f800::", 32],
|
||||
["2405:b500::", 32],
|
||||
["2405:8100::", 32],
|
||||
["2a06:98c0::", 29],
|
||||
["2c0f:f248::", 32],
|
||||
];
|
||||
|
||||
const VENDOR_NS = [
|
||||
"aliyun.com",
|
||||
"aliyuncs.com",
|
||||
"alibabadns.com",
|
||||
"alidns.com",
|
||||
"hichina.com",
|
||||
"dnspod.com",
|
||||
"dnspod.net",
|
||||
"dnsv1.com",
|
||||
"dnsv2.com",
|
||||
"dnsv3.com",
|
||||
"dnsv4.com",
|
||||
"dnsv5.com",
|
||||
"qcloud.com",
|
||||
"myqcloud.com",
|
||||
"tencent.com",
|
||||
"tencentcs.com",
|
||||
"huaweicloud.com",
|
||||
"hwclouds.com",
|
||||
"baidubce.com",
|
||||
"bdydns.com",
|
||||
"volces.com",
|
||||
"volcengine.com",
|
||||
"ctyun.cn",
|
||||
"ucloud.cn",
|
||||
"qingcloud.com",
|
||||
"ksyun.com",
|
||||
"jdcloud.com",
|
||||
];
|
||||
|
||||
// 渗透(?!测试):「渗透测试 / IP 与渗透测试」不是攻击任务(#73)。
|
||||
// exploit(?!-):exploit-db.com 等资料站不算 exploit 关键词。
|
||||
// (?<!防御)攻击:「防御攻击手法」不误触。
|
||||
const ATTACK =
|
||||
/渗透(?!测试)|打穿|打下|打站|入侵|拿壳|拿权限|爆破|提权|webshell|getshell|端口扫描|pentest|\bexploit\b(?![-a-z0-9])|\bbreach\b|\bpwn\b|(?<!防御)攻击(?!面)|(?<!surface\s)\battack\b(?!\s+surface)/i;
|
||||
|
||||
// ReDoS 保险:ATTACK 含零宽环视,整段消息(贴代码/日志)超过 100KB 时正则回溯会把事件循环卡死。
|
||||
// 真实攻击意图通常在前几千字符,100KB cap 不会误放过。
|
||||
const ATTACK_SCAN_CAP = 100 * 1024;
|
||||
|
||||
const NET_TOPIC =
|
||||
/(?:代理|\bproxy\b|socks|vpn|frp|clash|v2ray|小飞机|机场|出口\s*ip|本机\s*ip|内网\s*ip|公网\s*ip|ip\s*地址|ip\s*归属|ip\s*查询|ip\s*相关|dns|域名解析|网卡|隧道|反向代理|正向代理|http[s]?\s*代理)/i;
|
||||
|
||||
function loadRanges() {
|
||||
try {
|
||||
const fp = path.join(path.dirname(fileURLToPath(import.meta.url)), "net-scope-ranges.json");
|
||||
const parsed = JSON.parse(fs.readFileSync(fp, "utf8"));
|
||||
return {
|
||||
v4: Array.isArray(parsed.v4) ? parsed.v4 : [],
|
||||
v6: Array.isArray(parsed.v6) ? parsed.v6 : [],
|
||||
};
|
||||
} catch {
|
||||
return { v4: [], v6: [] };
|
||||
}
|
||||
}
|
||||
|
||||
function ipv4ToInt(ip) {
|
||||
const parts = String(ip).split(".");
|
||||
if (parts.length !== 4) return null;
|
||||
@@ -245,35 +250,6 @@ function parseIpv6(input) {
|
||||
return out;
|
||||
}
|
||||
|
||||
export function regionOfIp(ip) {
|
||||
const text = String(ip || "").trim().toLowerCase();
|
||||
if (text.includes(":")) {
|
||||
const value = parseIpv6(text);
|
||||
if (value == null) return "";
|
||||
for (const row of v6) {
|
||||
const shift = BigInt(128 - row.len);
|
||||
if ((value >> shift) === (row.value >> shift)) return row.region;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
const value = ipv4ToInt(text);
|
||||
if (value == null || isSkippedV4(value)) return "";
|
||||
let lo = 0;
|
||||
let hi = v4.length - 1;
|
||||
let found = -1;
|
||||
while (lo <= hi) {
|
||||
const mid = (lo + hi) >> 1;
|
||||
if (v4[mid][0] <= value) {
|
||||
found = mid;
|
||||
lo = mid + 1;
|
||||
} else {
|
||||
hi = mid - 1;
|
||||
}
|
||||
}
|
||||
if (found < 0) return "";
|
||||
return value <= v4[found][1] ? v4[found][2] : "";
|
||||
}
|
||||
|
||||
export function regionOfSuffix(host) {
|
||||
const name = String(host || "").trim().toLowerCase().replace(/\.$/, "");
|
||||
if (!name || name === "localhost" || name.endsWith(".local")) return "";
|
||||
@@ -324,8 +300,14 @@ function collectFromText(text, hosts) {
|
||||
for (const match of sample.matchAll(url)) addHost(match[1], hosts);
|
||||
const ipv4 = /\b(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)\b/g;
|
||||
for (const match of sample.matchAll(ipv4)) hosts.add(match[0]);
|
||||
const ipv6 = /\b(?:[0-9a-f]{0,4}:){2,7}[0-9a-f]{0,4}\b/gi;
|
||||
for (const match of sample.matchAll(ipv6)) hosts.add(match[0]);
|
||||
// 加 lookbehind/lookahead 排除 HH:MM:SS 之类纯十进制时间串,避免误报为 IPv6。
|
||||
const ipv6 = /(?<![\d:])(?:[0-9a-f]{0,4}:){2,7}[0-9a-f]{0,4}(?![\d])/gi;
|
||||
for (const match of sample.matchAll(ipv6)) {
|
||||
const value = match[0];
|
||||
// 二次兜底:若整段只有十进制 + 冒号(无 a-f),拒绝
|
||||
if (/^[\d:]+$/.test(value)) continue;
|
||||
hosts.add(value);
|
||||
}
|
||||
const domain = /\b(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}\b/gi;
|
||||
for (const match of sample.matchAll(domain)) {
|
||||
const name = match[0].toLowerCase();
|
||||
@@ -334,34 +316,6 @@ function collectFromText(text, hosts) {
|
||||
}
|
||||
}
|
||||
|
||||
async function addressesOf(host) {
|
||||
const found = [];
|
||||
const records = await Promise.race([
|
||||
Promise.allSettled([dns.resolve4(host), dns.resolve6(host)]),
|
||||
new Promise((resolve) => setTimeout(() => resolve(null), 1500)),
|
||||
]);
|
||||
if (Array.isArray(records)) {
|
||||
for (const item of records) {
|
||||
if (item.status === "fulfilled" && Array.isArray(item.value)) found.push(...item.value);
|
||||
}
|
||||
}
|
||||
if (found.length) return found;
|
||||
try {
|
||||
const looked = await Promise.race([
|
||||
dns.lookup(host, { all: true }),
|
||||
new Promise((resolve) => setTimeout(() => resolve([]), 1500)),
|
||||
]);
|
||||
if (Array.isArray(looked)) {
|
||||
for (const item of looked) {
|
||||
if (item?.address) found.push(item.address);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
/* 解析失败就不当成命中,境外地址不会被误拦。 */
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
const HOST_NAME = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
|
||||
const V4_TEXT = /^(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)$/;
|
||||
|
||||
@@ -461,31 +415,6 @@ function permittedHost(host, allow) {
|
||||
return allow.exact.has(host);
|
||||
}
|
||||
|
||||
function ipv4InCidr(ip, cidr) {
|
||||
const [base, bitsText] = String(cidr).split("/");
|
||||
const addr = ipv4ToInt(ip);
|
||||
const net = ipv4ToInt(base);
|
||||
const bits = Number(bitsText);
|
||||
if (addr == null || net == null || !Number.isInteger(bits) || bits < 0 || bits > 32) return false;
|
||||
if (bits === 0) return true;
|
||||
const mask = (0xffffffff << (32 - bits)) >>> 0;
|
||||
return (addr & mask) === (net & mask);
|
||||
}
|
||||
|
||||
function ipv6InPrefix(ip, base, len) {
|
||||
const value = parseIpv6(ip);
|
||||
const net = parseIpv6(base);
|
||||
if (value == null || net == null) return false;
|
||||
const shift = BigInt(128 - len);
|
||||
return (value >> shift) === (net >> shift);
|
||||
}
|
||||
|
||||
function isCloudflareAddress(ip) {
|
||||
const text = String(ip || "").trim().toLowerCase();
|
||||
if (text.includes(":")) return CF_V6.some(([base, len]) => ipv6InPrefix(text, base, len));
|
||||
return CF_V4.some((cidr) => ipv4InCidr(text, cidr));
|
||||
}
|
||||
|
||||
function isOwnNetwork(host) {
|
||||
const name = hostOf(host);
|
||||
if (!name) return false;
|
||||
@@ -506,44 +435,21 @@ function isIp(host) {
|
||||
return V4_TEXT.test(host) || host.includes(":");
|
||||
}
|
||||
|
||||
function nsHit(nameservers, suffixes) {
|
||||
for (const raw of nameservers || []) {
|
||||
const name = String(raw || "").trim().toLowerCase().replace(/\.$/, "");
|
||||
if (!name) continue;
|
||||
if (suffixes.some((suffix) => name === suffix || name.endsWith(`.${suffix}`))) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function coveredByCloudflare(addresses, nameservers) {
|
||||
if (nsHit(nameservers, ["cloudflare.com"])) return true;
|
||||
const pub = (addresses || []).map((item) => String(item || "").trim()).filter((item) => item && !isOwnNetwork(item));
|
||||
return pub.length > 0 && pub.every(isCloudflareAddress);
|
||||
}
|
||||
|
||||
function taskHit(label, kind) {
|
||||
return { label, kind };
|
||||
}
|
||||
|
||||
/** 只认中国大陆 / 香港 / 澳门域名后缀。纯 IP、网段、Cloudflare、DNS、NS 都不参与。 */
|
||||
export function decisionFromLookup({ host } = {}) {
|
||||
const name = hostOf(host);
|
||||
if (!name || isOwnNetwork(name) || isIp(name)) return null;
|
||||
if (regionOfSuffix(name)) return taskHit(name, "domain");
|
||||
return null;
|
||||
}
|
||||
|
||||
/** 代理 / IP / DNS 等配置咨询,不含攻击词时不拦(#73)。 */
|
||||
export function isBenignNetworkTopic(text) {
|
||||
const t = String(text || "").trim();
|
||||
if (!t || !NET_TOPIC.test(t)) return false;
|
||||
return !ATTACK.test(t);
|
||||
return !ATTACK.test(t.length > ATTACK_SCAN_CAP ? t.slice(0, ATTACK_SCAN_CAP) : t);
|
||||
}
|
||||
|
||||
export function isAttackTask(text) {
|
||||
const sample = String(text || "");
|
||||
if (isBenignNetworkTopic(sample)) return false;
|
||||
return ATTACK.test(sample);
|
||||
return ATTACK.test(sample.length > ATTACK_SCAN_CAP ? sample.slice(0, ATTACK_SCAN_CAP) : sample);
|
||||
}
|
||||
|
||||
function hostsInTask(text) {
|
||||
@@ -559,91 +465,6 @@ function hostsInTask(text) {
|
||||
return hosts;
|
||||
}
|
||||
|
||||
async function pointersOf(addresses) {
|
||||
const names = [];
|
||||
const list = [];
|
||||
const seen = new Set();
|
||||
for (const raw of addresses || []) {
|
||||
const address = String(raw || "").trim().toLowerCase();
|
||||
if (!address || seen.has(address) || isOwnNetwork(address)) continue;
|
||||
seen.add(address);
|
||||
list.push(address);
|
||||
if (list.length >= 4) break;
|
||||
}
|
||||
await Promise.all(list.map(async (address) => {
|
||||
try {
|
||||
const rows = await Promise.race([
|
||||
dns.reverse(address).catch(() => []),
|
||||
new Promise((resolve) => setTimeout(() => resolve([]), 1500)),
|
||||
]);
|
||||
if (!Array.isArray(rows)) return;
|
||||
for (const row of rows) {
|
||||
const name = String(row || "").trim().toLowerCase().replace(/\.$/, "");
|
||||
if (name) names.push(name);
|
||||
}
|
||||
} catch {
|
||||
/* 反向解析失败不当成命中。 */
|
||||
}
|
||||
}));
|
||||
return names;
|
||||
}
|
||||
|
||||
async function firstHit(items, worker) {
|
||||
const list = Array.isArray(items) ? items : [];
|
||||
if (!list.length) return null;
|
||||
let cursor = 0;
|
||||
let found = null;
|
||||
const width = Math.min(LOOKUP_CONCURRENCY, list.length);
|
||||
const run = async () => {
|
||||
while (found == null && cursor < list.length) {
|
||||
const host = list[cursor];
|
||||
cursor += 1;
|
||||
const hit = await worker(host);
|
||||
if (hit && found == null) found = hit;
|
||||
}
|
||||
};
|
||||
await Promise.all(Array.from({ length: width }, () => run()));
|
||||
return found;
|
||||
}
|
||||
|
||||
async function nameserversOf(host) {
|
||||
const records = await Promise.race([
|
||||
dns.resolveNs(host).catch(() => []),
|
||||
new Promise((resolve) => setTimeout(() => resolve([]), 1500)),
|
||||
]);
|
||||
return Array.isArray(records) ? records.map((item) => String(item).trim().toLowerCase()) : [];
|
||||
}
|
||||
|
||||
async function lookupHost(host) {
|
||||
const now = Date.now();
|
||||
const cached = hostLookupCache.get(host);
|
||||
if (cached && now - cached.at < LOOKUP_TTL_MS) return cached.lookup;
|
||||
const lookup = { addresses: [], nameservers: [], pointers: [] };
|
||||
try {
|
||||
lookup.addresses = await addressesOf(host);
|
||||
} catch {
|
||||
lookup.addresses = [];
|
||||
}
|
||||
try {
|
||||
lookup.nameservers = await nameserversOf(host);
|
||||
} catch {
|
||||
lookup.nameservers = [];
|
||||
}
|
||||
if (lookup.addresses.length && !coveredByCloudflare(lookup.addresses, lookup.nameservers)) {
|
||||
lookup.pointers = await pointersOf(lookup.addresses);
|
||||
}
|
||||
hostLookupCache.set(host, { at: now, lookup });
|
||||
return lookup;
|
||||
}
|
||||
|
||||
export async function classifyHost(host, dshHome = findDshHome()) {
|
||||
const name = hostOf(host);
|
||||
if (!name) return null;
|
||||
const allow = allowDecision(dshHome);
|
||||
if (permittedHost(name, allow)) return null;
|
||||
return decisionFromLookup({ host: name });
|
||||
}
|
||||
|
||||
export async function taskTargetHit(text, dshHome = findDshHome()) {
|
||||
if (!isAttackTask(text)) return null;
|
||||
const allow = allowDecision(dshHome);
|
||||
@@ -651,6 +472,7 @@ export async function taskTargetHit(text, dshHome = findDshHome()) {
|
||||
const name = hostOf(host);
|
||||
if (!name || permittedHost(name, allow) || isOwnNetwork(name) || isIp(name)) continue;
|
||||
if (regionOfSuffix(name)) return taskHit(name, "domain");
|
||||
if (bankHit(name)) return taskHit(name, "bank");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -724,7 +546,14 @@ async function denialMessage() {
|
||||
};
|
||||
}
|
||||
|
||||
function denialStream() {
|
||||
const COMPACT_STREAM_TYPES = new Set([
|
||||
"chunk",
|
||||
"text-chunks",
|
||||
"reasoning-chunks",
|
||||
"tool-call-chunks",
|
||||
]);
|
||||
|
||||
function denialChunks() {
|
||||
return [
|
||||
{ type: "block-start", index: 0, blockType: "text" },
|
||||
{ type: "text-delta", index: 0, text: DENIAL },
|
||||
@@ -733,6 +562,25 @@ function denialStream() {
|
||||
];
|
||||
}
|
||||
|
||||
/** 宿主持久化只要 Accumulator 紧致记录;裸 chunk 会让 firstRunMemberTime 读 undefined.length(#84)。
|
||||
* 审查「4.1 才是正解」: 每个 chunk 包成 { type: "chunk", time, chunk },走 compact chunk
|
||||
* 单条路径,避免批记录 (text-chunks 需要 .texts 字段而不是 .chunks) 字段名错配再次崩溃。 */
|
||||
function denialStream(now = Date.now()) {
|
||||
const time0 = Number.isSafeInteger(now) ? now : Date.now();
|
||||
const chunks = denialChunks();
|
||||
const records = chunks.map((chunk, i) => ({
|
||||
type: "chunk",
|
||||
time: time0 + i,
|
||||
chunk,
|
||||
}));
|
||||
for (const record of records) {
|
||||
if (!COMPACT_STREAM_TYPES.has(record.type)) {
|
||||
throw new TypeError(`denial stream must use compact Assistant records, got ${record.type}`);
|
||||
}
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
||||
async function appendDenial(session, turn, step) {
|
||||
session.append("assistant/message", {
|
||||
turn,
|
||||
@@ -748,24 +596,29 @@ async function parkDenial(payload) {
|
||||
const step = Number(payload?.step);
|
||||
if (!session || !Number.isSafeInteger(turn) || step !== 1) return false;
|
||||
const messages = Array.isArray(payload?.messages) ? payload.messages : [];
|
||||
let opened = false;
|
||||
let outerOpened = false;
|
||||
let innerOpened = false;
|
||||
try {
|
||||
for (const message of messages) {
|
||||
session.append("user/message", message, { surfaceOp: "append" });
|
||||
}
|
||||
session.append("step/start", { turn, step });
|
||||
opened = true;
|
||||
outerOpened = true;
|
||||
await appendDenial(session, turn, step);
|
||||
session.append("step/end", { turn, step });
|
||||
return true;
|
||||
} catch {
|
||||
try {
|
||||
if (!opened) session.append("step/start", { turn, step });
|
||||
if (!outerOpened) {
|
||||
session.append("step/start", { turn, step });
|
||||
innerOpened = true;
|
||||
}
|
||||
await appendDenial(session, turn, step);
|
||||
session.append("step/end", { turn, step });
|
||||
return true;
|
||||
} catch {
|
||||
if (opened) {
|
||||
// 无论哪一层开过 step/start,都必须补 step/end,否则孤儿步让宿主崩。
|
||||
if (outerOpened || innerOpened) {
|
||||
try { session.append("step/end", { turn, step }); } catch { /* 步已经合不上时,交给宿主收尾。 */ }
|
||||
}
|
||||
return false;
|
||||
@@ -796,14 +649,22 @@ export function installRegionGate(ctx) {
|
||||
return forward();
|
||||
};
|
||||
const arm = () => {
|
||||
if (ctx.__dshPurgeRegionGate) return;
|
||||
if (ctx.__dshPurgeRegionGate) return true;
|
||||
try {
|
||||
ctx.on("agent/pre-step", hook, { global: true, prepend: true });
|
||||
ctx.__dshPurgeRegionGate = true;
|
||||
return true;
|
||||
} catch {
|
||||
/* 宿主还没有这条事件时,下一拍再挂。 */
|
||||
return false;
|
||||
}
|
||||
};
|
||||
arm();
|
||||
queueMicrotask(arm);
|
||||
if (arm()) return;
|
||||
// 宿主事件总线还没就绪:指数退避 3 次(≈ 0→50ms→200ms),不无限重试。
|
||||
queueMicrotask(() => {
|
||||
if (arm()) return;
|
||||
setTimeout(() => {
|
||||
if (arm()) return;
|
||||
setTimeout(() => { arm(); }, 200);
|
||||
}, 50);
|
||||
});
|
||||
}
|
||||
+2
-146
@@ -1,127 +1,14 @@
|
||||
// 官方桌面已下载新版本时,重启改去跑安装包,装完再解开并重新打补丁。
|
||||
import os from "node:os";
|
||||
// 官方客户端升级后的补丁回写标记。wscript 字面量给重启脚本用。
|
||||
import path from "node:path";
|
||||
import { spawn } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { hostFs as fs, readAsarFile } from "./extract-asar.js";
|
||||
import { hostFs as fs } from "./extract-asar.js";
|
||||
|
||||
const CACHE_DIR_NAME = "@deepseek-aidsh-desktop-updater";
|
||||
const MARKER_NAME = "dsh-purge-reapply-asar";
|
||||
const TEMPLATE_PATH = fileURLToPath(new URL("./official-update.wscript", import.meta.url));
|
||||
|
||||
function harnessExeName(exe) {
|
||||
const base = path.basename(String(exe || "")).toLowerCase();
|
||||
return base === "deepseek harness.exe" || base === "deepseek-harness.exe";
|
||||
}
|
||||
|
||||
function updaterCacheDir() {
|
||||
const local = process.env.LOCALAPPDATA || path.join(os.homedir(), "AppData", "Local");
|
||||
return path.join(local, CACHE_DIR_NAME);
|
||||
}
|
||||
|
||||
export function versionFromInstallerName(fileName) {
|
||||
const match = /^deepseek-harness-(.+)-win-x64\.exe$/i.exec(path.basename(String(fileName || "")));
|
||||
return match ? match[1] : "";
|
||||
}
|
||||
|
||||
function parseSemver(version) {
|
||||
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/.exec(String(version || ""));
|
||||
if (!match) return null;
|
||||
return {
|
||||
major: Number(match[1]),
|
||||
minor: Number(match[2]),
|
||||
patch: Number(match[3]),
|
||||
pre: match[4] ? match[4].split(".") : null,
|
||||
};
|
||||
}
|
||||
|
||||
function compareSemver(left, right) {
|
||||
const a = parseSemver(left);
|
||||
const b = parseSemver(right);
|
||||
if (!a || !b) return 0;
|
||||
if (a.major !== b.major) return a.major - b.major;
|
||||
if (a.minor !== b.minor) return a.minor - b.minor;
|
||||
if (a.patch !== b.patch) return a.patch - b.patch;
|
||||
if (!a.pre && !b.pre) return 0;
|
||||
if (!a.pre) return 1;
|
||||
if (!b.pre) return -1;
|
||||
const count = Math.max(a.pre.length, b.pre.length);
|
||||
for (let i = 0; i < count; i += 1) {
|
||||
if (a.pre[i] === undefined) return -1;
|
||||
if (b.pre[i] === undefined) return 1;
|
||||
const aNum = /^\d+$/.test(a.pre[i]);
|
||||
const bNum = /^\d+$/.test(b.pre[i]);
|
||||
if (aNum && bNum) {
|
||||
const diff = Number(a.pre[i]) - Number(b.pre[i]);
|
||||
if (diff) return diff;
|
||||
} else if (aNum) return -1;
|
||||
else if (bNum) return 1;
|
||||
else if (a.pre[i] !== b.pre[i]) return a.pre[i] < b.pre[i] ? -1 : 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function readPackageVersion(text) {
|
||||
try {
|
||||
return String(JSON.parse(String(text || "")).version || "");
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function readInstalledVersion(exe) {
|
||||
const root = path.dirname(exe);
|
||||
try {
|
||||
const packed = readAsarFile(path.join(root, "resources", "app.asar"), "package.json");
|
||||
const version = readPackageVersion(packed);
|
||||
if (version) return version;
|
||||
} catch {
|
||||
// 归档不在或还被外壳占着时,改看解开目录。
|
||||
}
|
||||
try {
|
||||
return readPackageVersion(fs.readFileSync(path.join(root, "resources", "app", "package.json"), "utf8"));
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/** 官方更新器已经下好、且比当前 exe 新的安装包。没有则返回 null。 */
|
||||
export function pendingOfficialUpdate(exe) {
|
||||
if (process.platform !== "win32" || !harnessExeName(exe)) return null;
|
||||
const cache = updaterCacheDir();
|
||||
let installer = path.join(cache, "installer.exe");
|
||||
let fileName = "installer.exe";
|
||||
let infoVersion = "";
|
||||
try {
|
||||
const info = JSON.parse(fs.readFileSync(path.join(cache, "pending", "update-info.json"), "utf8"));
|
||||
const pendingName = String(info.fileName || "");
|
||||
const pending = path.join(cache, "pending", pendingName);
|
||||
if (pendingName && fs.existsSync(pending)) {
|
||||
installer = pending;
|
||||
fileName = pendingName;
|
||||
}
|
||||
infoVersion = String(info.version || info.fileVersion || info.toVersion || "").trim();
|
||||
} catch {
|
||||
// 没有 update-info 时只认已经复制出来的 installer.exe。
|
||||
}
|
||||
if (!fs.existsSync(installer)) return null;
|
||||
// installer.exe 无版本号时绝不能当「待更新」(#56:同版本缓存会劫持重启解包)。
|
||||
const version = versionFromInstallerName(fileName) || (parseSemver(infoVersion) ? infoVersion : "");
|
||||
if (!version || !parseSemver(version)) return null;
|
||||
const installed = readInstalledVersion(exe);
|
||||
if (installed && compareSemver(version, installed) <= 0) return null;
|
||||
if (!installed) {
|
||||
try {
|
||||
const exeTime = fs.statSync(exe).mtimeMs;
|
||||
const installerTime = fs.statSync(installer).mtimeMs;
|
||||
if (exeTime > installerTime + 2000) return null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return { installer, version, installed };
|
||||
}
|
||||
|
||||
export function upgradeMarkerPath(exe) {
|
||||
if (!harnessExeName(exe)) return "";
|
||||
return path.join(path.dirname(exe), "resources", MARKER_NAME);
|
||||
@@ -149,10 +36,6 @@ export function clearStaleExtractedApps(exe) {
|
||||
}
|
||||
}
|
||||
|
||||
function winPath(value) {
|
||||
return path.win32.normalize(String(value || ""));
|
||||
}
|
||||
|
||||
/** Windows Script Host 无 BOM 时按系统 ANSI 读文件。中文路径写成 \uXXXX,整份脚本保持 ASCII。 */
|
||||
export function wshLiteral(value) {
|
||||
return JSON.stringify(String(value ?? "")).replace(/[\u007f-\uffff]/g, (ch) => {
|
||||
@@ -167,30 +50,3 @@ export function isWshAscii(source) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function renderUpdateScript(exe, installer) {
|
||||
const installDir = winPath(path.dirname(exe));
|
||||
const resources = winPath(path.join(installDir, "resources"));
|
||||
const logPath = winPath(path.join(os.tmpdir(), "dsh-purge-official-update.log"));
|
||||
const body = fs.readFileSync(TEMPLATE_PATH, "utf8")
|
||||
.split("__EXE_JSON__").join(wshLiteral(winPath(exe)))
|
||||
.split("__INSTALLER_JSON__").join(wshLiteral(winPath(installer)))
|
||||
.split("__RESOURCES_JSON__").join(wshLiteral(resources))
|
||||
.split("__INSTALL_DIR_JSON__").join(wshLiteral(installDir))
|
||||
.split("__LOG_JSON__").join(wshLiteral(logPath));
|
||||
if (!isWshAscii(body)) throw new Error("official update script is not ASCII");
|
||||
return body;
|
||||
}
|
||||
|
||||
/** 退出官方客户端后运行已下载的安装包,再打开新版本。不把新的 app.asar 挪走。
|
||||
* #57:默认禁用。宿主版本由用户自行升级;插件不得在「应用/重启」里自动交接官方 installer。
|
||||
*/
|
||||
export function launchOfficialDesktopUpdate(exe, pending) {
|
||||
return {
|
||||
restarting: false,
|
||||
officialUpdate: false,
|
||||
skipped: "manual-only",
|
||||
installer: pending?.installer || "",
|
||||
exe: exe || "",
|
||||
};
|
||||
}
|
||||
@@ -67,7 +67,7 @@ if (!ok) {
|
||||
if (copiedAsar && fso.FileExists(asar)) {
|
||||
try { fso.DeleteFile(asar, true); log('rehid-asar'); } catch (hideErr) { log('rehid-asar ' + hideErr); }
|
||||
}
|
||||
// 并发解包 helper 可能已重建 resources\app;更新失败时仍要把打过补丁的目录搬回来。
|
||||
// A concurrent unpack helper may have recreated resources\app. On failure, move the patched dir back.
|
||||
if (movedApp && prev && fso.FolderExists(prev)) {
|
||||
if (fso.FolderExists(appDir)) {
|
||||
try { fso.DeleteFolder(appDir, true); log('cleared-recreated-app'); } catch (clearErr) { log('cleared-recreated-app ' + clearErr); }
|
||||
|
||||
+9
-4
@@ -279,8 +279,10 @@ export async function reapplyInstalled(options = {}) {
|
||||
const summary = core.summarizeApplyReport(multi.report);
|
||||
const clean =
|
||||
summary.failed.length === 0 &&
|
||||
flash.ok === true &&
|
||||
(core.allPatchHostsWritten(multi.hosts) || core.hostCleanMarkersPresent(aiBase));
|
||||
if (clean && flash.ok !== true) {
|
||||
console.warn("[dsh-purge] cmd flash patch did not apply cleanly; clean flow continues, UI shows cmdFlashOk=false");
|
||||
}
|
||||
if (!clean && freshExtract) {
|
||||
const restored = core.restoreSealedExtract(freshExtract.appDir, freshExtract.prev);
|
||||
return {
|
||||
@@ -300,9 +302,12 @@ export async function reapplyInstalled(options = {}) {
|
||||
markPatchesApplied(installedRev() || undefined);
|
||||
if (freshExtract?.archive) core.writeUnpackedAsarStamp(freshExtract.archive);
|
||||
try {
|
||||
await core.installOverride(core.findDshHome(), false);
|
||||
} catch {
|
||||
// 落下 prompt-inject.md 失败不撤销补丁结果
|
||||
const seed = core.seedPromptInjectAtBoot(core.findDshHome());
|
||||
if (seed && seed.action === "error") {
|
||||
console.warn("[dsh-purge] seed prompt-inject failed:", seed.reason);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("[dsh-purge] seed prompt-inject exception:", String(e && e.message ? e.message : e));
|
||||
}
|
||||
}
|
||||
let renamed = false;
|
||||
|
||||
+82
-6
@@ -542,7 +542,23 @@ window.__ModuleLoader__.load({
|
||||
.rt-kb-tpl-name{flex:1 1 auto;min-width:0;color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}
|
||||
.rt-md{flex:1;overflow:auto;margin:0;padding:14px 16px;font-family:ui-monospace,Menlo,monospace;font-size:12.5px;
|
||||
line-height:1.65;white-space:pre-wrap;word-break:break-word;background:var(--dsw-alias-bg-base)}
|
||||
.rt-weblink{display:block;font-size:11.5px;margin-top:1px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}` /* ---------------------------------------------------------- 桥接与状态 */
|
||||
.rt-weblink{display:block;font-size:11.5px;margin-top:1px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.rt-shots{margin:8px 0 4px;padding:7px 8px;border:1px solid var(--dsw-alias-border-l1);border-radius:7px;
|
||||
background:var(--dsw-alias-bg-layer-1)}
|
||||
.rt-shots-head{display:flex;align-items:baseline;gap:8px;font-size:11.5px;margin-bottom:6px}
|
||||
.rt-shots-n{color:var(--dsw-alias-label-secondary)}
|
||||
.rt-shot-row{display:flex;gap:8px;flex-wrap:wrap}
|
||||
.rt-shot{display:flex;flex-direction:column;gap:3px;max-width:220px}
|
||||
.rt-shot-thumb{border:1px solid var(--dsw-alias-border-l1);border-radius:5px;background:#0b1020;
|
||||
object-fit:contain;display:block;width:auto;max-width:216px}
|
||||
.rt-shot-loading{display:flex;align-items:center;justify-content:center;width:150px;font-size:11px;
|
||||
color:var(--dsw-alias-label-secondary)}
|
||||
.rt-shot-cap{display:flex;align-items:center;gap:5px;font-size:10.5px;overflow-wrap:anywhere}
|
||||
.rt-shot-label{color:var(--dsw-alias-label-secondary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:170px}
|
||||
.rt-shot-zoom{position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,.82);display:flex;flex-direction:column;
|
||||
align-items:center;justify-content:center;gap:10px;cursor:zoom-out;padding:18px}
|
||||
.rt-shot-zoom img{max-width:96vw;max-height:86vh;border-radius:6px;box-shadow:0 18px 48px rgba(0,0,0,.5)}
|
||||
.rt-shot-zoom-cap{color:#e5e7eb;font-size:12px;text-align:center;max-width:90vw;overflow-wrap:anywhere}` /* ---------------------------------------------------------- 桥接与状态 */
|
||||
/** 是否在「全面浏览」独立窗口里(URL hash 标记,复用同一套界面代码)。 */
|
||||
const isFullWindow = () => {
|
||||
try { return String(window.location.hash || '') === '#redteam-full' } catch { return false }
|
||||
@@ -593,6 +609,61 @@ window.__ModuleLoader__.load({
|
||||
}
|
||||
|
||||
const fmt = (s) => (s ? String(s).replace('T', ' ').slice(0, 16) : '—')
|
||||
const shotCache = new Map()
|
||||
const shotLoading = new Map()
|
||||
const shotSrc = (eng, id) => shotCache.get(eng + ':' + id) || null
|
||||
const loadShot = (eng, id) => {
|
||||
const key = eng + ':' + id
|
||||
if (shotCache.has(key) || shotLoading.has(key)) return
|
||||
const p = api({ op: 'shotData', engagement: eng, id: id }).then((r) => {
|
||||
shotCache.set(key, r && r.base64 ? 'data:' + (r.mime || 'image/png') + ';base64,' + r.base64 : '')
|
||||
shotLoading.delete(key)
|
||||
const snap = Object.assign({}, ui)
|
||||
for (const f of Array.from(subs)) {
|
||||
try { f(snap) } catch { /* ignore subscriber errors */ }
|
||||
}
|
||||
}).catch(() => { shotLoading.delete(key) })
|
||||
shotLoading.set(key, p)
|
||||
}
|
||||
const SHOT_KIND = { screenshot: '现场截图', card: '记录生成的证据摘录' }
|
||||
const ShotImage = ({ eng, shot, height }) => {
|
||||
const [zoom, setZoom] = React.useState(false)
|
||||
const src = shotSrc(eng, shot.id)
|
||||
if (src === null) { loadShot(eng, shot.id); }
|
||||
const card = shot.kind === 'card'
|
||||
return h('div', { className: 'rt-shot' },
|
||||
src === null
|
||||
? h('div', { className: 'rt-shot-thumb rt-shot-loading', style: { height: (height || 96) + 'px' } }, '载入中…')
|
||||
: h('img', {
|
||||
className: 'rt-shot-thumb', src: src, alt: shot.label || ('证据 ' + shot.id),
|
||||
style: { height: (height || 96) + 'px', cursor: 'zoom-in' },
|
||||
onClick: () => setZoom(true),
|
||||
}),
|
||||
h('div', { className: 'rt-shot-cap' },
|
||||
h('span', { className: 'rt-tag ' + (card ? 'rt-tag-warn' : 'rt-tag-live'), title: card
|
||||
? '由当日记录生成的证据摘录,不是现场截图 —— 报告里同样会标注'
|
||||
: '现场截图' }, SHOT_KIND[shot.kind] || shot.kind || '证据'),
|
||||
h('span', { className: 'rt-shot-label', title: shot.label || shot.note || '' },
|
||||
shot.label || shot.target || ('#' + shot.id))),
|
||||
zoom
|
||||
? h('div', { className: 'rt-shot-zoom', onClick: () => setZoom(false) },
|
||||
h('img', { src: src, alt: shot.label || '' }),
|
||||
h('div', { className: 'rt-shot-zoom-cap' }, (shot.label || shot.target || '')
|
||||
+ (card ? ' · 由当日记录生成(非现场截图)' : '')
|
||||
+ (shot.captured_at ? ' · ' + fmt(shot.captured_at) : '')
|
||||
+ ' · 点击任意处关闭'))
|
||||
: null)
|
||||
}
|
||||
const ShotStrip = ({ eng, shots, total, title }) => {
|
||||
const list = shots || []
|
||||
if (list.length === 0) return null
|
||||
return h('div', { className: 'rt-shots' },
|
||||
h('div', { className: 'rt-shots-head' },
|
||||
h('b', null, title || '证据截图'),
|
||||
h('span', { className: 'rt-shots-n' }, '显示 ' + list.length + ' 张'
|
||||
+ (total && total > list.length ? '(该得分点共 ' + total + ' 张,取代表图)' : ''))),
|
||||
h('div', { className: 'rt-shot-row' }, list.map((sh) => h(ShotImage, { key: 'sh' + sh.id, eng: eng, shot: sh }))))
|
||||
}
|
||||
/** 发现时间在列表里只留「月-日 时:分」:整行宽度紧张,完整时间进悬浮提示 */
|
||||
const fmtShort = (s) => {
|
||||
const t = String(s || '').replace('T', ' ')
|
||||
@@ -1285,7 +1356,7 @@ window.__ModuleLoader__.load({
|
||||
className: 'rt-avail rt-avail-' + (s.availability || 'unknown'),
|
||||
style: { marginLeft: 6 },
|
||||
title: (s.availability === 'available'
|
||||
? '可用:正文能加载,必需的环境变量/本机路径/基础设施都在'
|
||||
? '可用:技能正文可以加载。缺的外部工具或密钥记在详情里,不阻止调用。'
|
||||
: (s.problems || []).join('\n') || '未知'),
|
||||
}, s.availability === 'available' ? '可用' : s.availability === 'broken' ? '不可用' : '未知'),
|
||||
h('div', { className: 'rt-item-desc' }, s.description || '(无描述)'),
|
||||
@@ -1369,7 +1440,7 @@ window.__ModuleLoader__.load({
|
||||
h('span', { className: 'rt-avail rt-avail-' + avail },
|
||||
avail === 'available' ? '可用' : avail === 'broken' ? '不可用(有明确缺口)' : '未知(正文读不到)')),
|
||||
(s2.problems || []).length > 0
|
||||
? h('div', { className: 'rt-kv' }, h('b', null, '缺口'),
|
||||
? h('div', { className: 'rt-kv' }, h('b', null, avail === 'available' ? '未装上的外部工具' : '缺口'),
|
||||
h('span', null, s2.problems.map((x, i) => h('div', { key: 'p' + i }, '· ' + x))))
|
||||
: null,
|
||||
(s2.needs_user || []).length > 0
|
||||
@@ -2049,15 +2120,16 @@ window.__ModuleLoader__.load({
|
||||
h('span', null, String(x.evidence).replace(/\n+/g, ' '))) : null,
|
||||
x.recorded_at ? h('div', { className: 'rt-rep-meta' }, h('b', null, '取得时间 '),
|
||||
h('span', null, fmt(x.recorded_at) + (x.recorded_by ? '(' + (ROLE_LABEL[x.recorded_by] || x.recorded_by) + ')' : ''))) : null,
|
||||
/* ── 这一步怎么来的:动作步骤(含实际命令与回显)+ 凭据 + 隧道 + WebShell ─────
|
||||
h(ShotStrip, { eng: eng, shots: x.shots, total: x.shot_total, title: '证据截图' }),
|
||||
/* ── 复现步骤:动作记录(含实际命令与回显)+ 凭据 + 隧道 + WebShell ─────
|
||||
报告的交付价值全在这块:账号密码怎么来的、隧道怎么搭的,用户照着就能复现。 */
|
||||
h('details', { className: 'rt-rep-trace', open: x.incomplete === true || (x.steps || []).length === 0 },
|
||||
h('summary', { className: 'rt-rep-trace-head', style: { cursor: 'pointer' } },
|
||||
h('span', { className: 'rt-rep-trace-title' }, '这一步怎么来的(点击展开复现链)'),
|
||||
h('span', { className: 'rt-rep-trace-title' }, '复现步骤(点击展开)'),
|
||||
(x.steps || []).length ? h('span', { className: 'rt-tag' }, (x.steps || []).length + ' 个动作') : null,
|
||||
(x.credentials || []).length ? h('span', { className: 'rt-tag' }, (x.credentials || []).length + ' 条凭据') : null,
|
||||
(x.tunnels || []).length ? h('span', { className: 'rt-tag' }, (x.tunnels || []).length + ' 条隧道') : null,
|
||||
x.incomplete ? h('span', { className: 'rt-tag rt-tag-warn' }, '复现链不完整') : h('span', { className: 'rt-tag rt-tag-live' }, '可复现')),
|
||||
x.incomplete ? h('span', { className: 'rt-tag rt-tag-warn' }, '复现材料待补') : h('span', { className: 'rt-tag rt-tag-live' }, '可复现')),
|
||||
h('div', { style: { paddingTop: 6 } },
|
||||
x.how ? h('div', { className: 'rt-rep-trace-how' }, x.how) : null,
|
||||
(x.steps || []).length === 0
|
||||
@@ -2883,6 +2955,8 @@ window.__ModuleLoader__.load({
|
||||
className: 'rt-tag rt-tag-warn',
|
||||
title: hh.capped_reason || '同一资产同一端口只算分值最高的一条,这条不计分',
|
||||
}, '服务已拿满 · 不计分' + (hh.service ? '(' + hh.service + ')' : '')) : null,
|
||||
hh.shot_count ? h('span', { className: 'rt-tag', title: '这条命中有证据截图(展开得分点即可看到代表图)' },
|
||||
'图 ' + hh.shot_count) : null,
|
||||
h('span', { className: 'rt-hit-time' }, fmt(hh.recorded_at)),
|
||||
h('button', {
|
||||
className: 'rt-btn', style: { padding: '0 5px', fontSize: 10.5 },
|
||||
@@ -2910,6 +2984,8 @@ window.__ModuleLoader__.load({
|
||||
: null,
|
||||
p.hits.length
|
||||
? h('div', null,
|
||||
h(ShotStrip, { eng: eng, shots: p.shots, total: p.shot_total,
|
||||
title: '证据截图 · ' + (p.shot_total || (p.shots || []).length) + ' 张' }),
|
||||
h('div', { className: 'rt-section', style: { padding: '6px 0 0' } },
|
||||
'命中记录 · ' + p.hits.length + '(只记资产与账号密码,详细复现见报告)'),
|
||||
h('div', { className: 'rt-hits' }, hitNodes))
|
||||
|
||||
+40
-12
@@ -242,11 +242,32 @@ function repairDelegation(text) {
|
||||
|
||||
/** 包内锚点门相对预设模板的标记,用来给已有用户预设补一行,不整份覆盖。 */
|
||||
const ANCHOR_ROW_MARK = '- id: anchor-gate'
|
||||
const ANCHOR_BLOCK_START = '# 锚点门'
|
||||
const REDTEAM_TOOLS_MARK = '- id: redteam-tools'
|
||||
|
||||
function anchorBlockBounds(ymlText) {
|
||||
const start = ymlText.indexOf(ANCHOR_BLOCK_START)
|
||||
const end = ymlText.indexOf(REDTEAM_TOOLS_MARK)
|
||||
if (start === -1 || end === -1 || start >= end) return null
|
||||
return { start, end }
|
||||
}
|
||||
|
||||
function readAnchorBlockFromTemplate() {
|
||||
let template = ''
|
||||
try {
|
||||
template = readFileSync(join(packagePaths().presetDir, 'agent.cordis.yml'), 'utf8')
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
const bounds = anchorBlockBounds(template)
|
||||
if (!bounds) return null
|
||||
return template.slice(bounds.start, bounds.end).trim()
|
||||
}
|
||||
|
||||
/**
|
||||
* 锚点门脚本每次用包内副本覆盖(没有用户可改状态)。
|
||||
* 用户预设里还没有这一行时,插到 redteam-tools 前面。
|
||||
* @returns {'inserted'|'updated'|'kept'|'missing'}
|
||||
* YAML 里锚点配置块与包内模板不一致时也会替换(bootstrapMaxTokens 等),其余 preset 正文保留。
|
||||
* @returns {'inserted'|'updated'|'config-updated'|'kept'|'missing'}
|
||||
*/
|
||||
function syncAnchorGate(targetDir) {
|
||||
const src = join(packagePaths().presetDir, 'anchor-gate.mjs')
|
||||
@@ -265,17 +286,22 @@ function syncAnchorGate(targetDir) {
|
||||
if (!existsSync(presetFile)) return script
|
||||
let text
|
||||
try { text = readFileSync(presetFile, 'utf8') } catch { return script }
|
||||
if (text.includes(ANCHOR_ROW_MARK)) return script
|
||||
let template = ''
|
||||
try { template = readFileSync(join(packagePaths().presetDir, 'agent.cordis.yml'), 'utf8') } catch { return script }
|
||||
const start = template.indexOf('# 锚点门')
|
||||
const end = template.indexOf('- id: redteam-tools')
|
||||
if (start === -1 || end === -1 || start > end) return script
|
||||
const block = template.slice(start, end).trim()
|
||||
const templateBlock = readAnchorBlockFromTemplate()
|
||||
if (!templateBlock) return script
|
||||
const nl = text.includes('\r\n') ? '\r\n' : '\n'
|
||||
const rendered = block.replace(/\r\n/g, '\n').replace(/\n/g, nl)
|
||||
const marker = '- id: redteam-tools'
|
||||
const at = text.indexOf(marker)
|
||||
const rendered = templateBlock.replace(/\r\n/g, '\n').replace(/\n/g, nl)
|
||||
|
||||
if (text.includes(ANCHOR_ROW_MARK)) {
|
||||
const bounds = anchorBlockBounds(text)
|
||||
if (!bounds) return script
|
||||
const currentBlock = text.slice(bounds.start, bounds.end).trim()
|
||||
if (currentBlock === rendered.trim()) return script
|
||||
const next = text.slice(0, bounds.start) + rendered + nl + nl + text.slice(bounds.end)
|
||||
writeFileSync(presetFile, next, 'utf8')
|
||||
return script === 'updated' ? 'updated' : 'config-updated'
|
||||
}
|
||||
|
||||
const at = text.indexOf(REDTEAM_TOOLS_MARK)
|
||||
const next = at === -1
|
||||
? text.replace(/\s*$/, '') + nl + nl + rendered + nl
|
||||
: text.slice(0, at) + rendered + nl + nl + text.slice(at)
|
||||
@@ -337,12 +363,14 @@ export function installPreset(options = {}) {
|
||||
const anchor = syncAnchorGate(target)
|
||||
if (anchor === 'inserted') log('已把锚点门补进现有预设(其余内容保留)')
|
||||
else if (anchor === 'updated') log('已更新锚点门脚本')
|
||||
else if (anchor === 'config-updated') log('已同步锚点门配置(bootstrapMaxTokens / maxBootstrapSteps 等)')
|
||||
const repaired = [
|
||||
rendered.changed ? rendered.reason : null,
|
||||
tools.changed ? 'tools-package' : null,
|
||||
delegation.changed ? 'delegation' : null,
|
||||
anchor === 'inserted' ? 'anchor-gate' : null,
|
||||
anchor === 'updated' ? 'anchor-script' : null,
|
||||
anchor === 'config-updated' ? 'anchor-config' : null,
|
||||
].filter(Boolean)
|
||||
if (repaired.length > 0) {
|
||||
return {
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
/**
|
||||
* 迁移:清掉预发布期(≤0.7.0)用「开发版」安装留下的 profile 补丁行。
|
||||
*
|
||||
* 为什么需要它:那些机器在 `$DSH_HOME/profiles/web/cordis.patch.yml` 里手写过
|
||||
* - insert:
|
||||
* - id: redteam-store
|
||||
* name: dsh-redteam-store
|
||||
* config: {…}
|
||||
* - id: redteam-ui
|
||||
* name: dsh-redteam-ui
|
||||
* bundle 补丁在**更早**的层里挂自己的行,改不动后面这一层,于是两套一起挂:
|
||||
* service "redteam" has been registered at <redteam-store>
|
||||
* `dsh web` 起不来(0.7.0 之前报的是 duplicate loader entry id)。
|
||||
*
|
||||
* 做法:按行扫描,删掉这两条**条目本身及其子行**(缩进更深的部分),其它内容原样保留;
|
||||
* 若某个 `- insert:` 的子项被删空,连同那一行一起删。先备份再写回;幂等;支持 --dry-run。
|
||||
*
|
||||
* 用法:
|
||||
* node node_modules/dsh-redteam-mode/lib/migrate-legacy-rows.mjs [--profile web] [--dry-run]
|
||||
*/
|
||||
import { copyFileSync, existsSync, readFileSync, writeFileSync } from 'node:fs'
|
||||
import { homedir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
|
||||
const LEGACY_IDS = ['redteam-store', 'redteam-ui']
|
||||
|
||||
const args = process.argv.slice(2)
|
||||
const dryRun = args.includes('--dry-run')
|
||||
const profileArg = args.indexOf('--profile')
|
||||
const profile = profileArg >= 0 ? args[profileArg + 1] : 'web'
|
||||
const dshHome = process.env.DSH_HOME || join(homedir(), '.dsh')
|
||||
const patchPath = join(dshHome, 'profiles', profile, 'cordis.patch.yml')
|
||||
|
||||
if (!existsSync(patchPath)) {
|
||||
console.log(`没有找到 profile 补丁:${patchPath}(无事可做)`)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const indentOf = (line) => (/^[ \t]*/.exec(line) || [''])[0].length
|
||||
const isBlank = (line) => line.trim() === ''
|
||||
|
||||
/**
|
||||
* 删掉一个条目:从 `- id: <legacyId>` 那行开始,连带删除后续**缩进更深**的行
|
||||
* (它自己的 name/config/…),遇到缩进不更深且非空的行就停。
|
||||
*/
|
||||
function removeEntry(lines, legacyId) {
|
||||
const out = []
|
||||
const removed = []
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i]
|
||||
const m = /^[ \t]*-[ \t]+id:[ \t]*(\S+)[ \t]*$/.exec(line)
|
||||
if (m === null || m[1] !== legacyId) { out.push(line); continue }
|
||||
const base = indentOf(line)
|
||||
removed.push(line.trim())
|
||||
let j = i + 1
|
||||
while (j < lines.length) {
|
||||
const next = lines[j]
|
||||
if (isBlank(next)) { j++; continue } /* 条目内的空行也一并吃掉 */
|
||||
if (indentOf(next) <= base) break
|
||||
j++
|
||||
}
|
||||
i = j - 1
|
||||
}
|
||||
return { lines: out, removed }
|
||||
}
|
||||
|
||||
/**
|
||||
* 删掉子项已被删空的 `- insert:` 行(连同它下面只剩注释/空行的块)。
|
||||
*
|
||||
* 注意:块内的**注释不算子项**——预发布期的补丁里 `- insert:` 下面常常先写一段
|
||||
* 说明注释再写 `- id:` 行,删掉 id 行后如果还把注释当子项,就会留下一个
|
||||
* `- insert:` + 注释的悬空块(YAML 解析成 `{insert: null}`,boot 仍会出错)。
|
||||
*/
|
||||
function dropEmptyInserts(lines) {
|
||||
const out = []
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i]
|
||||
if (/^[ \t]*-[ \t]*insert:[ \t]*$/.test(line)) {
|
||||
const base = indentOf(line)
|
||||
let j = i + 1
|
||||
let hasChild = false
|
||||
while (j < lines.length) {
|
||||
const next = lines[j]
|
||||
if (isBlank(next) || next.trim().startsWith('#')) {
|
||||
if (next.trim().startsWith('#') && indentOf(next) <= base) break
|
||||
j++
|
||||
continue
|
||||
}
|
||||
if (indentOf(next) <= base) break
|
||||
hasChild = true
|
||||
break
|
||||
}
|
||||
if (!hasChild) { i = j - 1; continue } /* 整块(含块内注释)一并丢掉 */
|
||||
}
|
||||
out.push(line)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
const original = readFileSync(patchPath, 'utf8')
|
||||
let lines = original.split('\n')
|
||||
const removed = []
|
||||
for (const id of LEGACY_IDS) {
|
||||
const res = removeEntry(lines, id)
|
||||
lines = res.lines
|
||||
removed.push(...res.removed)
|
||||
}
|
||||
lines = dropEmptyInserts(lines)
|
||||
/* 补丁文件必须是顶层 YAML 数组:整份被删空时要写回 `[]`,不能留空文件
|
||||
(空文件会让 boot 报 "must be a top-level YAML array of loader patch entries")。 */
|
||||
let text = lines.join('\n')
|
||||
if (text.split('\n').every((l) => l.trim() === '' || l.trim().startsWith('#'))) text = '[]\n'
|
||||
|
||||
if (removed.length === 0 && text === original) {
|
||||
console.log(`✓ ${patchPath} 里没有预发布期的遗留行(无需迁移)`)
|
||||
process.exit(0)
|
||||
}
|
||||
if (removed.length === 0) {
|
||||
/* 没有遗留行、但文件需要清理(例如旧版脚本删空 insert 块时留下的悬空 `- insert:`)。 */
|
||||
if (dryRun) {
|
||||
console.log('[dry-run] 将清理悬空的 `- insert:` 块(文件未改动)')
|
||||
process.exit(0)
|
||||
}
|
||||
const cleaned = `${patchPath}.bak-${Date.now()}`
|
||||
copyFileSync(patchPath, cleaned)
|
||||
writeFileSync(patchPath, text, 'utf8')
|
||||
console.log('✓ 已清理悬空的 `- insert:` 块(它下面只剩注释,YAML 会解析成 null)')
|
||||
console.log(` 备份:${cleaned}`)
|
||||
console.log(' 重启 dsh web 即可。')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const before = original.split('\n').filter((l) => l.trim() !== '').length
|
||||
const after = text.split('\n').filter((l) => l.trim() !== '').length
|
||||
if (dryRun) {
|
||||
console.log(`[dry-run] 将删除 ${removed.length} 条遗留行,有效行 ${before} → ${after}(文件未改动)`)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const backup = `${patchPath}.bak-${Date.now()}`
|
||||
copyFileSync(patchPath, backup)
|
||||
writeFileSync(patchPath, text, 'utf8')
|
||||
console.log(`✓ 已删除 ${removed.length} 条遗留行(有效行 ${before} → ${after})`)
|
||||
console.log(` 备份:${backup}`)
|
||||
console.log(' 重启 dsh web 即可。')
|
||||
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* 当前靶标的目标卡。指挥和子会话拼系统提示词时放在清洗稿后面。
|
||||
* 只读 redteam/current 和 engagement.yaml,不打开工具模块,也不开 sqlite。
|
||||
*/
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { redteamRoot } from "./platform-config.js";
|
||||
|
||||
function safeEngagementId(id) {
|
||||
const text = String(id || "").trim();
|
||||
if (!text || text.length > 200) return "";
|
||||
if (text.includes("..") || text.includes("/") || text.includes("\\") || text.includes("\0")) return "";
|
||||
return text;
|
||||
}
|
||||
|
||||
function readMeta(path) {
|
||||
if (!existsSync(path)) return null;
|
||||
const out = {};
|
||||
for (const line of readFileSync(path, "utf8").split("\n")) {
|
||||
const matched = /^([A-Za-z_][A-Za-z0-9_]*):\s*(.*)$/.exec(line);
|
||||
if (!matched) continue;
|
||||
const value = matched[2].trim();
|
||||
if (value.startsWith("[") && value.endsWith("]")) {
|
||||
out[matched[1]] = value.slice(1, -1).split(",").map((item) => item.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
|
||||
} else {
|
||||
out[matched[1]] = value.replace(/^["']|["']$/g, "");
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** 没有当前靶标时返回空串,不编一个目标。 */
|
||||
export function readObjectiveCard(root = redteamRoot()) {
|
||||
try {
|
||||
const id = safeEngagementId(readFileSync(join(root, "current"), "utf8"));
|
||||
if (!id) return "";
|
||||
const meta = readMeta(join(root, "engagements", id, "engagement.yaml"));
|
||||
const name = String(meta?.target_name || "").trim();
|
||||
if (!name) return "";
|
||||
const scope = Array.isArray(meta.scope_cidrs) ? meta.scope_cidrs.map((item) => String(item).trim()).filter(Boolean) : [];
|
||||
const scopeLine = scope.length > 0 ? scope.join("、") : "只打这个单位名下的资产";
|
||||
return [
|
||||
"## 本次目标",
|
||||
`只打:${name}`,
|
||||
`范围:${scopeLine}`,
|
||||
"不打:回报里带出来的其它单位。只有用户明确说出新的单位名称,才改打新目标。",
|
||||
].join("\n");
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -400,45 +400,4 @@ function readPresetDefinition(id, dir) {
|
||||
plugins: readCompositionRows(read("agent.cordis.yml"), dir)
|
||||
};
|
||||
}
|
||||
/** The overlay table: settings field to composition row and config key. */
|
||||
function overrideTargets(overrides) {
|
||||
return [["tool-catalog", { ...overrides.presentation === void 0 ? {} : { presentation: overrides.presentation } }], ["guard", {
|
||||
...overrides.guardEnabled === void 0 ? {} : { enabled: overrides.guardEnabled },
|
||||
...overrides.guardSensitivity === void 0 ? {} : { sensitivity: overrides.guardSensitivity },
|
||||
...overrides.guardStallReasoningChars === void 0 ? {} : { stallReasoningChars: overrides.guardStallReasoningChars },
|
||||
...overrides.guardGlobalStallCap === void 0 ? {} : { globalStallCap: overrides.guardGlobalStallCap },
|
||||
...overrides.guardEchoFailures === void 0 ? {} : { echoFailures: overrides.guardEchoFailures }
|
||||
}]];
|
||||
}
|
||||
/**
|
||||
* Apply the settings overlay to one parsed row list.
|
||||
*
|
||||
* Rows are addressed by their `id`, and only a row the composition actually
|
||||
* carries is touched: the overlay narrows the shipped configuration, it never
|
||||
* invents a mount the preset did not have. The shipped composition declares
|
||||
* every key the overlay writes, so leaving a key absent only matters for a
|
||||
* composition that dropped it.
|
||||
* @param rows - the parsed composition rows.
|
||||
* @param overrides - the operator's settings-surface choices.
|
||||
* @returns a new row list with the overlay applied.
|
||||
*/
|
||||
function applyPresetOverrides(rows, overrides) {
|
||||
const table = overrideTargets(overrides);
|
||||
return rows.map((row) => {
|
||||
const target = table.find(([id]) => id === row.id);
|
||||
if (target === void 0) return row;
|
||||
const [, patch] = target;
|
||||
if (Object.keys(patch).length === 0) return row;
|
||||
const config = row.config;
|
||||
if (typeof config !== "object" || config === null || Array.isArray(config)) return row;
|
||||
return {
|
||||
...row,
|
||||
config: {
|
||||
...config,
|
||||
...patch
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export { CompositionError, readCompositionRows, readPresetDefinition };
|
||||
@@ -14,6 +14,20 @@ import { redteamRoot } from './platform-config.js'
|
||||
const ROLE_TAG = /^[ \t]*redteamRole:[ \t]*(recon|assess|vuln-scan|exploit|internal)[ \t]*$/im
|
||||
|
||||
const roleBySession = new Map()
|
||||
// 模块级 Map,跨 install/dispose 都不清,长开进程 session id 持续堆积。
|
||||
// FIFO 兜底:超过 400 淘汰最早 100 条;角色很短(字符串),阈值可以放宽。
|
||||
const ROLE_SESSION_CAP = 400
|
||||
const ROLE_SESSION_EVICT = 100
|
||||
|
||||
function evictRoleBySessionIfOverflow() {
|
||||
if (roleBySession.size < ROLE_SESSION_CAP) return
|
||||
let i = 0
|
||||
for (const k of roleBySession.keys()) {
|
||||
if (i >= ROLE_SESSION_EVICT) break
|
||||
roleBySession.delete(k)
|
||||
i += 1
|
||||
}
|
||||
}
|
||||
|
||||
export function parseRedteamRole(text) {
|
||||
const matched = String(text || '').match(ROLE_TAG)
|
||||
@@ -31,6 +45,7 @@ export function textOfMessage(message) {
|
||||
|
||||
function remember(agent, role) {
|
||||
const ids = [agent?.session?.id, agent?.id].filter((id) => id !== undefined && id !== null)
|
||||
if (ids.length) evictRoleBySessionIfOverflow()
|
||||
for (const id of ids) roleBySession.set(String(id), role)
|
||||
}
|
||||
|
||||
|
||||
+20
-563
@@ -1,4 +1,7 @@
|
||||
import { DatabaseSync } from 'node:sqlite'
|
||||
/* 计分/判定规则的唯一实现在 score-rules.js;本文件只留 DDL 与迁移。
|
||||
migrate() 里用到的 parseTargetPort 也从那里取,不再保留副本。 */
|
||||
import { parseTargetPort } from './score-rules.js'
|
||||
|
||||
/**
|
||||
* 事实库 schema 与增量迁移(零依赖)。
|
||||
@@ -282,6 +285,20 @@ CREATE TABLE IF NOT EXISTS attack_step (
|
||||
recorded_by TEXT, recorded_at TEXT
|
||||
);
|
||||
|
||||
/* 证据截图:得分成果的"看得见"的那一份材料。
|
||||
落盘位置:<靶标目录>/shots/,库里只存文件名与元数据 —— 图片不进 SQLite。
|
||||
kind:screenshot 现场截图;card 由记录生成的证据摘录卡,报告里要分开标注。 */
|
||||
CREATE TABLE IF NOT EXISTS shot (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
point_id INTEGER, hit_id INTEGER, asset_id INTEGER, vuln_id INTEGER,
|
||||
target TEXT, label TEXT, note TEXT,
|
||||
file TEXT NOT NULL,
|
||||
kind TEXT DEFAULT 'screenshot',
|
||||
mime TEXT, bytes INTEGER, width INTEGER, height INTEGER, sha256 TEXT,
|
||||
source_ref TEXT, captured_at TEXT, found_by_agent TEXT, agent TEXT, created_at TEXT,
|
||||
UNIQUE(file)
|
||||
);
|
||||
|
||||
|
||||
CREATE INDEX IF NOT EXISTS ix_asset_segment ON asset(segment_cidr);
|
||||
CREATE INDEX IF NOT EXISTS ix_asset_ip_int ON asset(ip_int);
|
||||
@@ -301,6 +318,9 @@ CREATE INDEX IF NOT EXISTS ix_cred_host ON credential(host);
|
||||
CREATE INDEX IF NOT EXISTS ix_access_host ON access_session(host);
|
||||
CREATE INDEX IF NOT EXISTS ix_webshell_status ON webshell(status);
|
||||
CREATE INDEX IF NOT EXISTS ix_tunnel_status ON tunnel(status);
|
||||
CREATE INDEX IF NOT EXISTS ix_shot_point ON shot(point_id);
|
||||
CREATE INDEX IF NOT EXISTS ix_shot_hit ON shot(hit_id);
|
||||
CREATE INDEX IF NOT EXISTS ix_shot_asset ON shot(asset_id);
|
||||
CREATE INDEX IF NOT EXISTS ix_http_vuln ON http_evidence(vuln_id);
|
||||
CREATE INDEX IF NOT EXISTS ix_http_asset ON http_evidence(asset_id);
|
||||
CREATE INDEX IF NOT EXISTS ix_step_seq ON attack_step(seq, id);
|
||||
@@ -608,566 +628,3 @@ export function migrateKnowledge(db) {
|
||||
}
|
||||
} catch { /* 忽略 */ }
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ 判定规则 */
|
||||
|
||||
/**
|
||||
* 什么算"真隧道"(算边界突破/内网突破的凭证):**必须跨越了靶标边界**,
|
||||
* 即通道的一端在目标侧。三种情况:
|
||||
* · target-outbound:目标主动连出到我的服务器(反弹 shell 落地、目标上跑 frp/Stowaway 客户端)
|
||||
* · target-http:经目标 WebShell/HTTP 通道(suo5、Neo-ReGeorg、reGeorg、自研 HTTP 隧道)
|
||||
* · target-agent:经目标上已控进程/会话转发的隧道(SSH -R 由目标发起等)
|
||||
* 不算的:self-only —— 只在自己 VPS / 自建服务器上开的代理或服务端,没碰到目标。
|
||||
*/
|
||||
const TUNNEL_ENTRY_KINDS = {
|
||||
'target-outbound': '目标主动连出(反弹 shell / 目标上跑 frp 客户端)',
|
||||
'target-http': '经目标 WebShell/HTTP 通道(suo5 / Neo-ReGeorg)',
|
||||
'target-agent': '经目标已控进程/会话转发(SSH -R 等)',
|
||||
'self-only': '只在自己 VPS/自建服务器上(不算突破)',
|
||||
}
|
||||
export { TUNNEL_ENTRY_KINDS }
|
||||
|
||||
/** 这条隧道算不算"跨越了靶标边界"。未声明(老数据/没填)返回 null,界面按"待确认"显示。 */
|
||||
export function tunnelIsLegit(entryKind) {
|
||||
const k = String(entryKind || '').trim()
|
||||
if (k === '') return null
|
||||
return k !== 'self-only'
|
||||
}
|
||||
|
||||
/**
|
||||
* 账号/权限类得分点:**自己注册、自己创建的账号不算拿到权限**(演练得分针对"拿到别人已有的")。
|
||||
* 这些得分点命中时会要求声明 self_created,避免把自助注册当成战果。
|
||||
*/
|
||||
const ACCOUNT_POINT_CODES = ['web-account-user', 'web-account-admin', 'server-shell', 'db-access', 'internal-pivot', 'core-system']
|
||||
export { ACCOUNT_POINT_CODES }
|
||||
|
||||
/**
|
||||
* 按「服务」封顶的得分点:**同一个资产的同一个端口只算一次分**。
|
||||
*
|
||||
* · 账号类(web-account-user / web-account-admin)——拿到最高权限账号即该服务拿满:
|
||||
* 普通账号 10 分、管理员 20 分,同一服务上再刷几个账号都不再累加
|
||||
* (两种账号算**同一类**:先拿普通账号、后拿管理员,只有管理员那条计分,总分按最高那条算)。
|
||||
* · 数据库类(db-access)——同口径:一个库权限拿满,同服务再刷第二个库账号不重复计分。
|
||||
*
|
||||
* 其它得分点(webshell/rce/sensitive-data/boundary/…)仍然不设上限,按命中次数累加。
|
||||
*/
|
||||
const SERVICE_CAPPED_POINT_CODES = ['web-account-user', 'web-account-admin', 'db-access']
|
||||
export { SERVICE_CAPPED_POINT_CODES }
|
||||
|
||||
/**
|
||||
* 从 target 里解析端口:`http://h:8080/x`、`10.0.0.5:6379`、`10.0.0.5:22`。
|
||||
* 没有端口或解析不出返回 null(**不要编造 80/443**,否则会把不同服务并成一个)。
|
||||
*/
|
||||
export function parseTargetPort(target) {
|
||||
const t = String(target || '').trim()
|
||||
if (t === '') return null
|
||||
const url = /^[a-z][a-z0-9+.-]*:\/\/([^/?#\s]+)/i.exec(t)
|
||||
const authority = url !== null ? url[1] : (/^([^\s/?#]+)/.exec(t) || [])[1]
|
||||
if (!authority) return null
|
||||
const m = /:(\d{1,5})$/.exec(authority)
|
||||
if (m === null) return null
|
||||
const n = Number(m[1])
|
||||
return Number.isInteger(n) && n > 0 && n <= 65535 ? n : null
|
||||
}
|
||||
|
||||
/** 库列的 port 值(老库可能是 null/0/空串)。 */
|
||||
function normalizePort(value) {
|
||||
if (value === null || value === undefined || value === '') return null
|
||||
const n = Number(value)
|
||||
return Number.isInteger(n) && n > 0 && n <= 65535 ? n : null
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 target 里取「服务标识」:host[:port]。
|
||||
* · 端口取显式写的那个;没写就按协议推默认端口(http→80、https→443、其它→不推断),
|
||||
* 这样 `http://h/x` 与 `http://h:80/y` 会归到同一个服务;
|
||||
* · 路径/参数/查询串一律丢掉(`http://h:8080/a/b?c=1` → `h:8080`)。
|
||||
* 解析不出 host 时返回 null。
|
||||
*/
|
||||
function targetAuthority(target) {
|
||||
const t = String(target || '').trim()
|
||||
if (t === '') return null
|
||||
const url = /^([a-z][a-z0-9+.-]*):\/\/([^/?#\s]+)/i.exec(t)
|
||||
const scheme = url !== null ? url[1].toLowerCase() : null
|
||||
const authority = url !== null ? url[2] : (/^([^\s/?#]+)/.exec(t) || [])[1]
|
||||
if (!authority) return null
|
||||
const host = authority.replace(/:\d{1,5}$/, '').toLowerCase()
|
||||
if (host === '') return null
|
||||
let port = parseTargetPort(t)
|
||||
/* 没写端口时按协议补默认端口:避免同一个服务的两种写法被算成两个服务而被重复计分 */
|
||||
if (port === null) {
|
||||
if (scheme === 'http') port = 80
|
||||
else if (scheme === 'https') port = 443
|
||||
}
|
||||
return port === null ? host : host + ':' + port
|
||||
}
|
||||
|
||||
/**
|
||||
* 「服务」键:得分封顶的粒度 = 同一个资产的同一个端口。
|
||||
* · target 能解析出 host[:port] → 就用它(`t10.20.30.40:3306`)——
|
||||
* 同一个服务可能由不同的人记分,有的带 asset_id、有的只写 target,
|
||||
* 以目标为准才能把它们归到一起;
|
||||
* · target 解析不出(缺失/只写了名字)→ 退到资产:有端口用 `a<id>:<port>`,
|
||||
* 没端口记 `a<id>:0`(该资产的未知端口);
|
||||
* · 两样都没有 → null(拿不到服务信息,这条不参与封顶)。
|
||||
*/
|
||||
export function scoreServiceKey(hit = {}) {
|
||||
const authority = targetAuthority(hit.target)
|
||||
if (authority !== null) return 't' + authority
|
||||
const assetId = hit.asset_id === null || hit.asset_id === undefined || hit.asset_id === '' ? null : Number(hit.asset_id)
|
||||
if (assetId === null) return null
|
||||
const port = normalizePort(hit.port)
|
||||
return 'a' + assetId + ':' + (port === null ? 0 : port)
|
||||
}
|
||||
|
||||
/** 「服务」的可读标签,给告警/报告用(如 `10.1.2.3:8080`)。 */
|
||||
export function serviceLabel(hit = {}, assetIp) {
|
||||
const ip = assetIp || hit.asset_ip || ''
|
||||
const port = normalizePort(hit.port) ?? parseTargetPort(hit.target)
|
||||
if (ip !== '') return port === null ? ip : ip + ':' + port
|
||||
/* 没有资产 id 时用 target 的 host[:port](去掉路径与参数,别把整条 URL 当服务名);
|
||||
端口来自库列而 target 里没写时补上,便于一眼看出是哪个服务。 */
|
||||
const authority = targetAuthority(hit.target)
|
||||
if (authority === null) return hit.target ? String(hit.target) : '(未标注服务)'
|
||||
if (port !== null && !/:\d{1,5}$/.test(authority)) return authority + ':' + port
|
||||
return authority
|
||||
}
|
||||
|
||||
/**
|
||||
* 得分封顶与去重的**唯一实现**(数据驱动,v0.11.0 起)。
|
||||
*
|
||||
* 判定字段来自得分点本身(`score_point.rule / cap / dedup_scope`),不再靠代码里的硬编码名单:
|
||||
* · `dedup_scope = service` —— 同一(资产, 端口)只算分值最高的一条;
|
||||
* · `dedup_scope = system` —— 同一(资产, 端口, 系统名)只算最高权限一条,
|
||||
* 用于"同一个系统只计算一次最高权限分"(邮箱/OA/集权系统等);
|
||||
* · `dedup_scope = target` —— 整个目标只算一次(突破网络边界、IPv6 加成);
|
||||
* · `dedup_scope = none` —— 不去重,按台/卡/节点数累加(算力卡等)。
|
||||
* 之后按 `rule` 分组累计,超过该规则 `cap` 的部分标 `capped`(cap = 0 表示不设上限)。
|
||||
*
|
||||
* `self_created = 1`(自己注册/自建的账号)本来就不计分,既不参与竞争也不占位。
|
||||
*
|
||||
* @param {Array} rows - 命中行(需带 code / points / asset_id / port / target / recorded_at;
|
||||
* 可选 system_key 供 system 口径使用)
|
||||
* @param {Map|Object|null} pointsByCode - code → `{rule, cap, dedup_scope, points}`;
|
||||
* 省略时退化为"每个 code 自成一组、只去重不封顶"(兼容旧调用)
|
||||
* @returns {{capped:number, items:Array, caps:Map}} 打过标记的行 + 被封顶条数 + 各规则上限用量
|
||||
*/
|
||||
export function applyScoreCaps(rows = [], pointsByCode = null, nameByAsset = null) {
|
||||
const metaOf = (r) => {
|
||||
const m = pointsByCode === null || pointsByCode === undefined
|
||||
? undefined
|
||||
: (typeof pointsByCode.get === 'function' ? pointsByCode.get(r.code) : pointsByCode[r.code])
|
||||
const rule = m && m.rule !== null && m.rule !== undefined ? Number(m.rule) : null
|
||||
const legacyScope = legacyCapGroup(r.code)
|
||||
return {
|
||||
group: rule === null ? 'code:' + String(r.code || '') : 'rule:' + rule,
|
||||
cap: m && Number(m.cap) > 0 ? Number(m.cap) : 0,
|
||||
scope: (m && m.dedup_scope) || legacyScope || 'none',
|
||||
rule,
|
||||
}
|
||||
}
|
||||
const flagged = (rows || []).map((r) => {
|
||||
const m = metaOf(r)
|
||||
return {
|
||||
...r, capped: false, capped_by_id: null, capped_reason_kind: null,
|
||||
service_key: null, cap_group: m.group, dedup_scope: m.scope, rule: m.rule, rule_cap: m.cap,
|
||||
}
|
||||
})
|
||||
|
||||
/* ① 计分口径去重:同一口径键内只保留分值最高的一条(同分取更早记的) */
|
||||
const buckets = new Map()
|
||||
for (const r of flagged) {
|
||||
if (Number(r.self_created) === 1) continue
|
||||
const scope = r.dedup_scope
|
||||
if (scope === 'none' || scope === null || scope === undefined) continue
|
||||
let key
|
||||
if (scope === 'target') key = 'target'
|
||||
else if (scope === 'system') key = 'sys:' + String(systemKeyOf(r, nameByAsset) || '')
|
||||
else {
|
||||
/* `service` 口径必须有真正的服务键(`t<host[:port]>` / `a<id>:<port>`)。
|
||||
拿不到服务信息时**不参与去重**,而不是退回"每条自成一键" —— 后者会让
|
||||
`svc:#hit7` 这种键把同一口径的命中全部互相顶掉:实测 62 条无 target 的
|
||||
terminal-access 命中里 61 条被判 dedup 不计分、只留 1 条,等于静默吃掉成果。
|
||||
宁可少封顶也不能错封:认不出服务就各算各的。 */
|
||||
const svc = scoreServiceKey(r)
|
||||
if (svc === null || svc === undefined || String(svc) === '') continue
|
||||
key = 'svc:' + String(svc)
|
||||
}
|
||||
if (key === '' || key === 'svc:null' || key === 'sys:null') continue
|
||||
const k = r.cap_group + '|' + key
|
||||
if (!buckets.has(k)) buckets.set(k, [])
|
||||
buckets.get(k).push(r)
|
||||
}
|
||||
let capped = 0
|
||||
for (const list of buckets.values()) {
|
||||
if (list.length < 2) continue
|
||||
const best = pickBestHit(list)
|
||||
for (const r of list) {
|
||||
if (r === best) continue
|
||||
r.capped = true
|
||||
r.capped_by_id = best.id
|
||||
r.capped_by_points = Number(best.points) || 0
|
||||
r.capped_by_evidence = best.evidence || null
|
||||
r.capped_reason_kind = 'dedup'
|
||||
capped += 1
|
||||
}
|
||||
}
|
||||
|
||||
/* ② 规则上限:同一 rule 的计分命中累计不得超过 cap(按分值从高到低累计,超出的标 capped) */
|
||||
const caps = new Map()
|
||||
const byRule = new Map()
|
||||
for (const r of flagged) {
|
||||
if (r.capped === true || Number(r.self_created) === 1) continue
|
||||
if (r.rule_cap <= 0) continue
|
||||
if (!byRule.has(r.cap_group)) byRule.set(r.cap_group, [])
|
||||
byRule.get(r.cap_group).push(r)
|
||||
}
|
||||
for (const [group, list] of byRule.entries()) {
|
||||
const cap = list[0].rule_cap
|
||||
const ordered = [...list].sort((a, b) => {
|
||||
const pa = Number(a.points) || 0; const pb = Number(b.points) || 0
|
||||
if (pb !== pa) return pb - pa
|
||||
return Number(a.id) - Number(b.id)
|
||||
})
|
||||
let used = 0; let nCapped = 0
|
||||
for (const r of ordered) {
|
||||
const pts = Number(r.points) || 0
|
||||
if (used + pts > cap) {
|
||||
r.capped = true
|
||||
r.capped_reason_kind = 'cap'
|
||||
r.capped_by_points = null
|
||||
nCapped += 1
|
||||
capped += 1
|
||||
} else {
|
||||
used += pts
|
||||
}
|
||||
}
|
||||
caps.set(group, { rule: list[0].rule, cap, used, capped: nCapped })
|
||||
}
|
||||
return { capped, items: flagged, caps }
|
||||
}
|
||||
|
||||
/**
|
||||
* 参与 `system` 口径去重的"系统键"。
|
||||
*
|
||||
* 规则原文是"同一个系统只计算一次最高权限分"(邮箱、OA、集权系统等)。
|
||||
* 判定顺序:
|
||||
* ① 命中自带的 `system_key`(调用方显式指定,最准);
|
||||
* ② 资产的 `primary_name`(系统名/域名的首选名);资产名往往是同一套系统,最接近"同一个系统";
|
||||
* ③ 退回服务键(资产:端口)。
|
||||
* 三条都拿不到返回 null —— 此时**不参与该口径去重**,宁可不封顶也不要错封。
|
||||
*/
|
||||
function systemKeyOf(hit = {}, nameByAsset = null) {
|
||||
const svc = scoreServiceKey(hit)
|
||||
const svcText = svc === null || svc === undefined ? '' : String(svc)
|
||||
|
||||
/* ① 调用方显式给的 system_key:**只有它带上服务键前缀(t<host[:port]> / a<id>:<port>)才采信**。
|
||||
调用方(listScorePoints / scoreReport / scoreChain)会预造 `资产名|端口` 这种键,
|
||||
资产还没有名字时会退化成 `"|8080"` —— 若直接采信,10.7.7.7:8080 与 10.7.7.8:8080
|
||||
会被并成"同一个系统",把另一台主机的成果白白封顶。
|
||||
不能采信时**继续往下走**,用服务键兜底,而不是丢掉整个 system 口径。 */
|
||||
const explicit = String(hit.system_key || '').trim()
|
||||
if (explicit !== '' && (svcText === '' || explicit.includes(svcText))) {
|
||||
/* 没有服务键可校验时,要求"名字段非空"(避免只认端口的野键把所有服务并在一起) */
|
||||
const head = explicit.split('|')[0]
|
||||
if (svcText !== '' || String(head).trim() !== '') return explicit
|
||||
}
|
||||
|
||||
/* ② 资产名(系统名/域名首选名)+ 服务键 —— **这是 system 口径的主力路径**。
|
||||
规则原文是"同一个系统只计算一次最高权限分",覆盖面是"同一系统 + 同一端口":
|
||||
同一套系统跑在多台主机、多个端口时是不同实例,各自算一次最高权限。
|
||||
⚠️ 真的需要"跨主机、跨端口只算一次"时,应显式给 system_key 并用同一个值
|
||||
(见上 ①)——但那时请自己确认这些命中确实是同一个系统实例。 */
|
||||
const id = hit.asset_id === null || hit.asset_id === undefined || hit.asset_id === '' ? null : Number(hit.asset_id)
|
||||
const nameOf = (assetId) => {
|
||||
if (assetId === null || nameByAsset === null || nameByAsset === undefined) return null
|
||||
const raw = typeof nameByAsset.get === 'function' ? nameByAsset.get(assetId) : nameByAsset[assetId]
|
||||
const text = raw === null || raw === undefined ? '' : String(raw).trim()
|
||||
return text === '' ? null : text
|
||||
}
|
||||
const name = nameOf(id)
|
||||
if (name !== null) return name + '|' + svcText
|
||||
|
||||
/* ③ 退到服务键:同(资产, 端口)只算一次最高权限 —— 与 service 口径等效,
|
||||
这是"同一主机上的系统权限、应用权限、数据库权限按最高权限只得一次分"(G1)的兜底。 */
|
||||
if (svcText !== '') return svcText
|
||||
|
||||
/* ④ 三条都拿不到(没有 asset_id、没有系统名、target 也解析不出 host):
|
||||
退回**本条命中自己的 id** —— 即"互不相同",各算各的。
|
||||
宁可少封顶也不能错封:把两条无从区分的命中判成"同一个系统"会白白吃掉用户的成果。
|
||||
⚠️ 这里**不能**用 Math.random():同一个 hit 在两次调用(面板 / 报告 / 攻击链)里
|
||||
会拿到不同的键,计分口径就不稳定了。 */
|
||||
return '#hit' + String(hit.id ?? '0')
|
||||
}
|
||||
|
||||
/** 从一组同口径命中里挑"计分的那一条":分值最高,同分取更早记的(id 小的)。 */
|
||||
function pickBestHit(list) {
|
||||
return list.reduce((a, b) => {
|
||||
const pa = Number(a.points) || 0; const pb = Number(b.points) || 0
|
||||
if (pb !== pa) return pb > pa ? b : a
|
||||
return Number(b.id) < Number(a.id) ? b : a
|
||||
}, list[0])
|
||||
}
|
||||
|
||||
/** 旧口径分组(兼容 v0.10 及以前:账号类与数据库类按"同资产同端口"封顶)。 */
|
||||
function legacyCapGroup(code) {
|
||||
const c = String(code || '').trim()
|
||||
if (c === 'web-account-user' || c === 'web-account-admin') return 'service'
|
||||
return SERVICE_CAPPED_POINT_CODES.includes(c) ? 'service' : null
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 读取得分点元数据(code → `{ rule, cap, dedup_scope, points, enabled, builtin, src }`)。
|
||||
* 面板 / 报告 / 攻击链三处共用,避免"同一份规则三处各读一遍、字段各漏一个"。
|
||||
* @param db - 靶标库句柄。
|
||||
*/
|
||||
function loadScoreMeta(db) {
|
||||
return new Map(db.prepare('SELECT code, rule, cap, dedup_scope, points, enabled, builtin, src FROM score_point')
|
||||
.all()
|
||||
.map((r) => [String(r.code), {
|
||||
rule: r.rule === null || r.rule === undefined ? null : Number(r.rule),
|
||||
cap: Number(r.cap) || 0,
|
||||
dedup_scope: r.dedup_scope || 'service',
|
||||
points: Number(r.points) || 0,
|
||||
enabled: r.enabled === null || r.enabled === undefined ? 1 : Number(r.enabled),
|
||||
builtin: Number(r.builtin) === 1,
|
||||
src: r.src === null || r.src === undefined ? null : Number(r.src),
|
||||
}]))
|
||||
}
|
||||
|
||||
/**
|
||||
* 资产 id → 系统名(primary_name),`system` 口径要用它把"同一套系统"归到一起。
|
||||
* @param db - 靶标库句柄。
|
||||
*/
|
||||
function loadAssetNames(db) {
|
||||
return new Map(db.prepare('SELECT id, primary_name FROM asset').all()
|
||||
.filter((a) => a.primary_name).map((a) => [Number(a.id), a.primary_name]))
|
||||
}
|
||||
|
||||
/**
|
||||
* 本条命中的**实际分值** = 档位分值 × 倍率。
|
||||
* · 档位分值:命中自带优先(合并版同一条含多档),缺省回落到得分点默认分值;
|
||||
* · 倍率:G5 数据规模翻倍(超 1 亿条 / 10TB,或控制知识库相关系统)×2、
|
||||
* G6 IPv6 成果 ×3。倍率作用在**权限分**上,所以乘在分值里、随上限一起被 cap 约束
|
||||
* (文档要求"上限仍按对应系统类型的原上限计算,不因倍数突破上限")。
|
||||
*/
|
||||
function hitPointsOf(hit = {}, metaByCode = null) {
|
||||
let base = 0
|
||||
if (hit.points !== null && hit.points !== undefined && hit.points !== '') {
|
||||
base = Number(hit.points) || 0
|
||||
} else {
|
||||
const code = hit.code === null || hit.code === undefined ? null : String(hit.code)
|
||||
if (code !== null && metaByCode !== null && metaByCode !== undefined) {
|
||||
const meta = typeof metaByCode.get === 'function' ? metaByCode.get(code) : metaByCode[code]
|
||||
if (meta !== undefined && meta !== null) base = Number(meta.points) || 0
|
||||
}
|
||||
}
|
||||
const mult = Number(hit.multiplier)
|
||||
return Math.round(base * (Number.isFinite(mult) && mult > 0 ? mult : 1))
|
||||
}
|
||||
|
||||
/**
|
||||
* 这个 target 的主机部分是 IPv6 字面量吗(http://[2001:db8::1]:8080/x、2001:db8::1、[::1]:22)。
|
||||
*
|
||||
* 不能用一条粗糙的字符类正则代替:IPv6 里混着十六进制字母(a-f),
|
||||
* 写成 /^\[[0-9a-f:]+\]/ 这类"只看冒号和十六进制"的写法会把带字母的地址漏判
|
||||
* (实测 2001:db8::1 里的 db8 就被漏掉,G6 的 ×3 完全不生效)。
|
||||
* 所以把主机部分交给 isIpv6() 判定 —— 与 cidrOf / scopeOfIp 用同一份实现。
|
||||
*/
|
||||
function targetHasIpv6Host(target) {
|
||||
const text = String(target || "").trim()
|
||||
if (text === "") return false
|
||||
const bracket = /^[a-z][a-z0-9+.-]*:\/\/(\[[^\]]+\])/i.exec(text)
|
||||
if (bracket !== null) return isIpv6(bracket[1].replace(/^\[|\]$/g, ""))
|
||||
const url = /^[a-z][a-z0-9+.-]*:\/\/([^/?#\s]+)/i.exec(text)
|
||||
const authority = url !== null ? url[1] : (/^([^\s/?#]+)/.exec(text) || [])[1]
|
||||
if (!authority) return false
|
||||
/* 裸写 IPv6 想带端口必须加方括号,所以这里去掉方括号后再尝试剥端口 */
|
||||
const host = authority.replace(/^\[|\]$/g, "").replace(/:\d{1,5}$/, "")
|
||||
return isIpv6(host)
|
||||
}
|
||||
|
||||
/**
|
||||
* 把 G5 / G6 的倍率规则算成倍率值(只对权限分生效,且不突破原上限 —— 由 cap 兜住)。
|
||||
* · `ip_version === 6` 或 target 是 IPv6 字面量 → ×3(G6);
|
||||
* · `data_scale === "large"` → ×2(G5:超 1 亿条 或 10TB);
|
||||
* · `data_scale === "knowledge-base"` → ×2(G5:控制知识库相关系统);
|
||||
* · 两者都命中 → 相乘。文档没写禁止叠加,取对演练方有利的解释并**如实标注原因**。
|
||||
* @param hit - 命中参数(ip_version / data_scale / target)。
|
||||
* @returns `{ multiplier, reasons }`
|
||||
*/
|
||||
function scoreMultiplierOf(hit = {}) {
|
||||
const reasons = []
|
||||
let multiplier = 1
|
||||
const target = String(hit.target || "")
|
||||
const ipv6 = Number(hit.ip_version) === 6 || targetHasIpv6Host(target)
|
||||
|| /(^|\/\/)[0-9a-f]{0,4}:[0-9a-f:]+/i.test(target)
|
||||
if (ipv6) { multiplier *= 3; reasons.push("G6 IPv6 成果 ×3") }
|
||||
const scale = String(hit.data_scale || "").trim().toLowerCase()
|
||||
if (scale === "large") { multiplier *= 2; reasons.push("G5 数据规模超 1 亿条 / 10TB ×2") }
|
||||
else if (scale === "knowledge-base" || scale === "kb") { multiplier *= 2; reasons.push("G5 控制知识库相关系统 ×2") }
|
||||
return { multiplier, reasons }
|
||||
}
|
||||
|
||||
/**
|
||||
* **统一的计分评估**:面板 / 报告 / 攻击链都调这一个函数算出"哪条计分、哪条被封顶"。
|
||||
*
|
||||
* 输入为一组"命中行",输出它们的计分标记。调用方只需保证每行带
|
||||
* `{ id, code, points, asset_id, port, target, self_created }` 与**本条命中的实际分值**
|
||||
* (`points` 字段;不要传得分点默认值 —— 合并版里同一条含多档,传默认值会把哪条计分判反)。
|
||||
*
|
||||
* @param db - 靶标库句柄。
|
||||
* @param rows - 命中行数组。
|
||||
* @param options - `{ meta?, names?, enabledOnly? }`:可复用已读好的元数据;`enabledOnly` 为 true
|
||||
* 时"停用得分点"的命中直接标为不计分(报告与面板口径必须一致)。
|
||||
* @returns `{ byId, items, caps, meta, names, disabledIds }`
|
||||
*/
|
||||
function evaluateScoreBoard(db, rows = [], options = {}) {
|
||||
const meta = options.meta || loadScoreMeta(db)
|
||||
const names = options.names || loadAssetNames(db)
|
||||
const prepared = (rows || []).map((h) => {
|
||||
const code = h.code === null || h.code === undefined ? null : String(h.code)
|
||||
const m = code === null ? undefined : meta.get(code)
|
||||
const nm = h.asset_id === null || h.asset_id === undefined ? null : names.get(Number(h.asset_id))
|
||||
return Object.assign({}, h, {
|
||||
code,
|
||||
/* points 必须是"本条命中的实际分值"(见上方说明) */
|
||||
points: hitPointsOf(h, meta),
|
||||
rule: m === undefined || m.rule === undefined ? null : m.rule,
|
||||
cap: m === undefined ? 0 : m.cap,
|
||||
dedup_scope: m === undefined ? 'service' : m.dedup_scope,
|
||||
cap_group: m === undefined || m.rule === null || m.rule === undefined ? 'code:' + String(code) : 'rule:' + m.rule,
|
||||
rule_cap: m === undefined ? 0 : m.cap,
|
||||
system_key: [nm || '', normalizePort(h.port) ?? parseTargetPort(h.target) ?? ''].join('|'),
|
||||
})
|
||||
})
|
||||
const evaluated = applyScoreCaps(prepared, meta, names)
|
||||
const byId = new Map(evaluated.items.map((x) => [x.id, x]))
|
||||
const disabledIds = new Set()
|
||||
if (options.enabledOnly === true) {
|
||||
for (const h of prepared) {
|
||||
const m = h.code === null ? undefined : meta.get(h.code)
|
||||
if (m !== undefined && Number(m.enabled) !== 1) disabledIds.add(h.id)
|
||||
}
|
||||
}
|
||||
return { byId, items: evaluated.items, caps: evaluated.caps, meta, names, disabledIds }
|
||||
}
|
||||
|
||||
/**
|
||||
* 这条命中为什么不计分(告警 / 界面 / 报告共用一句话,避免三处口径写歪)。
|
||||
* @param hit - 命中行(带 code / target / port / rule / rule_cap / capped_reason_kind)
|
||||
* @param bestPoints - 去重时被哪条压住(该条的分值)
|
||||
*/
|
||||
export function scoreCapReasonText(hit = {}, bestPoints) {
|
||||
const label = serviceLabel(hit)
|
||||
if (hit.capped_reason_kind === 'cap') {
|
||||
return '「' + label + '」这条不计分:'
|
||||
+ (hit.rule === null || hit.rule === undefined ? '' : '规则 ' + hit.rule + ' ')
|
||||
+ '的**累计得分已达该规则上限(' + (Number(hit.rule_cap) || 0) + ' 分)**——同一规则超出上限的部分不再累加。'
|
||||
+ '把精力换到别的规则或别的资产上,不要在已达上限的规则里继续刷。'
|
||||
}
|
||||
return '「' + label + '」这个目标上的权限已经拿满(计分口径:同一目标只算分值最高的那条'
|
||||
+ (bestPoints === undefined || bestPoints === null ? '' : ',+' + bestPoints + ' 分')
|
||||
+ ')——这条按规则不再计分,只作过程留痕;**换目标或换规则推进,不要在同一个目标上刷同类成果**。'
|
||||
}
|
||||
|
||||
/** 兼容旧名(v0.10 及以前叫 serviceCapReason)。 */
|
||||
export const serviceCapReason = scoreCapReasonText
|
||||
|
||||
|
||||
/**
|
||||
* 数据规模的**粗判门槛**:100 万条/行。
|
||||
* 用途已经从「大量敏感信息得分项」改成 G5 翻倍的量级自检 —— 见 addScoreHit 里的警告。
|
||||
* 文档里 G5 的正式门槛是「超 1 亿条 或 10TB」;这里用更低的一档做"有没有写量级"的粗筛,
|
||||
* 低于它会提示核对,但不阻断记分。
|
||||
*/
|
||||
export const SENSITIVE_DATA_MIN_ROWS = 1000000
|
||||
|
||||
/**
|
||||
* 从证据文本里解析数据量(行/条/记录数)。
|
||||
* 支持「120 万条」「1300万行」「1,200,000 条记录」「2.5万行」「1200000 records」。
|
||||
* **只认带量词(条/行/记录/records/rows)或中文量级(亿/万…)的写法**——
|
||||
* 裸数字不认,否则会把口令里的 `123456`、端口号当成数据量。
|
||||
* 解析不出来返回 null(由调用方提示补齐量级,不猜、不编数)。
|
||||
*/
|
||||
export function parseRowCount(evidence) {
|
||||
const text = String(evidence || '')
|
||||
if (text.trim() === '') return null
|
||||
const units = { 亿: 1e8, 千万: 1e7, 百万: 1e6, 十万: 1e5, 万: 1e4, 千: 1e3 }
|
||||
const nums = []
|
||||
/* 「数字 + 单位 + 条/行/记录」:单位是中文量词,或英文 records/rows/entries */
|
||||
const cn = /(\d[\d,]*(?:\.\d+)?)\s*(亿|千万|百万|十万|万|千)?\s*(条|行|记录|数据|records?|rows?|entries)/gi
|
||||
for (const m of text.matchAll(cn)) {
|
||||
const base = Number(String(m[1]).replace(/,/g, ''))
|
||||
if (!Number.isFinite(base)) continue
|
||||
const mult = m[2] === undefined ? 1 : units[m[2]]
|
||||
nums.push(Math.round(base * mult))
|
||||
}
|
||||
if (nums.length > 0) return Math.max(...nums)
|
||||
/* 只写了「导出 120 万」这类(没写条/行)也认,但必须带中文量级 */
|
||||
for (const m of text.matchAll(/(\d[\d,]*(?:\.\d+)?)\s*(亿|千万|百万|十万|万|千)/g)) {
|
||||
const base = Number(String(m[1]).replace(/,/g, ''))
|
||||
if (Number.isFinite(base)) nums.push(Math.round(base * units[m[2]]))
|
||||
}
|
||||
return nums.length === 0 ? null : Math.max(...nums)
|
||||
}
|
||||
|
||||
/** 千分位展示,告警里读数更直观。 */
|
||||
export function formatRows(n) {
|
||||
return Number(n).toLocaleString('en-US')
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ 知识库常量 */
|
||||
|
||||
/** POC 类型:poc=验证性利用、exp=可执行利用、template=nuclei 等模板、script=辅助脚本、payload=载荷。 */
|
||||
const POC_KINDS = ['poc', 'exp', 'script', 'template', 'payload']
|
||||
/** 来源:web=互联网扒的、self=智能体手搓、manual=人写的、nuclei-template=模板库。 */
|
||||
const POC_SOURCES = ['web', 'self', 'manual', 'nuclei-template', 'kb']
|
||||
export { POC_KINDS, POC_SOURCES }
|
||||
|
||||
/** 生成知识库条目的稳定标识:组件 + 编号/标题,便于智能体直接引用。 */
|
||||
export function slugPoc(title, cve) {
|
||||
const t = String(title || '').trim()
|
||||
const c = String(cve || '').trim()
|
||||
/* 标题里往往已经写了 CVE,别再拼一遍(否则 code 会变成 xxx-cve-2023-21839-cve-2023-21839) */
|
||||
const flat = (s) => String(s).toLowerCase().replace(/[^a-z0-9]/g, '')
|
||||
const base = (c !== '' && !flat(t).includes(flat(c))) ? c + ' ' + t : t
|
||||
const slug = base.toLowerCase()
|
||||
.replace(/cve[-_ ]?(\d{4})[-_ ]?(\d+)/g, 'cve-$1-$2')
|
||||
.replace(/[^\w\u4e00-\u9fa5.-]+/g, '-')
|
||||
.replace(/-{2,}/g, '-')
|
||||
.replace(/^-+|-+$/g, '')
|
||||
.slice(0, 80)
|
||||
.replace(/-+$/, '')
|
||||
return slug === '' ? 'poc-' + Date.now() : slug
|
||||
}
|
||||
|
||||
/** 按语言给正文一个合适的文件名(智能体可以直接照着运行)。 */
|
||||
function defaultPocFilename(title, kind, language) {
|
||||
const ext = {
|
||||
python: 'py', py: 'py', go: 'go', java: 'java', bash: 'sh', sh: 'sh', shell: 'sh',
|
||||
js: 'js', node: 'js', php: 'php', ruby: 'rb', powershell: 'ps1', http: 'http', nuclei: 'yaml', yaml: 'yaml',
|
||||
}[String(language || '').toLowerCase()]
|
||||
if (ext) return 'poc.' + ext
|
||||
if (kind === 'template') return 'poc.yaml'
|
||||
return 'poc.txt'
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ 目标命名 */
|
||||
/**
|
||||
* 把目标(IP / URL / C 段)归一化成攻击文件目录名。
|
||||
* · IP 或 ip:port → 只取 IP(同一 IP 的多个端口归一个文件夹)
|
||||
* · URL → 只取 host(去掉协议、端口、路径)
|
||||
* · C 段 10.0.0.0/24 → 10.0.0.0_24
|
||||
*/
|
||||
export function slugTarget(target) {
|
||||
const raw = String(target || '').trim()
|
||||
if (raw === '') return 'unknown'
|
||||
const ipMatch = /^(\d{1,3}(?:\.\d{1,3}){3})(?::\d+)?$/.exec(raw)
|
||||
if (ipMatch !== null) return ipMatch[1]
|
||||
const urlMatch = /^https?:\/\/([^/?#]+)/i.exec(raw)
|
||||
const hostPort = urlMatch !== null ? urlMatch[1] : raw
|
||||
const host = hostPort.replace(/:(\d+)$/, '')
|
||||
return host.replace(/[^\w.\-]/g, '_').replace(/_+$/, '') || 'unknown'
|
||||
}
|
||||
@@ -409,7 +409,9 @@ function scoreMultiplierOf(hit = {}) {
|
||||
let multiplier = 1
|
||||
const target = String(hit.target || "")
|
||||
const ipv6 = Number(hit.ip_version) === 6 || targetHasIpv6Host(target)
|
||||
|| /(^|\/\/)[0-9a-f]{0,4}:[0-9a-f:]+/i.test(target)
|
||||
/* 裸写 IPv6 兜底的正则必须含 ≥2 个冒号:dc01:389 / ad01:8080 这类内网主机名:端口
|
||||
只有一个冒号,旧正则会把它们误判成 IPv6 让成果静默 ×3 */
|
||||
|| /(^|\/\/)(?:\[[0-9a-f:]+\]|[0-9a-f]*(?::[0-9a-f]*){2,})/i.test(target)
|
||||
if (ipv6) { multiplier *= 3; reasons.push("G6 IPv6 成果 ×3") }
|
||||
const scale = String(hit.data_scale || "").trim().toLowerCase()
|
||||
if (scale === "large") { multiplier *= 2; reasons.push("G5 数据规模超 1 亿条 / 10TB ×2") }
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
* 不只是说"哪里不可用",而是直接告诉用户"怎么修"。`problems` 保留为纯文本视图(兼容旧调用方)。
|
||||
*
|
||||
* 判定维度(都是能从技能正文里客观读出来的):
|
||||
* ① 技能文件是否存在、正文能否加载;
|
||||
* ② 必需环境变量(`os.environ["X"]` / `process.env.X`;带默认值的 `os.environ.get("X", "…")` 不算必需);
|
||||
* ① 技能文件是否存在、正文能否加载 —— 只有这个把整条技能标成不可用;
|
||||
* ② 环境变量(`os.environ["X"]` / `process.env.X`;带默认值的 `os.environ.get("X", "…")` 不算);
|
||||
* ③ 正文里引用的本机路径(toolkit / bin / local 下的绝对路径、`$DSH_HOME`、`~/`);
|
||||
* ④ 外部基础设施占位符(如 `<你的VPS_IP>` 没填)。
|
||||
* ②③④ 只记在缺口里。技能正文里写了替代做法,缺工具或缺密钥时仍然可以加载。
|
||||
*
|
||||
* 不判定:语义正确性、权限、目标可达性 —— 那些只有真打一次才知道。
|
||||
*/
|
||||
@@ -53,6 +54,8 @@ export function pathCountsOnThisHost(raw, platform = process.platform, arch = pr
|
||||
const base = String(raw).replace(/\\/g, '/').split('/').pop() || ''
|
||||
if (/\.(md|txt|json|ya?ml|csv)$/i.test(base)) return false
|
||||
const token = (name) => new RegExp('(?:^|[._-])(?:' + name + ')(?:[._-]|$)', 'i').test(base)
|
||||
if (platform === 'win32' && /\.(sh|bash)$/i.test(base)) return false
|
||||
if (platform === 'win32' && /\/\.local\/|\/\.kimi-webbridge\//.test(String(raw).replace(/\\/g, '/'))) return false
|
||||
const isWinName = /\.exe$/i.test(base) || token('windows|win32|win64')
|
||||
const isDarwin = token('darwin|macos')
|
||||
const isLinux = token('linux')
|
||||
@@ -213,6 +216,7 @@ function safeFix(issue) {
|
||||
* @returns `{ name, status: 'available'|'broken'|'unknown', issues, problems, needs_user, checked, shadowed_by? }`
|
||||
* `issues` 是 `{ kind, detail, fix }` 列表(`kind` ∈ file-missing / content-missing /
|
||||
* env-missing / path-missing / placeholder / shadowed),`problems` 是它的 detail 文本视图。
|
||||
* 缺路径、缺密钥、占位符未填都留在 issues 里,不把 status 打成 broken。
|
||||
* status='unknown' 表示"正文读不到,判不了"(例如只有元数据、正文加载失败的远端技能)。
|
||||
*/
|
||||
export function checkSkill(skill, options = {}) {
|
||||
@@ -290,9 +294,10 @@ export function checkSkill(skill, options = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
const blocking = issues.filter((item) => item.kind === 'file-missing')
|
||||
return {
|
||||
name,
|
||||
status: issues.length === 0 ? 'available' : 'broken',
|
||||
status: blocking.length === 0 ? 'available' : 'broken',
|
||||
issues,
|
||||
problems: issues.map((x) => x.detail),
|
||||
needs_user: Array.from(new Set(needsUser)),
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
const SETUP = 'bash $DSH_HOME/redteam/setup.sh --yes'
|
||||
|
||||
/** 完全不知道缺什么时的兜底建议。 */
|
||||
const GENERIC_FIX = '跑 `' + SETUP + '` 补齐工具与配置(幂等,可反复跑;缺的会下载,损坏的会删掉重下),'
|
||||
const GENERIC_FIX = '由用户执行 `' + SETUP + '` 补齐工具与配置(幂等,可反复跑;缺的会下载,损坏的会删掉重下),'
|
||||
+ '改了 `$DSH_HOME/.env` 后重启 `dsh web` 才生效;仍不行就重新安装 redteam 插件再体检一次。'
|
||||
|
||||
/** 工具箱附件实际装了什么。不要写成「缺了就从附件里解出来」。 */
|
||||
@@ -301,7 +301,7 @@ export const SKILL_FIXES = {
|
||||
'fofa-recon': '配 `FOFA_KEY`:<https://fofa.info> 登录 → 个人中心 → API Key。\n'
|
||||
+ '写进 `$DSH_HOME/.env`(`FOFA_KEY=你的key`,`chmod 600`)或临时 `export FOFA_KEY=…`,然后重启 `dsh web` 才在本进程生效;'
|
||||
+ '自测 `curl -s "https://fofa.info/api/v1/info/my?key=$FOFA_KEY"` 要返回 `"error":false`。\n'
|
||||
+ '也可以直接跑 `' + SETUP + '`,由脚本代写并当场校验。',
|
||||
+ '也可以由用户跑 `' + SETUP + '`(脚本代写并当场校验)。',
|
||||
|
||||
'frp-tunnel': '补 `toolkit/frp/frps`、`toolkit/frp/frpc`:跑 `' + SETUP + '`(一次解出两个二进制)。\n'
|
||||
+ 'VPS 侧要 `REDTEAM_VPS_HOST` / `REDTEAM_VPS_KEY`(`$DSH_HOME/.env`),命令前 `set -a; . "$DSH_HOME/.env"; set +a`,'
|
||||
@@ -487,7 +487,7 @@ export function fixesForIssue(issue) {
|
||||
})
|
||||
parts.push('缺环境变量:' + items.join(';') + '。')
|
||||
parts.push('持久化:写进 `$DSH_HOME/.env`(一行一个 `NAME=值`,建议 `chmod 600`),改完必须重启 `dsh web` 当前进程才读得到;'
|
||||
+ '或跑 `' + SETUP + '` 由脚本代写(`FOFA_KEY`、VPS 相关变量它都会引导并当场校验)。')
|
||||
+ '或由用户跑 `' + SETUP + '`(脚本会引导并当场校验 `FOFA_KEY`、VPS 相关变量)。')
|
||||
}
|
||||
} else if (kind === 'placeholder') {
|
||||
const ph = typeof it.placeholder === 'string' && it.placeholder.trim() !== '' ? it.placeholder.trim() : '外部基础设施地址'
|
||||
|
||||
+1002
-152
File diff suppressed because it is too large.
Load diff
+80
-34
@@ -211,13 +211,6 @@ function bindingViewOf(exec) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 子智能体的继承说明(写进返回值,让模型知道为什么它不用再绑定一次)。 */
|
||||
function inheritedHint(exec, id) {
|
||||
const info = sessionInfoOf(exec)
|
||||
if (info.parentId === undefined) return undefined
|
||||
return '本会话是子智能体:靶标 ' + id + ' 继承自父会话(会话隔离生效,不会写到别的靶标库里)。'
|
||||
}
|
||||
|
||||
/** 逗号/空白分隔的清单 → 去重数组。 */
|
||||
function splitList(value) {
|
||||
return String(value || '').split(/[,,\s]+/).map((x) => x.trim()).filter(Boolean)
|
||||
@@ -251,23 +244,6 @@ const text = (value) => [{ type: 'text', text: typeof value === 'string' ? value
|
||||
/** 角色 code 的合法值说明(写进工具 description,模型不用猜)。 */
|
||||
const ROLE_HINT = '角色 code:' + ROLE_ORDER.map((r) => '`' + r + '`(' + ROLE_TITLES[r] + ')').join('、')
|
||||
|
||||
/** 子会话组装角色稿时用:沿父链找到本进程里已绑定的靶标。没有就返回 undefined。 */
|
||||
export function engagementIdForSession(session) {
|
||||
if (!session) return undefined
|
||||
try {
|
||||
const info = sessionInfoOf({ agent: { session } })
|
||||
if (info.id === undefined) return undefined
|
||||
const resolved = resolveRootSession(session)
|
||||
const rootId = resolved.rootId === undefined ? info.id : resolved.rootId
|
||||
const keys = Array.from(new Set([rootId, info.id, ...resolved.chain].filter(Boolean)))
|
||||
for (const key of keys) {
|
||||
const bound = bindings.get(key)
|
||||
if (typeof bound === 'string' && bound.length > 0) return bound
|
||||
}
|
||||
} catch { /* 解析失败就交给 current 指针 */ }
|
||||
return undefined
|
||||
}
|
||||
|
||||
function bindKeysOf(exec) {
|
||||
const { rootId, sessionId, chain } = bindingKeyOf(exec)
|
||||
return Array.from(new Set([rootId, sessionId, ...chain].filter(Boolean)))
|
||||
@@ -310,9 +286,13 @@ function dropReservation(rootId, key) {
|
||||
const map = reservations.get(rootId)
|
||||
if (map === undefined) return false
|
||||
if (key === undefined) {
|
||||
const n = map.size
|
||||
reservations.delete(rootId)
|
||||
return n > 0
|
||||
/* 无 key 时只释放最早的一条(与工具描述一致)——清空整张表会把别的在途预留一起放掉,名额超卖 */
|
||||
let oldestKey = null
|
||||
let oldestAt = Infinity
|
||||
for (const [k, at] of map) {
|
||||
if (at < oldestAt) { oldestAt = at; oldestKey = k }
|
||||
}
|
||||
return oldestKey !== null ? map.delete(oldestKey) : false
|
||||
}
|
||||
return map.delete(key)
|
||||
}
|
||||
@@ -501,10 +481,13 @@ export function apply(ctx) {
|
||||
if (existsSync(envFile)) {
|
||||
const { readFileSync } = await import('node:fs')
|
||||
for (const line of readFileSync(envFile, 'utf8').split('\n')) {
|
||||
const m = /^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/.exec(line)
|
||||
/* 兼容 shell 习惯写法:`export KEY=value`;未加引号的行内注释(`KEY=v # 备注`)剥掉 */
|
||||
const m = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/.exec(line)
|
||||
if (m === null) continue
|
||||
const key = m[1]
|
||||
const value = m[2].trim().replace(/^["']|["']$/g, '')
|
||||
let raw = m[2].trim()
|
||||
if (!/^["']/.test(raw)) raw = raw.replace(/\s+#.*$/, '')
|
||||
const value = raw.replace(/^["']|["']$/g, '').trim()
|
||||
if (value === '') continue
|
||||
envFileKeys.push(key)
|
||||
if (effectiveEnv[key] === undefined || effectiveEnv[key] === '') effectiveEnv[key] = value
|
||||
@@ -618,6 +601,8 @@ export function apply(ctx) {
|
||||
}
|
||||
summaries = redteamSummariesForCheck(summaries, bundledSkills, scoped)
|
||||
const wanted = summaries.filter((s) => only.length === 0 || only.includes(s.name))
|
||||
/* include 时只体检点名的技能:否则 ok 被无关 broken 拖成 false,模型会误以为目标技能坏了 */
|
||||
const toCheck = only.length > 0 ? wanted : summaries
|
||||
unknownIncludes = only.filter((n) => !summaries.some((s) => s.name === n))
|
||||
const rootsWith = new Map()
|
||||
for (const x of summaries) {
|
||||
@@ -626,7 +611,7 @@ export function apply(ctx) {
|
||||
if (!rootsWith.has(x.name)) rootsWith.set(x.name, [])
|
||||
if (!rootsWith.get(x.name).includes(dir)) rootsWith.get(x.name).push(dir)
|
||||
}
|
||||
for (const summary of summaries) {
|
||||
for (const summary of toCheck) {
|
||||
let def
|
||||
if (!fromBundle && skills && typeof skills.get === 'function') {
|
||||
try { def = await skills.get(summary.name) } catch { def = undefined }
|
||||
@@ -697,15 +682,18 @@ export function apply(ctx) {
|
||||
|
||||
const summary = summarizeSkills(checked)
|
||||
return JSON.stringify({
|
||||
ok: allBroken.length === 0 && missing.length === 0,
|
||||
include: only.length > 0 ? { requested: only, unknown: unknownIncludes } : undefined,
|
||||
all_checked: { total: checked.length, broken: allBroken.length, available: allAvailable.length },
|
||||
/* include 模式:ok 只反映点名技能的体检结果;测绘 key/VPS 等 missing 与此无关,降为参考不拖 ok */
|
||||
ok: allBroken.length === 0 && (only.length > 0 || missing.length === 0),
|
||||
include: only.length > 0 ? { requested: only, unknown: unknownIncludes, note: 'ok 只覆盖点名的技能;onboarding.missing 是全局参考,不影响本次 ok' } : undefined,
|
||||
all_checked: { registry_total: summaries.length, checked: checked.length, broken: allBroken.length, available: allAvailable.length },
|
||||
onboarding,
|
||||
platform: plat,
|
||||
summary,
|
||||
checked: checked.length,
|
||||
available: available.map((s) => s.name),
|
||||
broken: broken.map((s) => ({ name: s.name, problems: s.problems, needs_user: s.needs_user })),
|
||||
broken: broken.map((s) => ({ name: s.name, problems: s.problems, needs_user: s.needs_user,
|
||||
fixes: (s.issues || []).map((i) => i && i.fix).filter(Boolean),
|
||||
fix_note: '修复步骤由用户执行(或经「环境适配」页);不要由你下载/安装工具。' })),
|
||||
unknown: checked.filter((s) => s.status === 'unknown').map((s) => s.name),
|
||||
toolkit: { dir: toolkit, exists: existsSync(toolkit), entries: toolkitEntries, hint: toolkitHint },
|
||||
skills_root_hint: '这里只检查红队技能。官方技能在 $DSH_HOME/skills,不按红队工具路径判不可用。',
|
||||
@@ -1120,6 +1108,64 @@ export function apply(ctx) {
|
||||
},
|
||||
})))
|
||||
|
||||
ctx.tools.register(withStructuredErrors(defineTool({
|
||||
name: 'redteam_shot_add',
|
||||
description: '登记一张证据截图:把图片拷进靶标目录并关联到得分点/命中(面板展开得分点即可看图,报告里也会嵌入)。批量得分点(如终端权限)每个得分点最多展示 3 张代表图,不必逐台截图。',
|
||||
parameters: {
|
||||
engagement: { type: 'string' },
|
||||
agent: AGENT_PARAM,
|
||||
path: { type: 'string', description: '图片在本机的路径(相对靶标目录或绝对路径);与 data_base64 二选一' },
|
||||
data_base64: { type: 'string', description: '图片内容(base64,可带 data: 前缀);截图工具没落盘时用这个' },
|
||||
label: { type: 'string', description: '图片说明,例如「域控 WEB-SHDC1 atexec 回显 nt authority\\system」' },
|
||||
kind: { type: 'string', description: 'screenshot(现场截图,默认)| card(由记录生成的证据摘录卡,报告里会标注)' },
|
||||
point_code: { type: 'string', description: '关联的得分点 code,如 terminal-access / central-system' },
|
||||
hit_id: { type: 'number', description: '关联到具体某条得分命中(score_hit id);给了它这张图就只挂在那一条上' },
|
||||
asset_id: { type: 'number' },
|
||||
target: { type: 'string', description: '这张图对应的目标(IP / URL)' },
|
||||
note: { type: 'string', description: '补充说明:这张图证明了什么' },
|
||||
source_ref: { type: 'string', description: '原始来源:截图的落盘路径或 runs/ 下的证据文件' },
|
||||
captured_at: { type: 'string', description: '截图时间(ISO),缺省用当前时间' },
|
||||
},
|
||||
output: { schema: { type: 'string' }, render: (_args, value) => text(value) },
|
||||
async execute(args, exec) {
|
||||
const id = resolveEngagement(store, exec, args.engagement)
|
||||
const result = store.addShot(id, { ...args, engagement: undefined, agent: agentOf(args) })
|
||||
return JSON.stringify({ ok: true, engagement: id, ...result }, null, 2)
|
||||
},
|
||||
})))
|
||||
|
||||
ctx.tools.register(withStructuredErrors(defineTool({
|
||||
name: 'redteam_shot_list',
|
||||
description: '列出已登记的证据截图(含所属得分点、目标、类型、落盘文件)。',
|
||||
parameters: {
|
||||
engagement: { type: 'string' },
|
||||
point_code: { type: 'string' },
|
||||
hit_id: { type: 'number' },
|
||||
asset_id: { type: 'number' },
|
||||
},
|
||||
output: { schema: { type: 'string' }, render: (_args, value) => text(value) },
|
||||
async execute(args, exec) {
|
||||
const id = resolveEngagement(store, exec, args.engagement)
|
||||
return JSON.stringify({ ok: true, engagement: id, ...store.listShots(id, {
|
||||
point_code: args.point_code, hit_id: args.hit_id, asset_id: args.asset_id,
|
||||
}) }, null, 2)
|
||||
},
|
||||
})))
|
||||
|
||||
ctx.tools.register(withStructuredErrors(defineTool({
|
||||
name: 'redteam_shot_delete',
|
||||
description: '删除一张证据截图(连同磁盘文件)。',
|
||||
parameters: {
|
||||
engagement: { type: 'string' },
|
||||
id: { type: 'number', required: true, description: 'shot id(redteam_shot_list 里返回的 id)' },
|
||||
},
|
||||
output: { schema: { type: 'string' }, render: (_args, value) => text(value) },
|
||||
async execute(args, exec) {
|
||||
const eng = resolveEngagement(store, exec, args.engagement)
|
||||
return JSON.stringify({ ok: true, engagement: eng, ...store.deleteShot(eng, args.id) }, null, 2)
|
||||
},
|
||||
})))
|
||||
|
||||
ctx.tools.register(withStructuredErrors(defineTool({
|
||||
name: 'redteam_credential_list',
|
||||
description: '列出已收集的凭据(含明文 secret_value),用于凭据复用与横向移动。',
|
||||
|
||||
+2
-2
@@ -601,7 +601,7 @@ async function handleSkillOp(ctx, request) {
|
||||
cached: availability.cached,
|
||||
broken: Array.from(availability.byName.values()).filter((x) => x.status === 'broken')
|
||||
.map((x) => ({ name: x.name, problems: x.problems, needs_user: x.needs_user })),
|
||||
note: '可用性 = 技能文件存在 + 正文能加载 + 必需环境变量已设置 + 正文引用的本机路径存在 + 没有未填的基础设施占位符。',
|
||||
note: '可用性 = 技能文件存在且正文能加载。缺工具、缺密钥、VPS 占位符记在缺口里,不把整条技能标成不可用。',
|
||||
},
|
||||
bySource: Array.from(bySource, ([k, n]) => ({ key: k, n })).sort((a, b) => b.n - a.n),
|
||||
byDir: Array.from(byDir, ([k, n]) => ({ key: k, n })).sort((a, b) => b.n - a.n),
|
||||
@@ -704,7 +704,7 @@ function handleSkillOpFromPluginDir(request) {
|
||||
cached: false,
|
||||
broken: Array.from(byName.values()).filter((x) => x.status === 'broken')
|
||||
.map((x) => ({ name: x.name, problems: x.problems, needs_user: x.needs_user })),
|
||||
note: '按本包技能文件自检(含环境适配 config.json)。工具路径跟随 $DSH_HOME,不因示例路径或 VPS 占位符把整条技能标为不可用;缺必需密钥(如 FOFA_KEY)时仍会标为不可用。',
|
||||
note: '按本包技能文件自检(含环境适配 config.json)。工具路径、密钥和 VPS 占位符只记在缺口里,不把整条技能标成不可用。',
|
||||
},
|
||||
bySource: [{ key: 'plugin', n: items.length }],
|
||||
byDir: [{ key: dir, n: items.length }],
|
||||
|
||||
+36
-4
@@ -3,8 +3,26 @@ import { randomUUID } from "node:crypto";
|
||||
/** Region gate and other hard stops must not trigger auto-continue. */
|
||||
const HARD_STOP = /不行[,,]\s*这是严令禁止的/u;
|
||||
|
||||
const REFUSAL =
|
||||
/(?:^|[\s。!?!?\n])(?:抱歉|对不起|无法理解但|我理解但|出于(?:安全|合规)|无法(?:协助|帮助|提供|完成|直接)|不能(?:帮助|协助|提供|直接|进行|参与|为您|为你)?|(?:这个|这)?我(?:不能|无法|不会|不做|做不了|不参与)|不予(?:支持|提供)|未授权攻击|I\s*(?:can't|cannot|won't|will not)|unable\s+to\s+(?:assist|help|comply)|sorry[,.\s]|(?:decline|refuse)\s+to\s+(?:assist|help|comply)|(?:don'?t|do\s+not)\s+(?:do|perform|help\s+with)\s+this)/iu;
|
||||
// M10: 抱歉 / 对不起 / 不好意思 / sorry 单独出现不算拒绝(e.g. "抱歉让你久等" / "sorry about that")。
|
||||
// 要求它们在近邻窗口内(汉字 30 字 / 英文 80 字)跟一个拒绝动词,才判定为拒答。
|
||||
// 其他独立的拒绝词条(无法协助、I can't、unable to assist 等)继续独立命中。
|
||||
const REFUSAL = new RegExp(
|
||||
"(?:^|[\\s。!?!?\\n])(?:" +
|
||||
"(?:抱歉|对不起|不好意思)[^\\n]{0,30}?(?:我?(?:无法|不能|不会|不便|不方便|不予|做不了|不参与)|无法(?:协助|帮助|提供|完成)|不能(?:协助|帮助|提供|完成)|拒绝)|" +
|
||||
"sorry[\\s,.][^\\n]{0,80}?(?:cannot|can'?t|won'?t|will\\s+not|unable\\s+to|not\\s+(?:able|allowed)|decline|refuse)|" +
|
||||
"无法理解但|我理解但|出于(?:安全|合规)|" +
|
||||
"无法(?:协助|帮助|提供|完成|直接)|" +
|
||||
"不能(?:帮助|协助|提供|直接|进行|参与|为您|为你)|" +
|
||||
"(?:这个|这)?我(?:不能|无法|不会|不做|做不了|不参与)|" +
|
||||
"不予(?:支持|提供)|" +
|
||||
"未授权攻击|" +
|
||||
"I\\s*(?:can'?t|cannot|won'?t|will\\s+not)|" +
|
||||
"unable\\s+to\\s+(?:assist|help|comply)|" +
|
||||
"(?:decline|refuse)\\s+to\\s+(?:assist|help|comply)|" +
|
||||
"(?:don'?t|do\\s+not)\\s+(?:do|perform|help\\s+with)\\s+this" +
|
||||
")",
|
||||
"iu"
|
||||
);
|
||||
|
||||
export function lastAssistantText(events) {
|
||||
const list = Array.isArray(events) ? events : [];
|
||||
@@ -39,8 +57,7 @@ export function makeRecoverMessage(text) {
|
||||
role: "user",
|
||||
content: [{ type: "text", text: body }],
|
||||
source: {
|
||||
kind: "plugin",
|
||||
plugin: "dsh-purge",
|
||||
kind: "dsh-purge",
|
||||
form: "notice",
|
||||
summary: "refusal-recover",
|
||||
},
|
||||
@@ -71,6 +88,20 @@ export function installRefusalRecover(ctx, options = {}) {
|
||||
? options.getConfig
|
||||
: () => ({ enabled: true, maxPerTurn: 2, recoverText: "" });
|
||||
const bySession = new Map();
|
||||
// 没有 session/removed 事件挂钩,长开进程 bySession 累积不释放。
|
||||
// Map 插入顺序 FIFO:超过 200 淘汰最早 50 条。
|
||||
const SESSION_CAP = 200;
|
||||
const SESSION_EVICT = 50;
|
||||
|
||||
function evictIfOverflow() {
|
||||
if (bySession.size < SESSION_CAP) return;
|
||||
let i = 0;
|
||||
for (const k of bySession.keys()) {
|
||||
if (i >= SESSION_EVICT) break;
|
||||
bySession.delete(k);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
function listen(event, handler) {
|
||||
if (typeof ctx?.on !== "function") return null;
|
||||
@@ -107,6 +138,7 @@ export function installRefusalRecover(ctx, options = {}) {
|
||||
let slot = bySession.get(sid);
|
||||
if (!slot || slot.turn !== turn) {
|
||||
slot = { turn, count: 0, lastKey: "" };
|
||||
evictIfOverflow();
|
||||
bySession.set(sid, slot);
|
||||
}
|
||||
if (slot.lastKey === key) return;
|
||||
|
||||
+82
-11
@@ -33,6 +33,11 @@ function spawnEnv() {
|
||||
for (const key of Object.keys(env)) {
|
||||
if (key.toUpperCase() === "ELECTRON_RUN_AS_NODE") delete env[key];
|
||||
}
|
||||
// [dsh-purge-fix 2026-10-09] 从 explorer 继承的 env 常缺 DSH_PROFILE
|
||||
// (WM_SETTINGCHANGE broadcast 不刷新存活很久的 explorer)。helper relaunch
|
||||
// 时如果不兜底,新 Electron → host 子进程继续缺,报 "cannot determine the
|
||||
// boot profile" host crash → dsh-purge 插件没 activate → inject 全断。
|
||||
if (!env.DSH_PROFILE) env.DSH_PROFILE = "desktop";
|
||||
return env;
|
||||
}
|
||||
|
||||
@@ -336,7 +341,15 @@ function relaunchDesktop() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const child = spawn(info.execPath, Array.isArray(info.argv) ? info.argv : [], {
|
||||
// [dsh-purge-fix 2026-10-09] 复用 Electron 自带的 --updated argv 分支:
|
||||
// main.js:11256 process.argv.includes("--updated") → raiseAfterUpdate=true
|
||||
// → enterWorkspace 时 window.moveTop() + window.focus() 内部强制前台。
|
||||
// 比外部 PS SetForegroundWindow 可靠得多 (Win11 前台保护只挡外部进程)。
|
||||
const baseArgv = Array.isArray(info.argv) ? info.argv.slice() : [];
|
||||
if (process.platform === "win32" && !baseArgv.includes("--updated")) {
|
||||
baseArgv.push("--updated");
|
||||
}
|
||||
const child = spawn(info.execPath, baseArgv, {
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
cwd: info.cwd || process.cwd(),
|
||||
@@ -346,12 +359,78 @@ function relaunchDesktop() {
|
||||
});
|
||||
child.on("error", () => process.exit(1));
|
||||
child.unref();
|
||||
log("relaunched via execPath");
|
||||
log("relaunched via execPath (argv=" + JSON.stringify(baseArgv) + ")");
|
||||
|
||||
// [dsh-purge-fix 2026-10-09] Windows: 新 Electron 从 detached helper spawn,
|
||||
// Windows 焦点规则让它跑在后台。helper 已经不是前台(老 Electron 被 kill 了),
|
||||
// 直接 SetForegroundWindow 会被 Windows 静默 reject。
|
||||
// 三重 trick 强推前台:
|
||||
// 1) keybd_event 发送虚拟 Alt key — 模拟用户输入,解除 foreground lock
|
||||
// 2) AttachThreadInput attach 当前前台线程的 input queue — 继承前台权限
|
||||
// 3) ShowWindow(SW_RESTORE) + BringWindowToTop + SetForegroundWindow
|
||||
if (process.platform === "win32") {
|
||||
const exeLiteral = info.execPath.replace(/'/g, "''");
|
||||
const psScript =
|
||||
"$ErrorActionPreference='SilentlyContinue';" +
|
||||
"$sig=@'\n" +
|
||||
"[DllImport(\"user32.dll\")] public static extern bool SetForegroundWindow(IntPtr h);\n" +
|
||||
"[DllImport(\"user32.dll\")] public static extern bool ShowWindow(IntPtr h,int c);\n" +
|
||||
"[DllImport(\"user32.dll\")] public static extern bool BringWindowToTop(IntPtr h);\n" +
|
||||
"[DllImport(\"user32.dll\")] public static extern IntPtr GetForegroundWindow();\n" +
|
||||
"[DllImport(\"user32.dll\")] public static extern uint GetWindowThreadProcessId(IntPtr h,out uint pid);\n" +
|
||||
"[DllImport(\"kernel32.dll\")] public static extern uint GetCurrentThreadId();\n" +
|
||||
"[DllImport(\"user32.dll\")] public static extern bool AttachThreadInput(uint a,uint b,bool f);\n" +
|
||||
"[DllImport(\"user32.dll\")] public static extern void keybd_event(byte k,byte s,uint f,int e);\n" +
|
||||
"'@;" +
|
||||
"$t=Add-Type -MemberDefinition $sig -Name W -Namespace U -PassThru;" +
|
||||
"[void]$t::keybd_event(0x12,0,0,0);" +
|
||||
"[void]$t::keybd_event(0x12,0,2,0);" +
|
||||
"for($i=0;$i -lt 25;$i++){" +
|
||||
" Start-Sleep -Milliseconds 300;" +
|
||||
" $p=Get-Process | Where-Object {$_.Path -eq '" + exeLiteral + "' -and $_.MainWindowHandle -ne 0} | Select-Object -First 1;" +
|
||||
" if($p){" +
|
||||
" $h=$p.MainWindowHandle;" +
|
||||
" $fg=$t::GetForegroundWindow();" +
|
||||
" $pid2=0;" +
|
||||
" $fgTid=$t::GetWindowThreadProcessId($fg,[ref]$pid2);" +
|
||||
" $curTid=$t::GetCurrentThreadId();" +
|
||||
" [void]$t::AttachThreadInput($curTid,$fgTid,$true);" +
|
||||
" [void]$t::ShowWindow($h,9);" +
|
||||
" [void]$t::BringWindowToTop($h);" +
|
||||
" [void]$t::SetForegroundWindow($h);" +
|
||||
" [void]$t::AttachThreadInput($curTid,$fgTid,$false);" +
|
||||
" break;" +
|
||||
" }" +
|
||||
"}";
|
||||
try {
|
||||
const ps = spawn("powershell.exe", [
|
||||
"-NoProfile", "-WindowStyle", "Hidden", "-ExecutionPolicy", "Bypass",
|
||||
"-Command", psScript,
|
||||
], { detached: true, stdio: "ignore", windowsHide: true, shell: false });
|
||||
ps.unref();
|
||||
log("spawned ps bring-to-front helper (keybd+attach+setfg)");
|
||||
} catch (err) {
|
||||
log("ps bring-to-front spawn failed: " + String(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let asarReleased = true;
|
||||
if (info.killApp) {
|
||||
await sleep(400);
|
||||
// #85: 先杀 Electron,再 sleep + cleanup。原顺序 sleep 400ms 开头 →
|
||||
// host 已经 exit → Electron 还活着跑旧 close 回调弹 crash dialog。
|
||||
// 新顺序:立刻 kill (host 这边 killInstallElectronSync 已经杀过,这里兜底),
|
||||
// Electron 死得越快,旧回调越没机会跑。
|
||||
if (process.platform === "darwin") {
|
||||
await quitDarwinDesktop(info.execPath);
|
||||
} else if (process.platform === "win32") {
|
||||
killOtherDesktopProcesses(process.pid);
|
||||
await sleep(500);
|
||||
// 二次保险:再杀一次,防第一次漏掉的 pid
|
||||
killOtherDesktopProcesses(process.pid);
|
||||
} else {
|
||||
await quitPosixDesktop(info.execPath);
|
||||
}
|
||||
for (const dir of cleanup) rmTree(dir);
|
||||
if (info.helper) {
|
||||
try {
|
||||
@@ -360,14 +439,6 @@ if (info.killApp) {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
if (process.platform === "darwin") {
|
||||
await quitDarwinDesktop(info.execPath);
|
||||
} else if (process.platform === "win32") {
|
||||
killOtherDesktopProcesses(process.pid);
|
||||
await sleep(500);
|
||||
} else {
|
||||
await quitPosixDesktop(info.execPath);
|
||||
}
|
||||
if (info.asar) asarReleased = await releaseSealedAsar(info.asar, info.execPath);
|
||||
} else {
|
||||
const gone = await waitPidGone(info.pid);
|
||||
|
||||
+24
-15
@@ -143,20 +143,6 @@ function isSubagentHeader(header) {
|
||||
return header.origin === "subagent" || (header.delegationDepth ?? 0) > 0;
|
||||
}
|
||||
|
||||
export function climbToMain(startId, getHeader) {
|
||||
let currentId = startId;
|
||||
const seen = new Set();
|
||||
while (currentId && !seen.has(currentId)) {
|
||||
seen.add(currentId);
|
||||
const header = getHeader(currentId);
|
||||
if (!isSubagentHeader(header) || !header?.parentSession) {
|
||||
return currentId;
|
||||
}
|
||||
currentId = header.parentSession;
|
||||
}
|
||||
return startId;
|
||||
}
|
||||
|
||||
export function pendingInboxInserts(events) {
|
||||
const list = Array.isArray(events) ? events : [];
|
||||
let lastEnd = -1;
|
||||
@@ -553,7 +539,9 @@ function clearModelHistory(session, text, fromSeq = 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
async function rewindOneSession(ctx, controller, sessionId, options = {}) {
|
||||
const rewindLocks = new Map();
|
||||
|
||||
async function doRewindOneSession(ctx, controller, sessionId, options = {}) {
|
||||
let log = await readSessionLog(ctx, sessionId);
|
||||
if (lastOpenTurn(log.events)) {
|
||||
try { ignoreSettled(controller.cancel?.({ sessionId })); } catch { /* ignore */ }
|
||||
@@ -585,6 +573,27 @@ async function rewindOneSession(ctx, controller, sessionId, options = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
async function rewindOneSession(ctx, controller, sessionId, options = {}) {
|
||||
const key = String(sessionId || "");
|
||||
if (!key) return doRewindOneSession(ctx, controller, sessionId, options);
|
||||
const prev = rewindLocks.get(key) || Promise.resolve();
|
||||
const next = prev.then(async () => {
|
||||
try {
|
||||
return await doRewindOneSession(ctx, controller, sessionId, options);
|
||||
} finally {
|
||||
if (rewindLocks.get(key) === next) rewindLocks.delete(key);
|
||||
}
|
||||
}, async () => {
|
||||
try {
|
||||
return await doRewindOneSession(ctx, controller, sessionId, options);
|
||||
} finally {
|
||||
if (rewindLocks.get(key) === next) rewindLocks.delete(key);
|
||||
}
|
||||
});
|
||||
rewindLocks.set(key, next);
|
||||
return next;
|
||||
}
|
||||
|
||||
export async function analyzeRewind(ctx, sessionId) {
|
||||
if (!sessionId) return { ok: false, error: "没有当前会话" };
|
||||
try {
|
||||
|
||||
+94
-49
@@ -1,5 +1,4 @@
|
||||
import fs from "node:fs";
|
||||
import { promises as fsp } from "node:fs";
|
||||
import fs, { promises as fsp } from "node:fs";
|
||||
import path from "node:path";
|
||||
import {
|
||||
findDshHome,
|
||||
@@ -11,13 +10,15 @@ import {
|
||||
readPromptInjectFileSync,
|
||||
hashOverride,
|
||||
defaultOverrideHash,
|
||||
atomicWriteFile,
|
||||
atomicCopyFile,
|
||||
} from "./core.js";
|
||||
import { modePromptText } from "./identity.js";
|
||||
|
||||
const RULE_ID_RE = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/;
|
||||
const MAX_RULE_BYTES = 256 * 1024;
|
||||
const MAX_NAME_LENGTH = 64;
|
||||
export const RULE_TARGETS = ["AGENTS.md", "CLAUDE.md"];
|
||||
const BACKUP_SUFFIX = ".dsh-purge-rule.bak";
|
||||
|
||||
export { findDshHome };
|
||||
|
||||
@@ -78,7 +79,25 @@ export async function readRuleMeta(dshHome, id) {
|
||||
export async function writeRuleMeta(dshHome, id, meta) {
|
||||
if (!validRuleId(id)) throw new Error(`invalid rule id: ${id}`);
|
||||
await fsp.mkdir(rulesDir(dshHome), { recursive: true });
|
||||
await fsp.writeFile(ruleMetaPath(dshHome, id), JSON.stringify(normalizeMeta(id, meta), null, 2), "utf8");
|
||||
await atomicWriteFile(ruleMetaPath(dshHome, id), JSON.stringify(normalizeMeta(id, meta), null, 2));
|
||||
}
|
||||
|
||||
function readRuleContentSync(dshHome, id) {
|
||||
try {
|
||||
return fs.readFileSync(rulePath(dshHome, id), "utf8");
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function collectRuleContents(dshHome) {
|
||||
const listed = await listRules(dshHome);
|
||||
const contents = new Set();
|
||||
for (const r of listed) {
|
||||
const c = readRuleContentSync(dshHome, r.id);
|
||||
if (c !== null) contents.add(c);
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
|
||||
export async function listRules(dshHome) {
|
||||
@@ -120,10 +139,40 @@ export async function saveRule(dshHome, id, content, meta) {
|
||||
throw new Error("rule too large (max 256KB)");
|
||||
}
|
||||
await fsp.mkdir(rulesDir(dshHome), { recursive: true });
|
||||
await fsp.writeFile(rulePath(dshHome, id), content, "utf8");
|
||||
await writeRuleMeta(dshHome, id, meta);
|
||||
if ((await readActive(dshHome)) === id) {
|
||||
await activateRule(dshHome, id);
|
||||
|
||||
const rulePathStr = rulePath(dshHome, id);
|
||||
const metaPathStr = ruleMetaPath(dshHome, id);
|
||||
let prevRule = null;
|
||||
let prevMeta = null;
|
||||
try { prevRule = await fsp.readFile(rulePathStr, "utf8"); } catch { /* 新 rule */ }
|
||||
try { prevMeta = await fsp.readFile(metaPathStr, "utf8"); } catch { /* 新 rule */ }
|
||||
|
||||
let wroteRule = false;
|
||||
let wroteMeta = false;
|
||||
try {
|
||||
await atomicWriteFile(rulePathStr, content);
|
||||
wroteRule = true;
|
||||
await writeRuleMeta(dshHome, id, meta);
|
||||
wroteMeta = true;
|
||||
if ((await readActive(dshHome)) === id) {
|
||||
await activateRule(dshHome, id);
|
||||
}
|
||||
} catch (e) {
|
||||
if (wroteRule) {
|
||||
try {
|
||||
if (prevRule === null) {
|
||||
await fsp.unlink(rulePathStr).catch(() => {});
|
||||
} else {
|
||||
await atomicWriteFile(rulePathStr, prevRule);
|
||||
}
|
||||
} catch { /* 回滚失败,原错继续抛 */ }
|
||||
}
|
||||
if (wroteMeta && prevMeta !== null) {
|
||||
try { await atomicWriteFile(metaPathStr, prevMeta); } catch { /* ignore */ }
|
||||
} else if (wroteMeta && prevMeta === null) {
|
||||
try { await fsp.unlink(metaPathStr).catch(() => {}); } catch { /* ignore */ }
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,26 +211,6 @@ export async function setActive(dshHome, id) {
|
||||
await fsp.writeFile(stateFile(dshHome), JSON.stringify({ active: id }, null, 2), "utf8");
|
||||
}
|
||||
|
||||
export function activeRuleId(dshHome) {
|
||||
try {
|
||||
const parsed = JSON.parse(fs.readFileSync(stateFile(dshHome), "utf8"));
|
||||
const id = parsed?.active;
|
||||
return validRuleId(id) ? id : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function activeRuleText(dshHome) {
|
||||
const id = activeRuleId(dshHome);
|
||||
if (!id) return "";
|
||||
try {
|
||||
return fs.readFileSync(rulePath(dshHome, id), "utf8");
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 本进程框内提交 > $DSH_HOME/prompt-inject.md > 加密槽。
|
||||
* 规则集只改 agents 目标文件,不参与 system 注入链(#74 磁盘与 UI/注入一致)。
|
||||
@@ -209,21 +238,22 @@ export function ensureOperatorBody(dshHome) {
|
||||
return resolved.text || normalizeOverride(hungOperatorPrompt()) || "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂到 Cordis system 段的正文:与 resolveInjectText 同源。
|
||||
* redteam=true 时去掉 CTF 块;不再单独走规则集分支(规则集 ≠ 操作者提示词)。
|
||||
*/
|
||||
export function resolveModeInject(dshHome, redteam) {
|
||||
const resolved = resolveInjectText(dshHome);
|
||||
if (!resolved.text) return "";
|
||||
return modePromptText(resolved.text, Boolean(redteam));
|
||||
}
|
||||
|
||||
export async function activateRule(dshHome, id) {
|
||||
const content = await readRule(dshHome, id);
|
||||
if (content === null) throw new Error(`rule not found: ${id}`);
|
||||
const meta = await readRuleMeta(dshHome, id);
|
||||
await fsp.writeFile(targetPath(dshHome, meta.target), content, "utf8");
|
||||
const target = targetPath(dshHome, meta.target);
|
||||
const backup = `${target}${BACKUP_SUFFIX}`;
|
||||
if (!fs.existsSync(backup)) {
|
||||
try {
|
||||
const existing = await fsp.readFile(target, "utf8");
|
||||
const ruleContents = await collectRuleContents(dshHome);
|
||||
if (!ruleContents.has(existing)) {
|
||||
await atomicCopyFile(target, backup);
|
||||
}
|
||||
} catch { /* target 不存在 → 无需备份 */ }
|
||||
}
|
||||
await atomicWriteFile(target, content);
|
||||
await setActive(dshHome, id);
|
||||
return meta;
|
||||
}
|
||||
@@ -245,26 +275,41 @@ export async function resetToOriginal(dshHome) {
|
||||
const active = await readActive(dshHome);
|
||||
const removed = [];
|
||||
const skipped = [];
|
||||
const restored = [];
|
||||
|
||||
for (const target of RULE_TARGETS) {
|
||||
const fp = targetPath(dshHome, target);
|
||||
const bak = `${fp}${BACKUP_SUFFIX}`;
|
||||
if (!fs.existsSync(bak)) continue;
|
||||
try {
|
||||
await atomicCopyFile(bak, fp);
|
||||
await fsp.unlink(bak);
|
||||
restored.push(fp);
|
||||
} catch { /* restore 失败,fall through 到老逻辑 */ }
|
||||
}
|
||||
|
||||
if (active !== null) {
|
||||
const meta = await readRuleMeta(dshHome, active);
|
||||
const ruleContent = await readRule(dshHome, active);
|
||||
const fp = targetPath(dshHome, meta.target);
|
||||
try {
|
||||
const fileContent = await fsp.readFile(fp, "utf8");
|
||||
if (ruleContent !== null && fileContent === ruleContent) {
|
||||
await fsp.unlink(fp);
|
||||
removed.push(fp);
|
||||
} else {
|
||||
skipped.push(fp);
|
||||
if (!restored.includes(fp)) {
|
||||
const ruleContent = await readRule(dshHome, active);
|
||||
try {
|
||||
const fileContent = await fsp.readFile(fp, "utf8");
|
||||
if (ruleContent !== null && fileContent === ruleContent) {
|
||||
await fsp.unlink(fp);
|
||||
removed.push(fp);
|
||||
} else {
|
||||
skipped.push(fp);
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
try {
|
||||
await fsp.unlink(stateFile(dshHome));
|
||||
} catch {
|
||||
}
|
||||
return { removed, skipped };
|
||||
return { removed, skipped, restored };
|
||||
}
|
||||
|
||||
export async function rulesStatus(dshHome) {
|
||||
|
||||
+31
-14
@@ -2,7 +2,8 @@ import { promises as fsp } from "node:fs";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { findDshHome } from "./core.js";
|
||||
import crypto from "node:crypto";
|
||||
import { findDshHome, atomicWriteFile } from "./core.js";
|
||||
import { extractZipArchive, listZipFile } from "./zip-extract.js";
|
||||
|
||||
export { findDshHome };
|
||||
@@ -14,6 +15,7 @@ const MAX_ARCHIVE_BYTES = 12 * 1024 * 1024;
|
||||
const MAX_IMPORT_FILES = 200;
|
||||
const MAX_DESCRIPTION = 500;
|
||||
const SKIP_COPY_NAMES = new Set([".", "..", ".system", ".git", "node_modules", "__MACOSX", ".DS_Store"]);
|
||||
const MAX_UNPACKED_BYTES = 50 * 1024 * 1024;
|
||||
|
||||
export function validSkillName(id) {
|
||||
return typeof id === "string" && SKILL_NAME_RE.test(id);
|
||||
@@ -195,14 +197,6 @@ export function formatSize(bytes) {
|
||||
return `${kb >= 100 ? Math.round(kb) : kb.toFixed(1)} KB`;
|
||||
}
|
||||
|
||||
async function fileSize(fp) {
|
||||
try {
|
||||
return (await fsp.stat(fp)).size;
|
||||
} catch {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function pathExists(fp) {
|
||||
try {
|
||||
await fsp.access(fp);
|
||||
@@ -309,7 +303,8 @@ async function backupExisting(dshHome, id) {
|
||||
const hasFlat = await pathExists(flat);
|
||||
if (!hasBundle && !hasFlat) return null;
|
||||
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
||||
const dest = path.join(skillBackupDir(dshHome), `${id}_${stamp}`);
|
||||
const uniq = `${process.pid}-${crypto.randomBytes(4).toString("hex")}`;
|
||||
const dest = path.join(skillBackupDir(dshHome), `${id}_${stamp}_${uniq}`);
|
||||
assertInside(path.join(dshHome, "dsh-purge-backups"), dest);
|
||||
await fsp.mkdir(dest, { recursive: true });
|
||||
if (hasBundle) {
|
||||
@@ -357,9 +352,20 @@ export async function saveSkill(dshHome, id, content, description) {
|
||||
const dest = skillBundleFile(dshHome, id);
|
||||
assertInside(root, dest);
|
||||
const backup = await backupExisting(dshHome, id);
|
||||
await removeOfficialSkill(dshHome, id);
|
||||
await fsp.mkdir(skillBundleDir(dshHome, id), { recursive: true });
|
||||
await fsp.writeFile(dest, document, "utf8");
|
||||
try {
|
||||
await removeOfficialSkill(dshHome, id);
|
||||
await fsp.mkdir(skillBundleDir(dshHome, id), { recursive: true });
|
||||
await atomicWriteFile(dest, document);
|
||||
} catch (err) {
|
||||
try { await restoreSkillFromBackup(dshHome, id, backup); }
|
||||
catch (restoreErr) {
|
||||
console.warn(
|
||||
"[dsh-purge] saveSkill restore failed:",
|
||||
restoreErr && restoreErr.message ? restoreErr.message : restoreErr,
|
||||
);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
return {
|
||||
id,
|
||||
path: dest,
|
||||
@@ -589,7 +595,18 @@ export async function importArchive(dshHome, buffer, filename = "skill.zip") {
|
||||
await fsp.mkdir(unpacked, { recursive: true });
|
||||
await fsp.writeFile(archive, bytes);
|
||||
extractArchive(archive, unpacked);
|
||||
await walkFiles(unpacked, async () => {});
|
||||
let total = 0;
|
||||
await walkFiles(unpacked, async (fp) => {
|
||||
try {
|
||||
const st = await fsp.stat(fp);
|
||||
total += st.size;
|
||||
if (total > MAX_UNPACKED_BYTES) {
|
||||
throw new Error(`压缩包解压后超过 ${Math.floor(MAX_UNPACKED_BYTES / 1024 / 1024)}MB`);
|
||||
}
|
||||
} catch (err) {
|
||||
if (err && err.message && err.message.includes("超过")) throw err;
|
||||
}
|
||||
});
|
||||
const imported = await installFoundSkills(dshHome, unpacked, kebabFromLabel(filename));
|
||||
return { imported: imported.map((item) => toPublicSkill(dshHome, item)) };
|
||||
} finally {
|
||||
|
||||
+161
-194
@@ -6,15 +6,12 @@ import https from "node:https";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { findDshHome } from "./core.js";
|
||||
import { adapterFor, detectSurface } from "./surface.js";
|
||||
import { cliInvocation } from "./desktop.js";
|
||||
import { atomicWriteSync, findDshHome } from "./core.js";
|
||||
import { extractZipArchive } from "./zip-extract.js";
|
||||
|
||||
const REPO = "YuJunZhiXue/dsh-purge";
|
||||
const STABLE_REF = "master";
|
||||
const BETA_REF = "beta";
|
||||
export const TARBALL_URL = `https://codeload.github.com/${REPO}/tar.gz/refs/heads/${STABLE_REF}`;
|
||||
const PLUGIN_ROOT = path.resolve(fileURLToPath(new URL(".", import.meta.url)), "..");
|
||||
const CHANNELS = {
|
||||
stable: { id: "stable", ref: STABLE_REF, label: "正式版" },
|
||||
@@ -40,6 +37,18 @@ const HIDDEN = {
|
||||
timeout: 20000,
|
||||
};
|
||||
|
||||
// 只允许来自 GitHub / jsdelivr 的 302 跳转落地,阻挡中间人把下载指向任意主机。
|
||||
const UPDATE_REDIRECT_ALLOWED_HOSTS = new Set([
|
||||
"github.com",
|
||||
"codeload.github.com",
|
||||
"api.github.com",
|
||||
"raw.githubusercontent.com",
|
||||
"objects.githubusercontent.com",
|
||||
"release-assets.githubusercontent.com",
|
||||
"cdn.jsdelivr.net",
|
||||
]);
|
||||
const MAX_UPDATE_BYTES = 50 * 1024 * 1024;
|
||||
|
||||
export function pluginRoot() {
|
||||
return PLUGIN_ROOT;
|
||||
}
|
||||
@@ -69,31 +78,16 @@ function autoUpdateGuardPath() {
|
||||
return path.join(findDshHome(), "dsh-purge", "auto-update-guard.json");
|
||||
}
|
||||
|
||||
function autoUpdateGuardBlocks(ref) {
|
||||
try {
|
||||
const raw = JSON.parse(fs.readFileSync(autoUpdateGuardPath(), "utf8"));
|
||||
const at = Date.parse(String(raw?.at || "")) || 0;
|
||||
if (!at || Date.now() - at > 15 * 60 * 1000) return false;
|
||||
const target = String(raw?.ref || "");
|
||||
if (target && ref && target !== String(ref)) return false;
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function markAutoUpdateGuard(ref, sha = "") {
|
||||
const fp = autoUpdateGuardPath();
|
||||
fs.mkdirSync(path.dirname(fp), { recursive: true });
|
||||
fs.writeFileSync(fp, `${JSON.stringify({
|
||||
atomicWriteSync(autoUpdateGuardPath(), `${JSON.stringify({
|
||||
ref: String(ref || ""),
|
||||
sha: String(sha || ""),
|
||||
at: new Date().toISOString(),
|
||||
}, null, 2)}\n`, "utf8");
|
||||
}, null, 2)}\n`);
|
||||
}
|
||||
|
||||
export function normalizeChannel(_value) {
|
||||
return "stable";
|
||||
export function normalizeChannel(value) {
|
||||
return String(value || "").toLowerCase() === "beta" ? "beta" : "stable";
|
||||
}
|
||||
|
||||
function isBetaName(name) {
|
||||
@@ -137,9 +131,10 @@ export function latestStableVersion(versions) {
|
||||
return best;
|
||||
}
|
||||
|
||||
/** 测试通道已下线。beta 分支、测试标签和名称里带 beta/rc/pre 的条目都不再列出。 */
|
||||
/** 测试通道只认 beta 分支头。旧的 beta/rc/pre 标签不列出。 */
|
||||
export function hideListedVersion(item, _stableVersion = "") {
|
||||
if (!item || withdrawnVersion(item)) return true;
|
||||
if (item.ref === BETA_REF && item.channel === "beta") return false;
|
||||
return item.channel === "beta" || isBetaName(item.version) || isBetaName(item.ref) || isBetaName(item.id);
|
||||
}
|
||||
|
||||
@@ -147,11 +142,12 @@ export function readChannelState() {
|
||||
const raw = readJson(channelStatePath()) || {};
|
||||
const stored = String(raw.channel || "").toLowerCase();
|
||||
const pin = typeof raw.pin === "string" ? raw.pin.trim() : "";
|
||||
const channel = stored === "beta" ? "beta" : "stable";
|
||||
const state = {
|
||||
channel: "stable",
|
||||
channel,
|
||||
pin: isBetaName(pin) || pin === BETA_REF ? "" : pin,
|
||||
};
|
||||
if (stored === "beta" || state.pin !== pin) writeChannelState(state);
|
||||
if ((stored === "beta") !== (channel === "beta") || state.pin !== pin) writeChannelState(state);
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -160,8 +156,7 @@ function writeChannelState(next) {
|
||||
channel: normalizeChannel(next?.channel),
|
||||
pin: typeof next?.pin === "string" ? next.pin.trim() : "",
|
||||
};
|
||||
fs.mkdirSync(path.dirname(channelStatePath()), { recursive: true });
|
||||
fs.writeFileSync(channelStatePath(), `${JSON.stringify(state, null, 2)}\n`, "utf8");
|
||||
atomicWriteSync(channelStatePath(), `${JSON.stringify(state, null, 2)}\n`);
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -186,8 +181,7 @@ function readHistory() {
|
||||
|
||||
function pushHistory(entry) {
|
||||
const next = [entry, ...readHistory().filter((item) => item && item.ref !== entry.ref)].slice(0, 20);
|
||||
fs.mkdirSync(path.dirname(historyPath()), { recursive: true });
|
||||
fs.writeFileSync(historyPath(), `${JSON.stringify(next, null, 2)}\n`, "utf8");
|
||||
atomicWriteSync(historyPath(), `${JSON.stringify(next, null, 2)}\n`);
|
||||
}
|
||||
|
||||
/** 直连 codeload,避免 github.com/archive → 302 在 Electron/部分 Node 下变成 http 302 / fetch failed。 */
|
||||
@@ -215,9 +209,7 @@ function readStamp() {
|
||||
|
||||
function writeStamp(value) {
|
||||
if (!value) return;
|
||||
const fp = stampPath();
|
||||
fs.mkdirSync(path.dirname(fp), { recursive: true });
|
||||
fs.writeFileSync(fp, `${value}\n`, "utf8");
|
||||
atomicWriteSync(stampPath(), `${value}\n`);
|
||||
}
|
||||
|
||||
function sameRev(a, b) {
|
||||
@@ -302,92 +294,6 @@ export function profilePluginDir(profileDir) {
|
||||
return fs.existsSync(nm) ? realPath(nm) : "";
|
||||
}
|
||||
|
||||
function resolveDshBin() {
|
||||
try {
|
||||
execFileSync(process.platform === "win32" ? "where" : "which", ["dsh"], HIDDEN);
|
||||
return "dsh";
|
||||
} catch {
|
||||
// 桌面进程 PATH 里经常没有 dsh,再到启动器旁找。
|
||||
}
|
||||
const home = findDshHome();
|
||||
const names = process.platform === "win32" ? ["dsh.cmd", "dsh.exe", "dsh"] : ["dsh"];
|
||||
const dirs = [
|
||||
path.join(home, "..", "npm-global"),
|
||||
path.join(home, "..", "npm-global-0.1.5-rc.2"),
|
||||
path.join(home, "..", "npm-global-0.1.5-rc.1"),
|
||||
path.join(home, "bin"),
|
||||
];
|
||||
for (const dir of dirs) {
|
||||
for (const name of names) {
|
||||
const fp = path.join(dir, name);
|
||||
if (fs.existsSync(fp)) return fp;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
export function runDshPlugin(profile, args) {
|
||||
if (adapterFor(detectSurface()) === "desktop") {
|
||||
const inv = cliInvocation();
|
||||
if (!inv) throw new Error("找不到 DSH Desktop CLI");
|
||||
execFileSync(inv.execPath, [...inv.argvPrefix, "plugin", "--profile", profile, ...args], {
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
windowsHide: true,
|
||||
timeout: 120000,
|
||||
env: {
|
||||
...process.env,
|
||||
...inv.env,
|
||||
DSH_HOME: findDshHome(),
|
||||
CI: "1",
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
const bin = resolveDshBin();
|
||||
if (!bin) throw new Error("找不到 dsh");
|
||||
execFileSync(bin, ["plugin", "--profile", profile, ...args], {
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
windowsHide: true,
|
||||
timeout: 120000,
|
||||
env: {
|
||||
...process.env,
|
||||
DSH_HOME: findDshHome(),
|
||||
CI: "1",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function pluginAddSpec(spec, ref = currentChannelRef()) {
|
||||
const s = String(spec || "");
|
||||
// github: / git+https 会让 pnpm 跑 git ls-remote。没装 git 时就是 #30。
|
||||
// 公开仓库用 archive tar.gz,不依赖本机 git。
|
||||
if (
|
||||
/\.(zip|tgz|tar\.gz)(\b|$)/i.test(s) ||
|
||||
/^https?:\/\//i.test(s) ||
|
||||
/^git\+https?:\/\//i.test(s) ||
|
||||
/^github:/i.test(s) ||
|
||||
/github\.com\/.+\.git/i.test(s)
|
||||
) {
|
||||
return archiveTarballUrl(ref);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function dshReinstall(profile, spec, ref = currentChannelRef()) {
|
||||
const addSpec = pluginAddSpec(spec, ref);
|
||||
if (addSpec) {
|
||||
runDshPlugin(profile, ["add", "--force", addSpec]);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
runDshPlugin(profile, ["update", "dsh-purge"]);
|
||||
} catch {
|
||||
runDshPlugin(profile, ["add", "--force", archiveTarballUrl(ref)]);
|
||||
}
|
||||
}
|
||||
|
||||
/** 把 profile 里的安装地址改成 codeload。github.com/archive 会 302,pnpm 的 fetch 接着失败。 */
|
||||
function pinInstalledSpec(profileDir, ref) {
|
||||
if (!profileDir) return;
|
||||
@@ -402,16 +308,17 @@ function pinInstalledSpec(profileDir, ref) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (changed) fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
|
||||
if (changed) atomicWriteSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
||||
}
|
||||
const lockPath = path.join(profileDir, "pnpm-lock.yaml");
|
||||
if (!fs.existsSync(lockPath)) return;
|
||||
const text = fs.readFileSync(lockPath, "utf8");
|
||||
const next = text.replace(
|
||||
/(^|\n)([ \t]*dsh-purge:\r?\n[ \t]+specifier:[ \t]*)\S+([ \t]*\r?\n[ \t]+version:[ \t]*)\S+/g,
|
||||
`$1$2${url}$3${url}`,
|
||||
);
|
||||
if (next !== text) fs.writeFileSync(lockPath, next, "utf8");
|
||||
// 这里曾经用正则把 pnpm-lock.yaml 里 importer 的 specifier/version 两行换成新地址,
|
||||
// 却没有写 packages:/snapshots: 条目。锁文件于是自相矛盾,pnpm 在任何命令之前校验
|
||||
// 锁文件就失败:
|
||||
// ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY / Broken lockfile: no entry for 'dsh-purge@…'
|
||||
// dsh 又给子进程带 CI=1(frozen-lockfile 默认开),于是 profile 里连紧随其后、
|
||||
// 本来能修好它的 pnpm add --force 都起不来 —— 整个 profile 从此不可安装。
|
||||
// 这个手改并不需要:pin 完 package.json 后,pnpm 自己会在 add --force 时按新地址
|
||||
// 重新解析,把 importer / packages / snapshots 一次写一致。锁文件只能由解析出这些
|
||||
// 字段的解析器来写。
|
||||
}
|
||||
|
||||
function planUpdates() {
|
||||
@@ -486,6 +393,10 @@ function requestBuffer(url, ms, headers, redirectsLeft = 5) {
|
||||
reject(e);
|
||||
return;
|
||||
}
|
||||
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
|
||||
reject(new Error(`update: unsupported protocol ${parsed.protocol}`));
|
||||
return;
|
||||
}
|
||||
const lib = parsed.protocol === "http:" ? http : https;
|
||||
const req = lib.request(parsed, {
|
||||
method: "GET",
|
||||
@@ -499,12 +410,27 @@ function requestBuffer(url, ms, headers, redirectsLeft = 5) {
|
||||
return;
|
||||
}
|
||||
const loc = Array.isArray(res.headers.location) ? res.headers.location[0] : res.headers.location;
|
||||
const next = loc ? new URL(loc, url).href : rewriteDownloadUrl(url);
|
||||
if (!next || next === url) {
|
||||
const candidate = loc ? new URL(loc, url).href : rewriteDownloadUrl(url);
|
||||
if (!candidate || candidate === url) {
|
||||
reject(new Error(`http ${status}`));
|
||||
return;
|
||||
}
|
||||
requestBuffer(next, ms, headers, redirectsLeft - 1).then(resolve, reject);
|
||||
let nextUrl;
|
||||
try {
|
||||
nextUrl = new URL(candidate);
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
return;
|
||||
}
|
||||
if (nextUrl.protocol !== "https:") {
|
||||
reject(new Error(`update: redirect rejected (non-https: ${nextUrl.protocol})`));
|
||||
return;
|
||||
}
|
||||
if (!UPDATE_REDIRECT_ALLOWED_HOSTS.has(nextUrl.hostname)) {
|
||||
reject(new Error(`update: redirect rejected (host not allowed: ${nextUrl.hostname})`));
|
||||
return;
|
||||
}
|
||||
requestBuffer(nextUrl.href, ms, headers, redirectsLeft - 1).then(resolve, reject);
|
||||
return;
|
||||
}
|
||||
if (status < 200 || status >= 300) {
|
||||
@@ -518,8 +444,21 @@ function requestBuffer(url, ms, headers, redirectsLeft = 5) {
|
||||
return;
|
||||
}
|
||||
const chunks = [];
|
||||
res.on("data", (chunk) => chunks.push(chunk));
|
||||
res.on("end", () => resolve({ status, body: Buffer.concat(chunks) }));
|
||||
let received = 0;
|
||||
let aborted = false;
|
||||
res.on("data", (chunk) => {
|
||||
if (aborted) return;
|
||||
received += chunk.length;
|
||||
if (received > MAX_UPDATE_BYTES) {
|
||||
aborted = true;
|
||||
req.destroy(new Error(`update: response exceeds ${MAX_UPDATE_BYTES} bytes`));
|
||||
return;
|
||||
}
|
||||
chunks.push(chunk);
|
||||
});
|
||||
res.on("end", () => {
|
||||
if (!aborted) resolve({ status, body: Buffer.concat(chunks) });
|
||||
});
|
||||
res.on("error", reject);
|
||||
});
|
||||
req.on("error", reject);
|
||||
@@ -541,8 +480,10 @@ async function fetchRes(url, ms = 20000, headers = {}) {
|
||||
return result.body.toString("utf8");
|
||||
},
|
||||
async arrayBuffer() {
|
||||
const copy = Buffer.from(result.body);
|
||||
return copy.buffer.slice(copy.byteOffset, copy.byteOffset + copy.byteLength);
|
||||
return result.body.buffer.slice(
|
||||
result.body.byteOffset,
|
||||
result.body.byteOffset + result.body.byteLength,
|
||||
);
|
||||
},
|
||||
};
|
||||
} catch (e) {
|
||||
@@ -621,10 +562,11 @@ function rememberVersion(item, seen) {
|
||||
return item;
|
||||
}
|
||||
|
||||
const UPDATE_REF_RE = /^(?:master|beta|v\d+\.\d+[\w.-]{0,48}|[0-9a-f]{7,40})$/i;
|
||||
const UPDATE_REF_RE = /^(?:v?\d+\.\d+(?:\.\d+)?(?:-[\w.]+)?|master|main|beta|[0-9a-f]{7,40})$/i;
|
||||
|
||||
export function safeUpdateRef(ref) {
|
||||
const target = String(ref || "").trim();
|
||||
if (!target) return "";
|
||||
if (!UPDATE_REF_RE.test(target)) return "";
|
||||
return target;
|
||||
}
|
||||
@@ -707,8 +649,9 @@ async function listRemoteVersions() {
|
||||
if (next) out.push(next);
|
||||
};
|
||||
|
||||
const [stableSha, tags] = await Promise.all([
|
||||
const [stableSha, betaSha, tags] = await Promise.all([
|
||||
remoteHeadSha(STABLE_REF),
|
||||
remoteHeadSha(BETA_REF),
|
||||
listGithubTags(),
|
||||
]);
|
||||
|
||||
@@ -725,6 +668,19 @@ async function listRemoteVersions() {
|
||||
latest: true,
|
||||
});
|
||||
}
|
||||
if (betaSha) {
|
||||
const version = await remotePackageVersion(betaSha, BETA_REF).catch(() => "");
|
||||
add({
|
||||
id: BETA_REF,
|
||||
ref: BETA_REF,
|
||||
sha: betaSha,
|
||||
version: version || "",
|
||||
channel: "beta",
|
||||
label: `${versionLabel(version, "beta", betaSha)} · 最新`,
|
||||
kind: "head",
|
||||
latest: true,
|
||||
});
|
||||
}
|
||||
for (const tag of tags) {
|
||||
if (!withdrawnVersion(tag)) add(tag);
|
||||
}
|
||||
@@ -747,23 +703,12 @@ async function listRemoteVersions() {
|
||||
const visible = withLocal.filter((item) => !hideListedVersion(item, ceiling));
|
||||
return {
|
||||
versions: markCurrent(visible, state, localVer, localSha),
|
||||
hasBeta: false,
|
||||
hasBeta: Boolean(betaSha),
|
||||
stableSha,
|
||||
betaSha: "",
|
||||
betaSha: betaSha || "",
|
||||
};
|
||||
}
|
||||
|
||||
function alignChannelState(state, listed, localRev, localVer) {
|
||||
if (state.pin) return state;
|
||||
if (listed.stableSha && localRev && sameRev(localRev, listed.stableSha) && state.channel !== "stable") {
|
||||
return writeChannelState({ channel: "stable", pin: "" });
|
||||
}
|
||||
if (!localRev && localVer && state.channel !== "stable") {
|
||||
return writeChannelState({ channel: "stable", pin: "" });
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
function describeLane(id, listed, state, localVer, localRev) {
|
||||
const sha = id === "beta" ? listed.betaSha : listed.stableSha;
|
||||
const versions = listed.versions.filter((item) => item.channel === id);
|
||||
@@ -806,7 +751,6 @@ export async function checkUpdate() {
|
||||
const gitSha = gitOk() ? gitHead(PLUGIN_ROOT) : "";
|
||||
const stamp = readStamp();
|
||||
const localRev = gitSha || stamp;
|
||||
state = alignChannelState(state, listed, localRev, localVer);
|
||||
listed.versions = markCurrent(listed.versions, state, localVer, localRev);
|
||||
const channelRef = currentChannelRef(state);
|
||||
const lanes = lanesOf(listed, state, localVer, localRev);
|
||||
@@ -924,34 +868,37 @@ async function overlayFromZip(dests, ref = STABLE_REF) {
|
||||
const unique = [...new Set(dests.filter(Boolean).map((d) => realPath(d)))];
|
||||
if (!unique.length) return;
|
||||
const tmp = await fsp.mkdtemp(path.join(os.tmpdir(), "dsh-purge-upd-"));
|
||||
const zip = path.join(tmp, "plugin.zip");
|
||||
const res = await fetchRes(archiveZipUrl(ref), 45000);
|
||||
await fsp.writeFile(zip, Buffer.from(await res.arrayBuffer()));
|
||||
extractZip(zip, tmp);
|
||||
const names = await fsp.readdir(tmp);
|
||||
const unpacked = names
|
||||
.map((n) => path.join(tmp, n))
|
||||
.find((p) => fs.existsSync(path.join(p, "package.json")));
|
||||
if (!unpacked) throw new Error("zip 里没有 package.json");
|
||||
for (const dest of unique) {
|
||||
for (const name of COPY_NAMES) {
|
||||
const from = path.join(unpacked, name);
|
||||
const to = path.join(dest, name);
|
||||
if (!fs.existsSync(from)) continue;
|
||||
if (name === "lib" || name === "docs" || name === "bin") {
|
||||
try {
|
||||
await fsp.rm(to, { recursive: true, force: true });
|
||||
} catch {
|
||||
// 目录被占用时改为覆盖写入。
|
||||
}
|
||||
}
|
||||
await fsp.cp(from, to, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
try {
|
||||
await fsp.rm(tmp, { recursive: true, force: true });
|
||||
} catch {
|
||||
// 临时目录清不掉不影响安装结果。
|
||||
const zip = path.join(tmp, "plugin.zip");
|
||||
const res = await fetchRes(archiveZipUrl(ref), 45000);
|
||||
await fsp.writeFile(zip, Buffer.from(await res.arrayBuffer()));
|
||||
extractZip(zip, tmp);
|
||||
const names = await fsp.readdir(tmp);
|
||||
const unpacked = names
|
||||
.map((n) => path.join(tmp, n))
|
||||
.find((p) => fs.existsSync(path.join(p, "package.json")));
|
||||
if (!unpacked) throw new Error("zip 里没有 package.json");
|
||||
for (const dest of unique) {
|
||||
for (const name of COPY_NAMES) {
|
||||
const from = path.join(unpacked, name);
|
||||
const to = path.join(dest, name);
|
||||
if (!fs.existsSync(from)) continue;
|
||||
if (name === "lib" || name === "docs" || name === "bin") {
|
||||
try {
|
||||
await fsp.rm(to, { recursive: true, force: true });
|
||||
} catch (e) {
|
||||
// 删不掉说明文件被进程占用。继续 cp 会写出一半新文件一半旧文件的半升级,
|
||||
// 让 host 和插件的版本不一致。宁可抛错让用户彻底退出宿主再重试。
|
||||
throw new Error(
|
||||
`覆盖 ${to} 失败(${e.message || e})。可能被进程占用,请完全退出宿主后重试。`,
|
||||
);
|
||||
}
|
||||
}
|
||||
await fsp.cp(from, to, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
await fsp.rm(tmp, { recursive: true, force: true }).catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -994,7 +941,23 @@ function runReapplyChild() {
|
||||
return { ok: false, error: detail.slice(0, 500) || "重新应用失败" };
|
||||
}
|
||||
|
||||
let applyUpdateInflight = null;
|
||||
|
||||
export async function applyUpdate(jobs = planUpdates(), options = {}) {
|
||||
// 同一时刻只能有一次 applyUpdate 在跑。第二次调用在第一次完成前共享同一个 Promise,
|
||||
// 避免两条 overlayFromZip 同时往同一目录写出一半文件,或两次 writeStamp 竞争。
|
||||
if (applyUpdateInflight) return applyUpdateInflight;
|
||||
applyUpdateInflight = (async () => {
|
||||
try {
|
||||
return await _applyUpdateImpl(jobs, options);
|
||||
} finally {
|
||||
applyUpdateInflight = null;
|
||||
}
|
||||
})();
|
||||
return applyUpdateInflight;
|
||||
}
|
||||
|
||||
async function _applyUpdateImpl(jobs, options) {
|
||||
if (!Array.isArray(jobs)) {
|
||||
options = jobs && typeof jobs === "object" ? jobs : {};
|
||||
jobs = planUpdates();
|
||||
@@ -1035,27 +998,31 @@ export async function applyUpdate(jobs = planUpdates(), options = {}) {
|
||||
}
|
||||
for (const dir of specProfiles) pinInstalledSpec(dir, ref);
|
||||
const sha = (gitOk() ? gitHead(PLUGIN_ROOT) : "") || (await remoteHeadSha(ref).catch(() => ""));
|
||||
if (sha) markAutoUpdateGuard(ref, sha);
|
||||
if (sha) writeStamp(sha);
|
||||
const via = vias.size > 1 ? "mixed" : [...vias][0] || detectVia();
|
||||
const saved = writeChannelState({ channel, pin });
|
||||
const localVer = localVersion();
|
||||
pushHistory({
|
||||
ref,
|
||||
sha: sha || "",
|
||||
version: localVer,
|
||||
channel,
|
||||
label: versionLabel(localVer, channel, sha),
|
||||
at: new Date().toISOString(),
|
||||
});
|
||||
const listed = await listRemoteVersions().catch(() => ({ versions: [], hasBeta: saved.channel === "beta" }));
|
||||
const reapplied = runReapplyChild();
|
||||
// reapply 真的成功才能承认这次升级:写 stamp / guard / history。
|
||||
// 失败就不写,下次 checkUpdate 还能发现没完成的升级,而不是误标为"已是最新"。
|
||||
if (reapplied.ok === true) {
|
||||
if (sha) markAutoUpdateGuard(ref, sha);
|
||||
if (sha) writeStamp(sha);
|
||||
pushHistory({
|
||||
ref,
|
||||
sha: sha || "",
|
||||
version: localVer,
|
||||
channel,
|
||||
label: versionLabel(localVer, channel, sha),
|
||||
at: new Date().toISOString(),
|
||||
});
|
||||
}
|
||||
const restartAfter = reapplied.ok === true && !reapplied.needsFullQuit;
|
||||
const needsFullQuit = reapplied.ok === true && Boolean(reapplied.needsFullQuit);
|
||||
return rememberUpdate({
|
||||
ok: reapplied.ok !== false,
|
||||
applied: true,
|
||||
hasUpdate: false,
|
||||
applied: reapplied.ok === true,
|
||||
hasUpdate: reapplied.ok !== true,
|
||||
hasBeta: listed.hasBeta,
|
||||
pinned: Boolean(saved.pin),
|
||||
localVersion: localVer,
|
||||
@@ -1067,6 +1034,7 @@ export async function applyUpdate(jobs = planUpdates(), options = {}) {
|
||||
restartAfter,
|
||||
needsFullQuit,
|
||||
reapplied: reapplied.ok === true,
|
||||
needsRetry: reapplied.ok === false,
|
||||
error: reapplied.ok === false ? `文件已更新,但还原并重新应用失败: ${reapplied.error || "未知错误"}` : undefined,
|
||||
via,
|
||||
versions: listed.versions,
|
||||
@@ -1076,7 +1044,6 @@ export async function applyUpdate(jobs = planUpdates(), options = {}) {
|
||||
}
|
||||
|
||||
export async function switchChannel(channel, { apply = true } = {}) {
|
||||
if (String(channel || "").toLowerCase() === "beta") throw new Error("测试版已下线");
|
||||
const next = normalizeChannel(channel);
|
||||
if (!apply) {
|
||||
writeChannelState({ channel: next, pin: "" });
|
||||
@@ -1121,12 +1088,12 @@ export async function handleUpdateOp(body = {}) {
|
||||
const requested = body.ref || currentChannelRef(state);
|
||||
const ref = safeUpdateRef(requested);
|
||||
if (!ref) throw new Error("未知版本");
|
||||
if (ref === BETA_REF || isBetaName(ref)) throw new Error("测试版已下线");
|
||||
if (ref !== STABLE_REF) {
|
||||
if (ref !== BETA_REF && isBetaName(ref)) throw new Error("该测试标签已不再提供");
|
||||
if (ref !== STABLE_REF && ref !== BETA_REF) {
|
||||
const listed = await listRemoteVersions();
|
||||
if (!listedUpdateRef(ref, listed)) throw new Error("未知版本");
|
||||
}
|
||||
const channel = body.channel === "beta" ? "stable" : (body.channel || (ref === STABLE_REF ? "stable" : state.channel));
|
||||
const channel = ref === BETA_REF ? "beta" : (ref === STABLE_REF ? "stable" : normalizeChannel(body.channel || state.channel));
|
||||
return applyUpdate(planUpdates(), { ref, channel, pin: false, force: true });
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "dsh-purge",
|
||||
"version": "1.1.61",
|
||||
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,内嵌演练台;不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
|
||||
"version": "1.1.67",
|
||||
"description": "DeepSeek Harness 破甲:让所有模型都能破甲,不同模型可换不同提示词;默认提示词面向国模「小码酱」。Jailbreak for every model — swap prompts per model. 求 Star 收藏 ⭐ 如要二开,请查看署名要求部分",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
"exports": {
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
- `assess` **资产梳理**:把收集到的资产**一条一条过**,评估易打性(priority/potential/reason)并**全部落库**,产出"先打谁"的排序。
|
||||
- `vuln-scan` **漏洞发现**:逐条过资产,**先查库避免重复劳动** → 优先 Nday/1day → 再提取前端接口探未授权 → 每条漏洞落库 + 原始请求。
|
||||
- `exploit` **漏洞利用**:逐条过漏洞,先拿服务器权限(**冰蝎/哥斯拉马 + 必须实测用户能连上**),**立刻建 suo5 隧道并实测能访问内网**(给用户可粘贴的 `socks5://127.0.0.1:<端口>` 配置),再做其它得分项。
|
||||
- `internal` **内网渗透**:用 exploit 建好的隧道做内网渗透,**依次拉起信息收集 → 资产梳理 → 漏洞发现 → 漏洞利用**四个角色(子任务里写清"走哪条隧道"、把隧道监听地址贴成真实值),**最重要的是挖出内网所有网段**。
|
||||
- `internal` **内网渗透**:用 exploit 建好的隧道做内网渗透,**它自己顺序做收集 → 梳理 → 发现 → 利用**(它是叶子节点,不能再往下派活;任务书里写清"走哪条隧道"、把隧道监听地址贴成真实值),**最重要的是挖出内网所有网段**。
|
||||
**内网的信息收集必须指定用 `gogo-intranet` 与 `fscan-intranet` 两个技能**(不要把外网那套 nmap 一台台扫的法子带进内网):先 gogo 走隧道铺面(存活/端口/服务/指纹/关键信息),再 fscan 走隧道打点(弱口令/未授权/高危漏洞),命中项记进资产的 `surface` 交给漏洞发现角色;**每发现一个新网段就再跑一轮**,直到没有新网段、没有新存活为止。
|
||||
- 自己的责任边界:子角色只做本职,**不要交叉派活**(别让信息收集去测漏洞、别让漏洞发现去打内网)。
|
||||
|
||||
@@ -116,15 +116,15 @@
|
||||
- **自己的 VPS / 自建服务器上开的代理不算隧道**:隧道必须说清目标侧那一端(`entry_kind`)。
|
||||
- 报告只收录拿到分的成果,且每条要能复现(目标 → 拿到什么 → 怎么拿到的(命令)→ 原始请求)。
|
||||
|
||||
# 锚点门:第一段思考含 we 且不含 let me 才放开 1024 输出上限;锚不住最多 4 步。
|
||||
# 锚点门:bootstrap 阶段限输出,避免首轮空转;指挥端会先连打 preflight/开靶/读技能,1024 易截断。
|
||||
# 不裁工具、不换人设。压缩后再关一次。放开后工作区长说明改成点名文件。
|
||||
- id: anchor-gate
|
||||
name: ./anchor-gate.mjs
|
||||
config:
|
||||
anchorGate: true
|
||||
maxBootstrapSteps: 4
|
||||
maxBootstrapSteps: 2
|
||||
promoteAfterFirstResponse: true
|
||||
bootstrapMaxTokens: 1024
|
||||
bootstrapMaxTokens: 8192
|
||||
instructionHint: true
|
||||
|
||||
- id: redteam-tools
|
||||
|
||||
@@ -41,6 +41,8 @@ export function hasAnchoredReasoning(content) {
|
||||
export function decidePromotion(state, config) {
|
||||
if (state.toolCalled && config.anchorGate !== true) return true
|
||||
if (state.toolCalled && config.anchorGate === true && (state.anchored || state.steps >= config.maxBootstrapSteps)) return true
|
||||
/* 红队指挥首轮必调工具;英文思考常写 I need 过不了 we 锚,但仍应在少量 step 后放开输出上限 */
|
||||
if (state.toolCalled && config.anchorGate === true && state.steps >= 1 && config.promoteAfterFirstResponse === true) return true
|
||||
if (state.toolCalled && config.anchorGate === true && config.promoteAfterFirstResponse === true && state.turnEnded) return true
|
||||
if (!state.toolCalled && state.responded && config.promoteAfterFirstResponse === true) return true
|
||||
return false
|
||||
|
||||
@@ -1,3 +1,133 @@
|
||||
# 1.1.67
|
||||
|
||||
## 中文
|
||||
|
||||
- 版本 **1.1.67**。
|
||||
- **#85**:continue 续跑在传输/429 连错时不再无限兜圈。`takeContinue` 加 failStreak 阈值;`refundContinue` 不清 `lastContinueSeq`,连错 ≥3 直接放弃。
|
||||
- **#84**:区域拦截的空 Assistant 流改为单批 `text-chunks` 记录(带 `.length`),不再卡住宿主 UI。
|
||||
- 启动种子:进程启动时若 `$DSH_HOME/prompt-inject.md` 为空或缺失,自动把加密默认稿写一次;用户改过的稿不动。清洗完点重启后,重启成功立刻就能用默认提示词。
|
||||
- Windows 官方包重启:restart 脚本名改成 `pid+random`,首启不与并发实例打架;多余的 `.cmd` 中介删掉,直接 `wscript.exe //nologo //B` 起脚本;本机旧版无 pid 后缀的脚本/日志超过 24h 启动时自动清。
|
||||
- 杀进程范围收紧:`ASAR_SWAP_PS1` 不再 `/IM` 杀全名同名进程,只按安装根下 pid 停,避免误伤第三方同名。
|
||||
- 官方 CLI shim 原地改写之前先存一份 `.dsh-purge.bak`,并走原子写,断电/盘满可回退。
|
||||
- 首装场景不卡:WScript 判 clean 时,两边都是 null(文件缺或读失败)放行启动,只有任一明确 dirty 才拦。
|
||||
- 探测缓存:`runningExes` / `shortcutExes` 空结果不再缓存;点"应用"前 `clearDesktopLocateCache()` 仍可强刷。
|
||||
- `scheduleAsarRenameWhenIdle` 的 `.rename-pending` 锁:时钟回拨或超过 30 分钟视为失效,清掉重做。
|
||||
- `execFileSync` 三处 PowerShell 调用加 `maxBuffer: 8MB`,大结果不再静默 ENOBUFS 掉。
|
||||
- 其他:net-scope region gate 指数退避 + IPv6 regex 收紧;identity `injectMatchers` 支持 >4096 分段匹配、`installAssembleGuard` 幂等;hooks-deny 删 R0 兜底规则改原子写;extract-asar commit 不删 `nextDir`,写 `.dshpurge-recover.json` 便回滚;client.js redteam preset 多路检测、shell.submit WeakMap 清理补齐。
|
||||
|
||||
## English
|
||||
|
||||
- **1.1.67**.
|
||||
- **#85**: Continue loop no longer spins forever on TRANSPORT/429 streaks. `takeContinue` adds a failStreak gate; `refundContinue` leaves `lastContinueSeq` set; 3 consecutive failures abandon.
|
||||
- **#84**: Region-gate empty-assistant stream becomes one batched `text-chunks` record (with `.length`), no longer hangs the host UI.
|
||||
- Boot-time seeding: on startup, if `$DSH_HOME/prompt-inject.md` is empty or missing, the encrypted default is written once; a user-edited file is untouched. After the Apply → cleanup → restart cycle, the default prompt is active immediately.
|
||||
- Windows official-build restart: restart script name now includes `pid+random`, so concurrent instances don't clobber each other; the `.cmd` intermediary is dropped — `wscript.exe //nologo //B` is spawned directly; legacy unsuffixed scripts/logs older than 24h are purged on each startup.
|
||||
- Kill scope tightened: `ASAR_SWAP_PS1` no longer uses `/IM` to kill by full name — only pids under the install root are stopped, so same-named third-party processes aren't collateral.
|
||||
- Official CLI shim repair now saves `.dsh-purge.bak` and uses atomic write before overwriting, so power loss / disk full is recoverable.
|
||||
- First-install not blocked: when WScript checks for clean markers, two nulls (missing or unreadable) now pass through; only an explicit `false` blocks startup.
|
||||
- Probe caches: `runningExes` / `shortcutExes` no longer cache empty results; `clearDesktopLocateCache()` on Apply still forces a refresh.
|
||||
- `scheduleAsarRenameWhenIdle` `.rename-pending` lock: clock skew or ≥30-min-old lock is treated as stale and cleared.
|
||||
- Three `execFileSync` PowerShell calls get `maxBuffer: 8MB` so large results no longer silent-fail with ENOBUFS.
|
||||
- Also: net-scope region-gate exponential backoff + stricter IPv6 regex; identity `injectMatchers` segments >4096-char payloads, `installAssembleGuard` is idempotent; hooks-deny drops R0 fallback and uses atomic write for state; extract-asar commit no longer deletes `nextDir` and writes `.dshpurge-recover.json` for rollback; client.js redteam preset detection broadened; `shell.submit` WeakMap cleanup wired.
|
||||
|
||||
# 1.1.66
|
||||
|
||||
## 中文
|
||||
|
||||
- 版本 **1.1.66**。
|
||||
- **#80**:清洗页可关掉 hooks deny / ask 旁路。关掉且文件干净显示跳过,不计入已应用;关掉后再打开,64/65 会按官方形态再打一次。
|
||||
- **#81**:继续 / 拒答续跑的来源 kind 改为 `dsh-purge`;限流和传输失败不再自动续一轮。
|
||||
- 重启后不用点保存也会挂上默认提示词;每一轮都补回全文。空的应用请求不再清空磁盘上的提示词。
|
||||
- 声明过的 overlay 只剩 `.dshpurge.bak` 时,应用会先拷回再加载。
|
||||
- 红队报告补上得分点短名。中文 README 恢复题图和预览图。
|
||||
|
||||
## English
|
||||
|
||||
- **1.1.66**.
|
||||
- **#80**: The clean page can turn off the hooks deny/ask bypass. Off + clean files show skipped and are not counted as applied. Turning it back on reapplies 64/65 from the official form.
|
||||
- **#81**: Continue / refusal-recover use source kind `dsh-purge`. RATE_LIMIT and TRANSPORT no longer start another continue turn.
|
||||
- Restart hangs the default prompt without a Save click; every step puts the full text back. An empty Apply body no longer wipes the disk prompt.
|
||||
- A declared overlay that exists only as `.dshpurge.bak` is copied back before load.
|
||||
- Red-team reports get short score-point names. Chinese README restores the banner and preview images.
|
||||
|
||||
# 1.1.65
|
||||
|
||||
## 中文
|
||||
|
||||
- 版本 **1.1.65**。
|
||||
- 默认提示词按 `lib/default-prompt-inject.md` 重新加密进槽。磁盘上仍是用户自己改过的稿时,不覆盖。
|
||||
- 红队接入截图登记、得分点看图,以及报告六段。可把某次演练导出成目录。
|
||||
- 技能正文缺工具路径、缺密钥或 VPS 还是占位符时,不再把整条技能标成不可用。缺口留在详情里。
|
||||
- 打开页面或组装提示词时,会把当前默认稿同步到磁盘,不必先点保存。
|
||||
- 删掉没有调用的桌面启动封装、旧迁移脚本,以及已经注释掉的手动继续入口。
|
||||
|
||||
## English
|
||||
|
||||
- **1.1.65**.
|
||||
- The default prompt is sealed again from `lib/default-prompt-inject.md`. A prompt the user already edited on disk is left as-is.
|
||||
- Red team gains shot registration, score-point images, and the six-part report. An engagement can be exported to a folder.
|
||||
- A skill stays usable when a documented tool path, key, or VPS placeholder is missing. The gap stays on the skill detail.
|
||||
- Opening the page or assembling the prompt writes the current default to disk, without a Save click first.
|
||||
- Unused desktop launch helpers, the old migration script, and the commented manual-continue entry are removed.
|
||||
|
||||
# 1.1.64
|
||||
|
||||
## 中文
|
||||
|
||||
- 版本 **1.1.64**。
|
||||
- 红队流程八项。角色稿只在**新建靶标**时播种;已经建好的靶标,要在演练台里把智能体同步一次才会换成新稿。
|
||||
- **内网**改为叶子节点,自己按收集、梳理、发现、利用做,不再往下派活。
|
||||
- 并发名额:不带 key 的 release 只放最早的一条。子智能体结束由服务端自动释放;手动释放必须带上 acquire 返回的 key。
|
||||
- 预检带 `include` 时只体检点名的技能,不再被全局缺密钥拖成失败。缺项带上由用户执行的修复说明。
|
||||
- IPv6 计分至少两个冒号,`dc01:389` 这类主机名不再 ×3。计分只留在 `score-rules.js`。
|
||||
- 攻击链计分跳过已停用的得分点。
|
||||
- `.env` 认 `export KEY=value`。未加引号的行内注释会剥掉,引号里的 `#` 保留。
|
||||
- 内网计分 code 改为 `central-system`、`boundary-logical`、`boundary-strong` 等,以 `redteam_score_list` 实际返回为准。
|
||||
- 漏洞发现和利用从 `priority=high` 打起。优先级为空时,先回报指挥补一轮评估。
|
||||
- 删掉没有调用的代码。设置页里过期的 `legacyApplyPath(...)` 调用改为 `applyPathOp`。
|
||||
|
||||
## English
|
||||
|
||||
- **1.1.64**.
|
||||
- Eight red-team flow fixes. Role prompts seed **new** engagements only; sync agents on an existing engagement to pick them up.
|
||||
- The internal role is a leaf and does collect, assess, scan, and exploit itself.
|
||||
- A release without a key drops only the oldest reservation. Ending a subagent auto-releases; a manual release must carry the acquire key.
|
||||
- Preflight `include` checks only the named skills. Broken items include fixes for the user to run.
|
||||
- IPv6 scoring needs at least two colons, so `dc01:389` is no longer ×3. Scoring lives only in `score-rules.js`.
|
||||
- Attack-chain scoring skips disabled score points.
|
||||
- `.env` accepts `export KEY=value` and strips unquoted inline comments. A `#` inside quotes stays.
|
||||
- Internal score codes match the live list (`central-system`, `boundary-logical`, `boundary-strong`, and the rest), taken from `redteam_score_list`.
|
||||
- Vuln-scan and exploit start at `priority=high`. If priority is empty, report back and run another assess first.
|
||||
- Unused code removed. Stale settings calls to `legacyApplyPath` now call `applyPathOp`.
|
||||
|
||||
# 1.1.63
|
||||
|
||||
## 中文
|
||||
|
||||
- 版本 **1.1.63**。
|
||||
- 官方更新脚本去掉中文注释,避免 `official update script is not ASCII`。
|
||||
|
||||
## English
|
||||
|
||||
- **1.1.63**.
|
||||
- Official update script is ASCII only, so the handoff no longer fails the ASCII check.
|
||||
|
||||
# 1.1.62
|
||||
|
||||
## 中文
|
||||
|
||||
- 版本 **1.1.62**。
|
||||
- 继续/重试重新打开。
|
||||
- 锚点门:首轮输出上限 1024→8192,最多 2 步;已调工具即放开,英文思考过不了 we 锚也不再卡住。
|
||||
- 已有预设的锚点配置与包内不一致时同步,不整份覆盖。
|
||||
|
||||
## English
|
||||
|
||||
- **1.1.62**.
|
||||
- Continue/retry is on again.
|
||||
- Anchor gate: bootstrap cap 8192, max 2 steps; promote after the first tool call.
|
||||
- Existing presets sync the anchor-gate block when it differs from the package.
|
||||
|
||||
# 1.1.61
|
||||
|
||||
## 中文
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* 把一个靶标的得分报告导出成可移动的交付包:`<outDir>/<靶标>-红队成果复现报告.md` + `<outDir>/shots/`。
|
||||
*
|
||||
* 面板下载的 markdown 里,证据截图走绝对路径,发给别人会碎图。
|
||||
* 这里把 shots/ 一并拷到输出目录,markdown 用相对路径。
|
||||
*
|
||||
* 跑法:
|
||||
* node scripts/export-engagement-report.mjs
|
||||
* node scripts/export-engagement-report.mjs --out ~/交付/靶标名
|
||||
* node scripts/export-engagement-report.mjs --engagement <id>
|
||||
*/
|
||||
import { mkdirSync, writeFileSync, cpSync, rmSync, existsSync, readdirSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { join, resolve } from "node:path";
|
||||
import { RedteamStore } from "../lib/redteam/store-core.js";
|
||||
|
||||
const argv = process.argv.slice(2);
|
||||
const argOf = (name, fallback) => {
|
||||
const i = argv.indexOf("--" + name);
|
||||
return i === -1 || argv[i + 1] === undefined ? fallback : argv[i + 1];
|
||||
};
|
||||
|
||||
const root = process.env.REDTEAM_HOME || join(process.env.DSH_HOME || join(homedir(), ".dsh"), "redteam");
|
||||
const store = new RedteamStore(root);
|
||||
const id = argOf("engagement", store.activeEngagementId());
|
||||
if (!id) {
|
||||
console.error("没有可用靶标:先用面板创建,或用 --engagement <id> 指定");
|
||||
process.exit(1);
|
||||
}
|
||||
const outDir = resolve(argOf("out", process.cwd()));
|
||||
mkdirSync(outDir, { recursive: true });
|
||||
|
||||
const shotsSrc = join(root, "engagements", id, "shots");
|
||||
const shotsDst = join(outDir, "shots");
|
||||
if (existsSync(shotsSrc)) {
|
||||
rmSync(shotsDst, { recursive: true, force: true });
|
||||
cpSync(shotsSrc, shotsDst, { recursive: true });
|
||||
}
|
||||
|
||||
const rep = store.scoreReport(id, { shotRef: "relative" });
|
||||
const name = String(rep.target || id).replace(/[/\\:*?"<>|]/g, "_");
|
||||
const outFile = join(outDir, name + "-红队成果复现报告.md");
|
||||
writeFileSync(outFile, rep.markdown, "utf8");
|
||||
store.close();
|
||||
|
||||
const imgs = (rep.markdown.match(/!\[[^\]]*\]\([^)]+\)/g) || []).length;
|
||||
console.log("✓ 报告:" + outFile);
|
||||
console.log(" 合计 " + rep.summary.points + " 分 · " + rep.items.length + " 条正文 · 嵌入截图 " + imgs + " 张"
|
||||
+ (existsSync(shotsDst) ? "(shots/ " + readdirSync(shotsDst).length + " 个文件,随报告一起拷走即可)" : ""));
|
||||
Reference in new issue
Block a user