mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-27 16:40:22 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77d61804c8 | ||
|
|
7a78399e0b | ||
|
|
fefae8764c | ||
|
|
7dd16def6d |
No files matched your search
@@ -4,7 +4,7 @@
|
||||
|
||||
<h1 align="center">⚔️ DeepSeek Harness cybersecurity red-team tool (dsh-purge)</h1>
|
||||
|
||||
<p align="center"><strong>Version 1.1.75</strong></p>
|
||||
<p align="center"><strong>Version 1.1.78</strong></p>
|
||||
|
||||
<p align="center">
|
||||
<em>DeepSeek Harness jailbreak: every model, swap prompts per model. Default prompt for 小码酱. Please star ⭐ If you build on this, see Attribution required.</em>
|
||||
@@ -57,7 +57,7 @@ The author's personal channel: [t.me/LLM_PoJia](https://t.me/LLM_PoJia). Notes a
|
||||
|
||||
## 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. **1.1.75** targets **DSH 0.2.1-rc.2** (0.2.0 still works). Official **Web** (`dsh web`) and the official **desktop EXE** are both supported. Install and Apply them separately.
|
||||
**dsh-purge** is a cybersecurity red-team plugin for the official [DeepSeek Harness](https://www.deepseek.com/harness/) already installed on your machine. **1.1.78** targets **DSH 0.2.1-rc.2** (0.2.0 still works). 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.
|
||||
|
||||
@@ -131,9 +131,9 @@ This repo is [Apache License 2.0](./LICENSE). Forks and redistributions must kee
|
||||
|
||||
## Supported hosts
|
||||
|
||||
**1.1.75 targets DSH 0.2.1-rc.2.** 0.2.0 still works. Do not apply it to 0.1.x.
|
||||
**1.1.78 targets DSH 0.2.1-rc.2.** 0.2.0 still works. Do not apply it to 0.1.x.
|
||||
|
||||
- **dsh 0.2.1-rc.2** (official desktop / official `dsh web`): use **1.1.75**. Fixes `{{cwd}}` / `[cwd]` crash, patch #40 match, dropped `toolFilter`, host `dsh-tools` resolve, hostFs fd, desktop helper self-kill, `file:` archive update, Ctrl+Enter steer.
|
||||
- **dsh 0.2.1-rc.2** (official desktop / official `dsh web`): use **1.1.78**. Fixes `{{cwd}}` / `[cwd]` crash, patch #40 match, dropped `toolFilter`, host `dsh-tools` resolve, hostFs fd, desktop helper self-kill, `file:` archive update, Ctrl+Enter steer.
|
||||
- **dsh 0.2.0-rc.2**: use **1.1.40** or newer; this line also installs.
|
||||
- **dsh 0.1.7** (incl. rc.1 / rc.2): use **1.1.39** or older — pick the tag on [Releases](https://github.com/YuJunZhiXue/dsh-purge/releases).
|
||||
|
||||
@@ -143,7 +143,7 @@ Unmatched patches stay pending or skipped; nothing is rewritten blindly.
|
||||
|
||||
## Install
|
||||
|
||||
Follow the three steps below. **Do not use the plugin marketplace.** One-click install on [dsh-plugin.org](https://dsh-plugin.org) or in Settings → Plugin Market fails with `already queued: dsh-purge` and never runs a command. There is no npm package; do not `pnpm add dsh-purge`, and do not `github:yujunzhixue/dsh-purge`.
|
||||
Follow the three steps below. **Do not use the plugin marketplace.** One-click install on [dsh-plugin.org](https://dsh-plugin.org) or in Settings → Plugin Market fails with `already queued: dsh-purge` and never runs a command. The name `dsh-purge` is not on the npm registry; do not `pnpm add dsh-purge`. If this machine only has pnpm, use the pnpm URL in step 2.
|
||||
|
||||
### 1. Which host are you running?
|
||||
|
||||
@@ -154,26 +154,44 @@ Official `dsh web` and the official desktop EXE are installed and patched **sepa
|
||||
| Official `dsh web` | `web` | First command below |
|
||||
| Official desktop EXE | `desktop` | Second command below |
|
||||
|
||||
### 2. Add the plugin with one command
|
||||
### 2. Add it to the profile (`dsh` or pnpm-only)
|
||||
|
||||
Web:
|
||||
Use `codeload.github.com`. Do not use `github.com/.../archive`: that 302 makes pnpm fail with `fetch failed`.
|
||||
|
||||
**If you have `dsh`:**
|
||||
|
||||
```sh
|
||||
dsh plugin --profile web add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz
|
||||
dsh plugin --profile web add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
|
||||
```
|
||||
|
||||
Desktop:
|
||||
Use `desktop` instead of `web` for the EXE. If this directory is already a clone, use `.` instead of the URL.
|
||||
|
||||
**pnpm only (no `dsh` required):** run this inside the profile you actually use, not the repo root.
|
||||
|
||||
```sh
|
||||
dsh plugin --profile desktop add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz
|
||||
cd "$DSH_HOME/profiles/web" # desktop: profiles/desktop
|
||||
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
|
||||
```
|
||||
|
||||
If this directory is already a clone, use `.` instead of the URL, e.g. `dsh plugin --profile web add .`. If `dsh` is not on PATH, use [Manual install](#manual) or a terminal from the desktop install folder.
|
||||
Windows PowerShell:
|
||||
|
||||
```powershell
|
||||
cd "$env:USERPROFILE\.dsh\profiles\web" # desktop: profiles\desktop
|
||||
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
|
||||
```
|
||||
|
||||
`pnpm add` fetches the package; `postinstall` writes `dsh-purge` into `dsh.profile.bundles`. If you passed `--ignore-scripts`, run:
|
||||
|
||||
```sh
|
||||
node node_modules/dsh-purge/scripts/ensure-profile-bundle.mjs
|
||||
```
|
||||
|
||||
Success: `node_modules/dsh-purge/package.json` exists and `"dsh-purge"` is in that profile's `bundles`. If neither `dsh` nor pnpm is available, use [Manual install](#manual).
|
||||
|
||||
For the desktop client you can also click the button (`dsh://` deep link; it still downloads the same tarball):
|
||||
|
||||
<p align="center">
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.75&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.78&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%2Fcodeload.github.com%2FYuJunZhiXue%2Fdsh-purge%2Ftar.gz%2Frefs%2Fheads%2Fmaster"><strong>Install in desktop client</strong></a>
|
||||
</p>
|
||||
|
||||
### 3. Three more clicks after the command
|
||||
@@ -194,11 +212,19 @@ Web controls affect Web only; desktop controls affect the desktop app only. Do n
|
||||
|
||||
### If the market says `already queued: dsh-purge`
|
||||
|
||||
Stop clicking the market. Use the tarball command in step 2. If the CLI also says it is already there:
|
||||
Stop clicking the market. Use `dsh plugin add` or pnpm from step 2 again. If the CLI also says it is already there:
|
||||
|
||||
```sh
|
||||
dsh plugin --profile desktop remove dsh-purge
|
||||
dsh plugin --profile desktop add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz
|
||||
dsh plugin --profile desktop add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
|
||||
```
|
||||
|
||||
pnpm only:
|
||||
|
||||
```sh
|
||||
cd "$DSH_HOME/profiles/desktop"
|
||||
pnpm remove dsh-purge
|
||||
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
|
||||
```
|
||||
|
||||
Swap `desktop` for `web` on Web. Then do step 3.
|
||||
@@ -212,17 +238,23 @@ Paste the block below to a local assistant. It should only run the install comma
|
||||
|
||||
<!-- AI-AGENT-START -->
|
||||
|
||||
Install the DeepSeek Harness plugin `dsh-purge` into the Web profile only. Do not scan the whole disk, do not read or edit other files, do not apply settings, and do not restart the app. Do not install into the desktop profile. Do not use the plugin marketplace or `github:yujunzhixue/dsh-purge`.
|
||||
Install the DeepSeek Harness plugin `dsh-purge` into the Web profile only. Do not scan the whole disk, do not read or edit other files, do not apply settings, and do not restart the app. Do not install into the desktop profile. Do not use the plugin marketplace. The name is not on the npm registry; do not `pnpm add dsh-purge`.
|
||||
|
||||
**Web (official `dsh web`)**
|
||||
|
||||
If `dsh` is not on PATH, tell the user and stop.
|
||||
If `dsh` is on PATH:
|
||||
|
||||
```sh
|
||||
dsh plugin --profile web add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz
|
||||
dsh plugin --profile web add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
|
||||
```
|
||||
|
||||
If this directory is already a clone, use `dsh plugin --profile web add .`. There is no npm package; do not `pnpm add dsh-purge`.
|
||||
If `dsh` is missing and pnpm is available, `cd` into `$DSH_HOME/profiles/web` (often `~/.dsh/profiles/web`) and run:
|
||||
|
||||
```sh
|
||||
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
|
||||
```
|
||||
|
||||
If this directory is already a clone and `dsh` exists, use `dsh plugin --profile web add .`. If neither `dsh` nor pnpm is available, tell the user and stop.
|
||||
|
||||
After the command finishes, tell the user to fully quit and restart `dsh web`, then open **dsh-purge** beside the session title and **Apply** on **Clean**. Then stop.
|
||||
|
||||
@@ -306,7 +338,7 @@ Success: `profiles/<web|desktop>/node_modules/dsh-purge/package.json` exists. If
|
||||
|
||||
### Uninstall
|
||||
|
||||
**dsh-purge** beside the session title → **Clean** → **Uninstall**. Confirm the dialog: it reverts any applied patches, restores the original Harness, and restarts the current host.
|
||||
**dsh-purge** beside the session title → **Clean** → **Uninstall**. Confirm the dialog: it reverts any applied patches, restores the original Harness, and restarts the current host. Disable or uninstall also resets an agent-preset default that still points at `redteam` back to `standard`, so the host can create sessions after the preset is gone.
|
||||
|
||||
```sh
|
||||
# or from a terminal / chat
|
||||
@@ -541,7 +573,7 @@ The author's personal channel: [t.me/LLM_PoJia](https://t.me/LLM_PoJia). Notes a
|
||||
- Scope is rendered copy, defaults, and runtime logic inside local `@deepseek-ai/*` packages, plus override files and rule sets under the harness home.
|
||||
- After an upgrade, unmatched originals show as skipped. Apply still completes, and those files are left unchanged.
|
||||
- Third-party plugin *source repos* outside `@deepseek-ai` are left alone (CMD silence may **best-effort** patch installed doctor / market / liangshen / mnemon at runtime).
|
||||
- Install from the GitHub archive (no npm package, no plugin market): `dsh plugin --profile web add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` (use profile `desktop` for the EXE). From this repo, `add .`.
|
||||
- Install from the GitHub tarball (the name is not on npm; skip the plugin market). With `dsh`: `dsh plugin --profile web add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master`. pnpm only: `pnpm add` that URL inside `$DSH_HOME/profiles/web`. Use `desktop` for the EXE. From this repo, `add .`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+54
-22
@@ -4,7 +4,7 @@
|
||||
|
||||
<h1 align="center">⚔️ DeepSeek Harness 网络安全红队工具(dsh-purge)</h1>
|
||||
|
||||
<p align="center"><strong>Version 1.1.75</strong></p>
|
||||
<p align="center"><strong>Version 1.1.78</strong></p>
|
||||
|
||||
<p align="center">
|
||||
<em>DeepSeek Harness 破甲:让所有模型都能破甲,不同模型可换不同提示词;默认提示词面向国模「小码酱」。Jailbreak for every model — swap prompts per model. 求 Star 收藏 ⭐ 如要二开,请查看署名要求部分</em>
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
## 介绍
|
||||
|
||||
**dsh-purge** 是装在本机官方 [DeepSeek Harness](https://www.deepseek.com/harness/) 上的网络安全红队评测插件。当前 **1.1.75** 已适配 **DSH 0.2.1-rc.2**(0.2.0 仍可用)。官方 **Web**(`dsh web`)和官方 **桌面端**(EXE)都支持,两边分开装、分开应用。
|
||||
**dsh-purge** 是装在本机官方 [DeepSeek Harness](https://www.deepseek.com/harness/) 上的网络安全红队评测插件。当前 **1.1.78** 已适配 **DSH 0.2.1-rc.2**(0.2.0 仍可用)。官方 **Web**(`dsh web`)和官方 **桌面端**(EXE)都支持,两边分开装、分开应用。
|
||||
|
||||
Harness 不只是把问题交给模型。它还会在运行时改提示词、审批门、沙箱和会话格式。只看「模型答不答」,会把宿主拦截误当成模型拒绝。这个插件在你自己的安装里把这两层分开,用来做受控评测,也用来看默认策略该不该收紧。
|
||||
|
||||
@@ -133,9 +133,9 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
|
||||
|
||||
## 适配范围
|
||||
|
||||
**1.1.75 已适配 DSH 0.2.1-rc.2**,0.2.0 仍可用。不要拿它去打 0.1.x。
|
||||
**1.1.78 已适配 DSH 0.2.1-rc.2**,0.2.0 仍可用。不要拿它去打 0.1.x。
|
||||
|
||||
- **dsh 0.2.1-rc.2**(官方桌面 / 官方 `dsh web`):用 **1.1.75**。已修 `{{cwd}}` / `[cwd]` 整轮失败、补丁 #40 命中、`toolFilter` 废弃、`dsh-tools` 解析、hostFs fd、桌面换包自杀、`file:` 归档更新、Ctrl+Enter 插话。
|
||||
- **dsh 0.2.1-rc.2**(官方桌面 / 官方 `dsh web`):用 **1.1.78**。已修 `{{cwd}}` / `[cwd]` 整轮失败、补丁 #40 命中、`toolFilter` 废弃、`dsh-tools` 解析、hostFs fd、桌面换包自杀、`file:` 归档更新、Ctrl+Enter 插话。
|
||||
- **dsh 0.2.0-rc.2**:用 **1.1.40** 及以上;本页这档也能装。
|
||||
- **dsh 0.1.7**(含 rc.1 / rc.2):用 **1.1.39** 及更早 —— 在 [Releases](https://github.com/YuJunZhiXue/dsh-purge/releases) 里选对应标签。
|
||||
|
||||
@@ -145,7 +145,7 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
|
||||
|
||||
## 安装
|
||||
|
||||
按下面三步走。**不要走插件市场**:[dsh-plugin.org](https://dsh-plugin.org) 或设置里的「插件市场」一键安装会报 `already queued: dsh-purge`,命令也走不成。npm 上没有这个包,不要 `pnpm add dsh-purge`,也不要 `github:yujunzhixue/dsh-purge`。
|
||||
按下面三步走。**不要走插件市场**:[dsh-plugin.org](https://dsh-plugin.org) 或设置里的「插件市场」一键安装会报 `already queued: dsh-purge`,命令也走不成。npm 仓库没有 `dsh-purge` 这个名字,不要 `pnpm add dsh-purge`;本机只有 pnpm 时走第 2 步里的 pnpm 地址。
|
||||
|
||||
### 1. 看你开的是哪一端
|
||||
|
||||
@@ -156,26 +156,44 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
|
||||
| 官方 `dsh web` | `web` | 下面第一条 |
|
||||
| 官方桌面 EXE | `desktop` | 下面第二条 |
|
||||
|
||||
### 2. 一条命令装进 profile
|
||||
### 2. 装进 profile(有 `dsh` 或只有 pnpm,走一条)
|
||||
|
||||
Web:
|
||||
压缩包走 `codeload.github.com`,不要用 `github.com/.../archive`:后者 302,pnpm 会 `fetch failed`。
|
||||
|
||||
**有 `dsh`:**
|
||||
|
||||
```sh
|
||||
dsh plugin --profile web add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz
|
||||
dsh plugin --profile web add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
|
||||
```
|
||||
|
||||
桌面:
|
||||
桌面把 `web` 换成 `desktop`。当前目录已是本仓库时,把网址换成 `.`。
|
||||
|
||||
**只有 pnpm(没有 `dsh` 也行):** 进正在用的那个 profile,不要在仓库根执行。
|
||||
|
||||
```sh
|
||||
dsh plugin --profile desktop add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz
|
||||
cd "$DSH_HOME/profiles/web" # 桌面改 profiles/desktop
|
||||
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
|
||||
```
|
||||
|
||||
当前目录已经是本仓库时,把网址换成 `.`,例如 `dsh plugin --profile web add .`。`dsh` 不在 PATH 时走 [手动安装](#manual),或在桌面安装目录里开终端。
|
||||
Windows PowerShell:
|
||||
|
||||
桌面客户端也可以点按钮(`dsh://` 唤起,下的仍是上面那个压缩包):
|
||||
```powershell
|
||||
cd "$env:USERPROFILE\.dsh\profiles\web" # 桌面改 profiles\desktop
|
||||
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
|
||||
```
|
||||
|
||||
`pnpm add` 会拉包;`postinstall` 再把 `dsh-purge` 写进 `dsh.profile.bundles`。若加了 `--ignore-scripts`,再跑:
|
||||
|
||||
```sh
|
||||
node node_modules/dsh-purge/scripts/ensure-profile-bundle.mjs
|
||||
```
|
||||
|
||||
成功标志:`node_modules/dsh-purge/package.json` 在,且 profile 的 `bundles` 里有 `"dsh-purge"`。`dsh` 和 pnpm 都没有时走 [手动安装](#manual)。
|
||||
|
||||
桌面客户端也可以点按钮(`dsh://` 唤起,下的仍是同一份压缩包):
|
||||
|
||||
<p align="center">
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.75&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>
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.78&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%2Fcodeload.github.com%2FYuJunZhiXue%2Fdsh-purge%2Ftar.gz%2Frefs%2Fheads%2Fmaster"><strong>唤起客户端一键安装</strong></a>
|
||||
</p>
|
||||
|
||||
### 3. 装完还要做这三下
|
||||
@@ -196,14 +214,22 @@ Web 的按钮只动 Web,桌面的只动桌面。不要在一个里面点另一
|
||||
|
||||
### 市场报 `already queued: dsh-purge` 时
|
||||
|
||||
不要再点市场。按第 2 步用压缩包命令装。命令也说已经有了,就先卸再装:
|
||||
不要再点市场。按第 2 步用 `dsh plugin add` 或 pnpm 再装一遍。命令也说已经有了,就先卸再装:
|
||||
|
||||
```sh
|
||||
dsh plugin --profile desktop remove dsh-purge
|
||||
dsh plugin --profile desktop add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz
|
||||
dsh plugin --profile desktop add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
|
||||
```
|
||||
|
||||
Web 把两处 `desktop` 都换成 `web`。然后再走第 3 步。
|
||||
只有 pnpm 时:
|
||||
|
||||
```sh
|
||||
cd "$DSH_HOME/profiles/desktop"
|
||||
pnpm remove dsh-purge
|
||||
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
|
||||
```
|
||||
|
||||
Web 把 `desktop` 换成 `web`。然后再走第 3 步。
|
||||
|
||||
### 交给助手安装
|
||||
|
||||
@@ -214,17 +240,23 @@ Web 把两处 `desktop` 都换成 `web`。然后再走第 3 步。
|
||||
|
||||
<!-- AI-AGENT-START -->
|
||||
|
||||
安装 DeepSeek Harness 插件 `dsh-purge`,只装到 Web profile。不要全盘搜索,不要读或改其它文件,不要应用设置,也不要重启应用。不要装到桌面 profile。不要走插件市场,不要 `github:yujunzhixue/dsh-purge`。
|
||||
安装 DeepSeek Harness 插件 `dsh-purge`,只装到 Web profile。不要全盘搜索,不要读或改其它文件,不要应用设置,也不要重启应用。不要装到桌面 profile。不要走插件市场。npm 仓库没有这个包名,不要 `pnpm add dsh-purge`。
|
||||
|
||||
**Web 端(官方 `dsh web`)**
|
||||
|
||||
`dsh` 不在 PATH 就告诉用户后停止。
|
||||
有 `dsh`:
|
||||
|
||||
```sh
|
||||
dsh plugin --profile web add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz
|
||||
dsh plugin --profile web add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
|
||||
```
|
||||
|
||||
当前目录已是本仓库时改用 `dsh plugin --profile web add .`。没有 npm 包,不要 `pnpm add dsh-purge`。
|
||||
没有 `dsh`、只有 pnpm:找到 `$DSH_HOME/profiles/web`(常见 `~/.dsh/profiles/web`),在该目录执行:
|
||||
|
||||
```sh
|
||||
pnpm add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master
|
||||
```
|
||||
|
||||
当前目录已是本仓库且有 `dsh` 时改用 `dsh plugin --profile web add .`。`dsh` 和 pnpm 都没有再告诉用户后停止。
|
||||
|
||||
命令结束后,提醒用户:完全退出并重启 `dsh web`,再点会话标题旁的 **dsh-purge**,在「清洗」里点「应用」。然后停止。
|
||||
|
||||
@@ -308,7 +340,7 @@ pnpm install
|
||||
|
||||
### 卸载
|
||||
|
||||
会话标题旁的 **dsh-purge** →「清洗」→「卸载」。弹窗确认:会先还原已应用的补丁,还原回原版 Harness,再重启当前宿主。
|
||||
会话标题旁的 **dsh-purge** →「清洗」→「卸载」。弹窗确认:会先还原已应用的补丁,还原回原版 Harness,再重启当前宿主。停用或卸载时会把「智能体预设」里指向红队模式的默认值改回 `standard`,避免宿主因找不到 `redteam` 而无法新建会话。
|
||||
|
||||
```sh
|
||||
# 也可以用命令行 / 聊天
|
||||
@@ -550,7 +582,7 @@ flowchart TD
|
||||
- 改动范围是本机 `@deepseek-ai/*` 包里的渲染文案、默认策略和执行逻辑,以及用户目录下的覆盖文件与规则集。
|
||||
- 升级后原文对不上会显示跳过,这次应用仍算完成,不会乱改。
|
||||
- 不改动非 `@deepseek-ai` 的第三方插件源仓库(启动时的 CMD 无感会**尽力**修补已装的 doctor / market / 梁神 / mnemon,属运行时补丁)。
|
||||
- 安装走 GitHub 归档(npm 上没有这个包,也不要走插件市场):`dsh plugin --profile web add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz`(桌面端把 profile 换成 `desktop`)。当前目录已是本仓库时 `add .`。
|
||||
- 安装走 GitHub 压缩包(npm 仓库没有这个名字,也不要走插件市场)。有 `dsh`:`dsh plugin --profile web add https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master`。只有 pnpm:在 `$DSH_HOME/profiles/web` 里 `pnpm add` 同一地址。桌面把 `web` 换成 `desktop`。当前目录已是本仓库时 `add .`。
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -27,6 +27,12 @@ import * as continueRetry from "./continue-retry.js";
|
||||
import * as uninstaller from "./uninstall.js";
|
||||
import { readDrillGrant, writeDrillGrant } from "./drill-grant.js";
|
||||
import { installRegionGate, readAllowText, writeAllowText } from "./net-scope.js";
|
||||
import {
|
||||
cancelClearOwnedSelectedDefault,
|
||||
clearOwnedSelectedDefault,
|
||||
removeStaleAgentPresetDir,
|
||||
scheduleClearOwnedSelectedDefault,
|
||||
} from "./preset-default.js";
|
||||
import {
|
||||
applyShouldRestart,
|
||||
isInactiveContextError,
|
||||
@@ -1455,8 +1461,16 @@ export function apply(ctx, config) {
|
||||
const cfg = { ...DEFAULTS, ...(config || {}) };
|
||||
if (!cfg.enabled) {
|
||||
purgeLog("boot", { enabled: false });
|
||||
try { clearOwnedSelectedDefault({ ctx, dshHome: core.findDshHome() }); } catch { /* 停用不被清默认挡住 */ }
|
||||
try { removeStaleAgentPresetDir(core.findDshHome(), "redteam"); } catch { /* ignore */ }
|
||||
return;
|
||||
}
|
||||
cancelClearOwnedSelectedDefault();
|
||||
try {
|
||||
ctx.effect(() => () => {
|
||||
try { scheduleClearOwnedSelectedDefault({ ctx, dshHome: core.findDshHome() }); } catch { /* 停用不被清默认挡住 */ }
|
||||
});
|
||||
} catch { /* 无 effect 时靠 uninstall / enabled:false 清 */ }
|
||||
purgeLog("boot", {
|
||||
enabled: true,
|
||||
surface: hostctl.currentSurface(),
|
||||
|
||||
+148
-23
@@ -241,7 +241,7 @@ const DENIAL = "不行,这是严令禁止的";
|
||||
// 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;
|
||||
/渗透测试|红队|打点|拿站|渗透(?!测试)|打穿|打下|打站|入侵|拿壳|拿权限|爆破|提权|webshell|getshell|端口扫描|pentest|\bexploit\b(?![-a-z0-9])|\bbreach\b|\bpwn\b|(?<!防御)攻击(?!面)|(?<!surface\s)\battack\b(?!\s+surface)/i;
|
||||
|
||||
// 外挂硬拦。单字「辅助 / 透视」太容易误伤辅助函数、透视投影,必须带游戏或挂本身。
|
||||
const CHEAT_STRONG =
|
||||
@@ -251,9 +251,9 @@ const CHEAT_GAME =
|
||||
const CHEAT_WEAK =
|
||||
/内存修改|读内存|写内存|dll注入/i;
|
||||
|
||||
// ReDoS 保险:ATTACK 含零宽环视,整段消息(贴代码/日志)超过 100KB 时正则回溯会把事件循环卡死。
|
||||
// 真实攻击意图通常在前几千字符,100KB cap 不会误放过。
|
||||
const ATTACK_SCAN_CAP = 100 * 1024;
|
||||
// ReDoS 保险:ATTACK 含零宽环视,整段消息(贴代码/日志)超过上限时按窗扫,不一次喂整篇。
|
||||
const ATTACK_SCAN_CAP = 256 * 1024;
|
||||
const ATTACK_WINDOW = 8192;
|
||||
|
||||
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;
|
||||
@@ -490,13 +490,25 @@ function taskHit(label, kind) {
|
||||
export function isBenignNetworkTopic(text) {
|
||||
const t = String(text || "").trim();
|
||||
if (!t || !NET_TOPIC.test(t)) return false;
|
||||
return !ATTACK.test(t.length > ATTACK_SCAN_CAP ? t.slice(0, ATTACK_SCAN_CAP) : t);
|
||||
return !scanHas(ATTACK, t);
|
||||
}
|
||||
|
||||
function scanHas(re, text) {
|
||||
const sample = String(text || "");
|
||||
const cap = Math.min(sample.length, ATTACK_SCAN_CAP);
|
||||
if (!cap) return false;
|
||||
if (cap <= ATTACK_WINDOW) return re.test(sample.slice(0, cap));
|
||||
const hop = ATTACK_WINDOW - 256;
|
||||
for (let i = 0; i < cap; i += hop) {
|
||||
if (re.test(sample.slice(i, i + ATTACK_WINDOW))) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isAttackTask(text) {
|
||||
const sample = String(text || "");
|
||||
if (isBenignNetworkTopic(sample)) return false;
|
||||
return ATTACK.test(sample.length > ATTACK_SCAN_CAP ? sample.slice(0, ATTACK_SCAN_CAP) : sample);
|
||||
return scanHas(ATTACK, sample);
|
||||
}
|
||||
|
||||
export function isCheatTask(text) {
|
||||
@@ -508,13 +520,19 @@ export function isCheatTask(text) {
|
||||
|
||||
function hostsInTask(text) {
|
||||
const hosts = new Set();
|
||||
const sample = String(text || "").slice(0, 32768);
|
||||
collectFromText(sample, hosts);
|
||||
const sample = String(text || "");
|
||||
const cap = Math.min(sample.length, ATTACK_SCAN_CAP);
|
||||
const win = 32768;
|
||||
const hop = 28672;
|
||||
const labeled = /(?:[a-z0-9\u00a1-\uffff](?:[a-z0-9\u00a1-\uffff-]{0,61}[a-z0-9\u00a1-\uffff])?\.)+(?:[a-z]{2,63}|xn--[a-z0-9-]{2,59}|[\u4e00-\u9fff]{2,12})/giu;
|
||||
for (const match of sample.matchAll(labeled)) {
|
||||
const name = match[0].toLowerCase().replace(/\.$/, "");
|
||||
if (!keepBareDomain(sample, match.index, name)) continue;
|
||||
addHost(name, hosts);
|
||||
for (let i = 0; i < cap; i += hop) {
|
||||
const chunk = sample.slice(i, i + win);
|
||||
collectFromText(chunk, hosts);
|
||||
for (const match of chunk.matchAll(labeled)) {
|
||||
const name = match[0].toLowerCase().replace(/\.$/, "");
|
||||
if (!keepBareDomain(chunk, match.index, name)) continue;
|
||||
addHost(name, hosts);
|
||||
}
|
||||
}
|
||||
return hosts;
|
||||
}
|
||||
@@ -532,14 +550,13 @@ async function isRangeTarget(name) {
|
||||
return ips.every((ip) => isLocalLabAddress(ip));
|
||||
}
|
||||
|
||||
export async function taskTargetHit(text) {
|
||||
if (!isAttackTask(text)) return null;
|
||||
export async function publicHostHit(text) {
|
||||
const names = [];
|
||||
for (const host of hostsInTask(text)) {
|
||||
const name = hostOf(host);
|
||||
if (name) names.push(name);
|
||||
}
|
||||
if (!names.length) return taskHit("unspecified", "domain");
|
||||
if (!names.length) return null;
|
||||
for (const name of names) {
|
||||
if (await isRangeTarget(name)) continue;
|
||||
return taskHit(name, isIp(name) ? "ip" : bankHit(name) ? "bank" : "domain");
|
||||
@@ -547,6 +564,76 @@ export async function taskTargetHit(text) {
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function taskTargetHit(text) {
|
||||
if (!isAttackTask(text)) return null;
|
||||
let found = false;
|
||||
for (const host of hostsInTask(text)) {
|
||||
if (hostOf(host)) found = true;
|
||||
}
|
||||
if (!found) return taskHit("unspecified", "domain");
|
||||
return publicHostHit(text);
|
||||
}
|
||||
|
||||
function blobOf(value, depth = 0) {
|
||||
if (value == null || depth > 3) return "";
|
||||
if (typeof value === "string" || typeof value === "number") return String(value);
|
||||
if (Array.isArray(value)) return value.map((item) => blobOf(item, depth + 1)).join("\n");
|
||||
if (typeof value !== "object") return "";
|
||||
const skip = new Set(["agent", "session", "ctx", "next", "signal", "context"]);
|
||||
return Object.entries(value)
|
||||
.filter(([key]) => !skip.has(key))
|
||||
.map(([, item]) => blobOf(item, depth + 1))
|
||||
.join("\n")
|
||||
.slice(0, 32768);
|
||||
}
|
||||
|
||||
function toolArgText(message) {
|
||||
const parts = [];
|
||||
const calls = message?.toolCalls || message?.tool_calls || [];
|
||||
for (const call of Array.isArray(calls) ? calls : []) {
|
||||
parts.push(blobOf(call.arguments ?? call.input ?? call.params ?? call));
|
||||
}
|
||||
if (Array.isArray(message?.content)) {
|
||||
for (const block of message.content) {
|
||||
if (!block || typeof block !== "object") continue;
|
||||
if (block.type === "tool_use" || block.type === "tool-call" || block.type === "tool-call-start") {
|
||||
parts.push(blobOf(block.input ?? block.arguments ?? block));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (message?.toolName || message?.name) parts.push(String(message.toolName || message.name));
|
||||
return parts.join("\n");
|
||||
}
|
||||
|
||||
export function latestToolText(messages) {
|
||||
const list = Array.isArray(messages) ? messages : [];
|
||||
const parts = [];
|
||||
for (let i = list.length - 1; i >= 0 && parts.length < 6; i -= 1) {
|
||||
const role = list[i]?.role;
|
||||
if (role !== "assistant" && role !== "model") continue;
|
||||
const blob = toolArgText(list[i]);
|
||||
if (blob.trim()) parts.push(blob);
|
||||
}
|
||||
return parts.join("\n");
|
||||
}
|
||||
|
||||
export function execArgText(exec) {
|
||||
if (!exec || typeof exec !== "object") return "";
|
||||
return blobOf({
|
||||
name: exec.tool?.name || exec.name || exec.toolName,
|
||||
args: exec.args ?? exec.input ?? exec.parameters ?? exec.params,
|
||||
command: exec.command,
|
||||
call: exec.toolCall ?? exec.call,
|
||||
});
|
||||
}
|
||||
|
||||
function isRedteamPayload(payload) {
|
||||
const session = payload?.agent?.session || payload?.session;
|
||||
const raw = session?.agentPreset || session?.header?.agentPreset || session?.projectionValues?.agentPreset || payload?.agent?.preset;
|
||||
const id = String(raw?.id || raw?.name || raw || "").toLowerCase();
|
||||
return id.includes("redteam");
|
||||
}
|
||||
|
||||
function messageBody(message) {
|
||||
if (typeof message?.content === "string") return message.content;
|
||||
if (!Array.isArray(message?.content)) return typeof message?.text === "string" ? message.text : "";
|
||||
@@ -664,13 +751,15 @@ async function parkDenial(payload) {
|
||||
const session = sessionOf(payload);
|
||||
const turn = Number(payload?.turn);
|
||||
const step = Number(payload?.step);
|
||||
if (!session || !Number.isSafeInteger(turn) || step !== 1) return false;
|
||||
if (!session || !Number.isSafeInteger(turn) || !Number.isSafeInteger(step) || step < 1) return false;
|
||||
const messages = Array.isArray(payload?.messages) ? payload.messages : [];
|
||||
let outerOpened = false;
|
||||
let innerOpened = false;
|
||||
try {
|
||||
for (const message of messages) {
|
||||
session.append("user/message", message, { surfaceOp: "append" });
|
||||
if (step === 1) {
|
||||
for (const message of messages) {
|
||||
session.append("user/message", message, { surfaceOp: "append" });
|
||||
}
|
||||
}
|
||||
session.append("step/start", { turn, step });
|
||||
outerOpened = true;
|
||||
@@ -696,18 +785,37 @@ async function parkDenial(payload) {
|
||||
}
|
||||
}
|
||||
|
||||
function denyToolResult() {
|
||||
return { isError: true, content: DENIAL, output: DENIAL, text: DENIAL };
|
||||
}
|
||||
|
||||
export function installRegionGate(ctx) {
|
||||
if (!ctx || typeof ctx.on !== "function") return;
|
||||
const scoped = new WeakMap();
|
||||
const hook = async (payload, next) => {
|
||||
const forward = () => (typeof next === "function" ? next() : { kind: "enter", messages: payload?.messages || [] });
|
||||
if (Number(payload?.step) !== 1) return forward();
|
||||
const step = Number(payload?.step);
|
||||
const turn = Number(payload?.turn);
|
||||
const session = sessionOf(payload) || payload?.agent?.session;
|
||||
let hit = null;
|
||||
try {
|
||||
const task = currentTaskText(payload?.messages);
|
||||
if (!task) return forward();
|
||||
if (isCheatTask(task)) hit = taskHit("cheat", "cheat");
|
||||
else if (isAttackTask(task)) hit = await taskTargetHit(task);
|
||||
else return forward();
|
||||
const redteam = isRedteamPayload(payload);
|
||||
const marked = session ? scoped.get(session) === turn : false;
|
||||
if (step === 1) {
|
||||
if (!task && !redteam) return forward();
|
||||
if (task && isCheatTask(task)) hit = taskHit("cheat", "cheat");
|
||||
else if (task && isAttackTask(task)) {
|
||||
if (session && Number.isSafeInteger(turn)) scoped.set(session, turn);
|
||||
hit = await taskTargetHit(task);
|
||||
} else if (redteam) {
|
||||
if (session && Number.isSafeInteger(turn)) scoped.set(session, turn);
|
||||
hit = task ? await publicHostHit(task) : null;
|
||||
} else return forward();
|
||||
} else if (redteam || marked || isAttackTask(task)) {
|
||||
if (isCheatTask(task)) hit = taskHit("cheat", "cheat");
|
||||
else hit = await publicHostHit(latestToolText(payload?.messages));
|
||||
} else return forward();
|
||||
} catch {
|
||||
return forward();
|
||||
}
|
||||
@@ -720,10 +828,27 @@ export function installRegionGate(ctx) {
|
||||
}
|
||||
return forward();
|
||||
};
|
||||
const toolHook = async (exec, next) => {
|
||||
const forward = () => (typeof next === "function" ? next() : denyToolResult());
|
||||
try {
|
||||
const blob = execArgText(exec);
|
||||
if (!blob.trim()) return forward();
|
||||
const hit = await publicHostHit(blob);
|
||||
if (!hit) return forward();
|
||||
} catch {
|
||||
return forward();
|
||||
}
|
||||
if (exec && typeof exec === "object") {
|
||||
exec.blocked = true;
|
||||
exec.error = DENIAL;
|
||||
}
|
||||
return denyToolResult();
|
||||
};
|
||||
const arm = () => {
|
||||
if (ctx.__dshPurgeRegionGate) return true;
|
||||
try {
|
||||
ctx.on("agent/pre-step", hook, { global: true, prepend: true });
|
||||
try { ctx.on("tools/pre-execute", toolHook, { global: true, prepend: true }); } catch { /* 旧宿主没有工具钩。 */ }
|
||||
ctx.__dshPurgeRegionGate = true;
|
||||
return true;
|
||||
} catch {
|
||||
|
||||
+26
-2
@@ -38,8 +38,10 @@ function listProfilePatchFiles(dshHome) {
|
||||
}
|
||||
for (const name of names) {
|
||||
if (name === "node_modules") continue;
|
||||
const fp = path.join(root, name, "cordis.patch.yml");
|
||||
if (fs.existsSync(fp)) out.push(fp);
|
||||
for (const file of ["cordis.patch.yml", "cordis.yml"]) {
|
||||
const fp = path.join(root, name, file);
|
||||
if (fs.existsSync(fp)) out.push(fp);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -167,6 +169,28 @@ export function clearOwnedSelectedDefault({ ctx = null, dshHome = "" } = {}) {
|
||||
return report;
|
||||
}
|
||||
|
||||
let pendingClear = null;
|
||||
|
||||
/** 热重载会先 dispose 再 apply:延迟写盘,apply 进来就取消,避免把用户的红队默认冲掉。 */
|
||||
export function scheduleClearOwnedSelectedDefault(opts = {}) {
|
||||
if (pendingClear) {
|
||||
clearTimeout(pendingClear);
|
||||
pendingClear = null;
|
||||
}
|
||||
pendingClear = setTimeout(() => {
|
||||
pendingClear = null;
|
||||
try { clearOwnedSelectedDefault(opts); } catch { /* 停用不被清默认挡住 */ }
|
||||
try { removeStaleAgentPresetDir(opts.dshHome, "redteam"); } catch { /* ignore */ }
|
||||
}, 800);
|
||||
if (typeof pendingClear.unref === "function") pendingClear.unref();
|
||||
}
|
||||
|
||||
export function cancelClearOwnedSelectedDefault() {
|
||||
if (!pendingClear) return;
|
||||
clearTimeout(pendingClear);
|
||||
pendingClear = null;
|
||||
}
|
||||
|
||||
export function removeStaleAgentPresetDir(dshHome, id = "redteam") {
|
||||
const home = dshHome || findDshHome();
|
||||
if (!home || !id) return false;
|
||||
|
||||
@@ -11,6 +11,7 @@ import { homedir } from 'node:os'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { readPresetDefinition } from './preset-composition.js'
|
||||
import { scheduleClearOwnedSelectedDefault } from '../preset-default.js'
|
||||
|
||||
/** Cordis 插件名。 */
|
||||
export const name = 'dsh-purge-redteam'
|
||||
@@ -605,6 +606,7 @@ export function apply(ctx) {
|
||||
closed = true
|
||||
if (timer) clearInterval(timer)
|
||||
if (stop) clearTimeout(stop)
|
||||
try { scheduleClearOwnedSelectedDefault({ ctx }) } catch { /* 清默认失败不挡停用 */ }
|
||||
void undeclare()
|
||||
}
|
||||
}, 'dsh-purge-redteam: declare agent preset')
|
||||
|
||||
+33
-13
@@ -6,6 +6,7 @@ import * as hostctl from "./host.js";
|
||||
import * as rules from "./rules.js";
|
||||
import * as updater from "./update.js";
|
||||
import { clearDrillGrant } from "./drill-grant.js";
|
||||
import { clearOwnedSelectedDefault, removeStaleAgentPresetDir } from "./preset-default.js";
|
||||
|
||||
export function wasApplied(state) {
|
||||
if (!state) return false;
|
||||
@@ -34,6 +35,18 @@ export function shouldDeletePluginTree(dir, dshHome = core.findDshHome()) {
|
||||
return n.startsWith(`${homeN}/profiles/`);
|
||||
}
|
||||
|
||||
function isPurgeBundleItem(item) {
|
||||
if (typeof item === "string") return item === "dsh-purge" || item.startsWith("dsh-purge@");
|
||||
const id = item && (item.id || item.name);
|
||||
return id === "dsh-purge";
|
||||
}
|
||||
|
||||
function stripBundleList(list) {
|
||||
if (!Array.isArray(list)) return { list, changed: false };
|
||||
const next = list.filter((item) => !isPurgeBundleItem(item));
|
||||
return { list: next, changed: next.length !== list.length };
|
||||
}
|
||||
|
||||
export function stripPluginFromPackage(pkg) {
|
||||
if (!pkg || typeof pkg !== "object") return false;
|
||||
let changed = false;
|
||||
@@ -44,14 +57,15 @@ export function stripPluginFromPackage(pkg) {
|
||||
}
|
||||
}
|
||||
for (const key of ["bundles", "plugins"]) {
|
||||
if (!Array.isArray(pkg[key])) continue;
|
||||
const next = pkg[key].filter((item) => {
|
||||
if (typeof item === "string") return item !== "dsh-purge" && !item.startsWith("dsh-purge@");
|
||||
const id = item && (item.id || item.name);
|
||||
return id !== "dsh-purge";
|
||||
});
|
||||
if (next.length !== pkg[key].length) {
|
||||
pkg[key] = next;
|
||||
const top = stripBundleList(pkg[key]);
|
||||
if (top.changed) {
|
||||
pkg[key] = top.list;
|
||||
changed = true;
|
||||
}
|
||||
const nested = pkg.dsh && pkg.dsh.profile ? pkg.dsh.profile[key] : null;
|
||||
const nest = stripBundleList(nested);
|
||||
if (nest.changed) {
|
||||
pkg.dsh.profile[key] = nest.list;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
@@ -74,11 +88,9 @@ function pkgMentionsPurge(pkg) {
|
||||
if (!pkg) return false;
|
||||
if (pkg.dependencies?.["dsh-purge"] || pkg.devDependencies?.["dsh-purge"]) return true;
|
||||
for (const key of ["bundles", "plugins"]) {
|
||||
if (!Array.isArray(pkg[key])) continue;
|
||||
if (pkg[key].some((item) => {
|
||||
if (typeof item === "string") return item === "dsh-purge" || item.startsWith("dsh-purge@");
|
||||
return item && (item.id === "dsh-purge" || item.name === "dsh-purge");
|
||||
})) return true;
|
||||
if (Array.isArray(pkg[key]) && pkg[key].some(isPurgeBundleItem)) return true;
|
||||
const nested = pkg.dsh && pkg.dsh.profile ? pkg.dsh.profile[key] : null;
|
||||
if (Array.isArray(nested) && nested.some(isPurgeBundleItem)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -254,6 +266,14 @@ export async function uninstallPurge() {
|
||||
report.errors.push(`reset rules: ${e.message || e}`);
|
||||
}
|
||||
|
||||
try {
|
||||
const preset = clearOwnedSelectedDefault({ dshHome });
|
||||
report.presetDefault = { live: preset.live, files: preset.files };
|
||||
report.stalePresetDir = removeStaleAgentPresetDir(dshHome, "redteam");
|
||||
} catch (e) {
|
||||
report.errors.push(`clear selectedDefault: ${e.message || e}`);
|
||||
}
|
||||
|
||||
const profiles = listInstalledProfiles(dshHome);
|
||||
report.profiles = profiles.map((p) => p.name);
|
||||
const unreg = unregisterProfiles(profiles);
|
||||
|
||||
+5
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dsh-purge",
|
||||
"version": "1.1.75",
|
||||
"version": "1.1.78",
|
||||
"description": "DeepSeek Harness 破甲:让所有模型都能破甲,不同模型可换不同提示词;默认提示词面向国模「小码酱」。Jailbreak for every model — swap prompts per model. 求 Star 收藏 ⭐ 如要二开,请查看署名要求部分",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
@@ -35,7 +35,8 @@
|
||||
],
|
||||
"scripts": {
|
||||
"embed-prompt": "node scripts/embed-default-prompt.mjs",
|
||||
"build:client": "node scripts/build-client.mjs"
|
||||
"build:client": "node scripts/build-client.mjs",
|
||||
"postinstall": "node scripts/ensure-profile-bundle.mjs"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"keywords": [
|
||||
@@ -78,8 +79,8 @@
|
||||
},
|
||||
"install": {
|
||||
"preferred": "tarball",
|
||||
"tarball": "https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz",
|
||||
"zip": "https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.zip",
|
||||
"tarball": "https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master",
|
||||
"zip": "https://codeload.github.com/YuJunZhiXue/dsh-purge/zip/refs/heads/master",
|
||||
"git": "https://github.com/YuJunZhiXue/dsh-purge.git"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,3 +1,45 @@
|
||||
# 1.1.78
|
||||
|
||||
## 中文
|
||||
|
||||
- 版本 **1.1.78**。修复 bug:停用/卸载后无法新建会话。
|
||||
- **#108**:停用或卸载时把 `agent-preset-registry.selectedDefault` 从 `redteam` 改回 `standard`,并清掉 `$DSH_HOME/.agent-presets/redteam`。热重载不会冲掉用户设的红队默认。
|
||||
- 卸载同时处理 `dsh.profile.bundles` / `dsh.profile.plugins`,桌面 profile 不再残留 `dsh-purge`。
|
||||
|
||||
## English
|
||||
|
||||
- **1.1.78**. Bug fix: new sessions after disable/uninstall.
|
||||
- **#108**: on disable or uninstall, reset `agent-preset-registry.selectedDefault` from `redteam` to `standard`, and remove `$DSH_HOME/.agent-presets/redteam`. Hot reload keeps a user-chosen redteam default.
|
||||
- Uninstall also strips `dsh.profile.bundles` / `dsh.profile.plugins`.
|
||||
|
||||
# 1.1.77
|
||||
|
||||
## 中文
|
||||
|
||||
- 版本 **1.1.77**。修复 bug,修复稳定性。
|
||||
- 修长红队任务仍打公网:`渗透测试` / `红队` / `打点` / `拿站` 纳入门禁;正文按窗扫到 256KB,目标写在后半段也能拦。
|
||||
- 修后续步骤漏拦:每一步看工具参数,`tools/pre-execute` 遇到公网 IP/域名直接停轮。
|
||||
- 长文正则按窗扫,避免整篇回溯把事件循环卡死。
|
||||
|
||||
## English
|
||||
|
||||
- **1.1.77**. Bug fixes and stability.
|
||||
- Long red-team tasks no longer reach the public internet: `渗透测试` / red-team / 打点 / 拿站 are gated; the body is scanned in windows up to 256KB.
|
||||
- Later steps are gated too: tool arguments are checked, and `tools/pre-execute` stops on a public IP or name.
|
||||
- Long-text regex runs in windows so a huge paste cannot stall the event loop.
|
||||
|
||||
# 1.1.76
|
||||
|
||||
## 中文
|
||||
|
||||
- 版本 **1.1.76**。适配只走 pnpm 的机器:在 profile 目录 `pnpm add` codeload 压缩包即可,`postinstall` 自动把 `dsh-purge` 写进 `bundles`。
|
||||
- 安装地址改成 `codeload.github.com`,避开 `github.com/archive` 的 302(pnpm 会 `fetch failed`)。不要 `pnpm add dsh-purge`(npm 仓库没有这个名字)。
|
||||
|
||||
## English
|
||||
|
||||
- **1.1.76**. pnpm-only hosts: `pnpm add` the codeload tarball inside the profile; `postinstall` writes `dsh-purge` into `bundles`.
|
||||
- Install URL is `codeload.github.com` so pnpm does not die on the `github.com/archive` 302. Do not `pnpm add dsh-purge` — that name is not on the npm registry.
|
||||
|
||||
# 1.1.75
|
||||
|
||||
## 中文
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* pnpm add 只写 dependencies,不会把插件写进 dsh.profile.bundles。
|
||||
* 装进 DSH profile 时补上这一笔;在插件仓库里跑 pnpm install 则跳过。
|
||||
*/
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const NAME = "dsh-purge";
|
||||
|
||||
function readJson(fp) {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(fp, "utf8"));
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function isProfilePkg(pkg) {
|
||||
if (!pkg || typeof pkg !== "object") return false;
|
||||
if (typeof pkg.name === "string" && pkg.name.startsWith("dsh-profile-")) return true;
|
||||
return Array.isArray(pkg.dsh?.profile?.bundles);
|
||||
}
|
||||
|
||||
function findProfileDir() {
|
||||
const seeds = [process.env.INIT_CWD, process.env.npm_config_local_prefix, process.cwd()].filter(Boolean);
|
||||
for (const seed of seeds) {
|
||||
let dir = path.resolve(seed);
|
||||
for (let i = 0; i < 8; i += 1) {
|
||||
if (isProfilePkg(readJson(path.join(dir, "package.json")))) return dir;
|
||||
const parent = path.dirname(dir);
|
||||
if (parent === dir) break;
|
||||
dir = parent;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
const profileDir = findProfileDir();
|
||||
if (!profileDir) process.exit(0);
|
||||
|
||||
const fp = path.join(profileDir, "package.json");
|
||||
const pkg = readJson(fp);
|
||||
if (!pkg) {
|
||||
process.stderr.write(`dsh-purge: cannot read ${fp}\n`);
|
||||
process.exit(1);
|
||||
}
|
||||
pkg.dsh = pkg.dsh && typeof pkg.dsh === "object" ? pkg.dsh : {};
|
||||
pkg.dsh.profile = pkg.dsh.profile && typeof pkg.dsh.profile === "object" ? pkg.dsh.profile : {};
|
||||
const bundles = Array.isArray(pkg.dsh.profile.bundles) ? pkg.dsh.profile.bundles : [];
|
||||
if (bundles.includes(NAME)) {
|
||||
process.stdout.write(`dsh-purge: already in bundles (${profileDir})\n`);
|
||||
process.exit(0);
|
||||
}
|
||||
pkg.dsh.profile.bundles = [...bundles, NAME];
|
||||
fs.writeFileSync(fp, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
|
||||
process.stdout.write(`dsh-purge: appended to bundles (${profileDir})\n`);
|
||||
Reference in new issue
Block a user