dsh-redteam-model
SeaOf0
基于dsh web实现的多种模式,目的是服务于redteam进行授权的安全研究,覆盖渗透测试、红队评估、代码审计等范围领域,请勿用于非法行为。(允许二开,赋予模块各位自己的业务逻辑,方法论只有自己熟练的才好用,好的方法论=好的生态)
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:siml1169/ShyPie
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
Privacy-first workflow for DeepSeek Harness + Magpie
Keep PII on your machine: images and PDFs are converted to text locally, the local transcript stays readable by default, and Magpie masks the text before it leaves the machine. Anything that cannot be masked or filtered is blocked, not sent.
This repository is a reference implementation of a two-plugin combo for DeepSeek Harness (DSH) and Magpie:
| Component | npm package | Role |
|---|---|---|
plugins/dsh-privacy-gate |
@shypie_privacy/dsh-privacy-gate |
ShyPie Filter DSH host bundle: extracts attached images/PDFs locally, keeps tool/document text local by default, guards binary reads, and enforces a fail-closed llm/stream egress guard |
| Magpie middleware (in-tree) | @magpie-community/middleware-privacy-gate |
Magpie gateway middleware: rejects or withholds content Magpie cannot mask (images, files, encoded blobs) for non-local models; binaryPolicy: guide withholds bytes and asks the model to choose a local extraction tool; per-agent page/panel/action controls |
packages/pii-core |
@shypie_privacy/pii-core |
Zero-dependency detector + keyed-placeholder library shared by both plugins |
packages/local-extract |
@shypie_privacy/local-extract |
Local-only PDF / Office / scan → text CLI with fail-closed blocking |
Three ShyPie packages are published on npm at 0.3.0 (pii-core, local-extract, the DSH bundle);
the legacy Magpie package is published at 0.4.0 with per-agent controls. The DSH bundle includes filter mode, image/PDF extraction and
the composer switch. The Magpie middleware is in-tree at
magpie-community/plugins
as @magpie-community/middleware-privacy-gate; 0.3.0 and 0.3.1 delivered the branded docs and the
coarse guide media class, and 0.4.0 is in review in
PR #1111 with per-agent controls and the
page/panel/action UI. The community npm package is still not published. The DSH catalog entry
PR #12308 is merged. This
repository mirrors the 0.4.0 middleware source under plugins/magpie-privacy-gate; the
@shypie_privacy/magpie-privacy-gate@0.4.0 npm package is published. docs/publish.md has the exact state.
It is a privacy-first workflow, not a guarantee: what it protects, and what it cannot, is documented precisely in docs/design.md and summarised below.
dsh-agent-loop, markAgentLoopRequest), so a plugin cannot rewrite it on the way out. ShyPie
Filter therefore does the local part it can do — extract attachments, block bytes it cannot mask,
and enforce the provider allowlist — while Magpie masks text at the gateway.binaryPolicy: guide, it replaces the bytes with metadata and a local-tool prompt; with the
default fail, it returns 403.ShyPie Filter covers what enters the DSH session log; Magpie covers text masking and every other agent
behind the gateway (Cursor, Copilot, Claude Code, scripts). The default textPolicy: filter keeps
raw local text; textPolicy: mask restores local placeholder masking.
flowchart TB
subgraph DSH[DeepSeek Harness]
direction TB
U["user text / attachments"] --> G3["Gate 3<br/>user ingress filter"]
T["tool call<br/>read / pwsh / MCP"] --> TOOL["tool execution"]
TOOL --> G1["Gate 1<br/>tool-result filter"]
PDF["PDF / image attachment"] --> EXT["local extraction / OCR<br/>pdftotext / Windows OCR"]
EXT --> RED["local text (raw by default)"]
RED --> PH["text"]
EXT -.->|blocked| ERR["tool error<br/>no data"]
G3 --> LOG["session log<br/>raw local text by default"]
G1 --> LOG
PH --> LOG
LOG --> REQ["LLM request<br/>text to mask at gateway"]
REQ --> EG{"DSH llm/stream<br/>egress guard"}
EG -->|reject| BLOCK["turn fails<br/>PRIVACY_EGRESS_BLOCKED"]
end
subgraph MAGPIE[Magpie gateway controls]
direction TB
MW["privacy-gate middleware<br/>fail: reject image/file/audio;<br/>guide: withhold bytes + prompt"]
MASK["built-in Privacy text masking<br/>raw PII is masked here"]
MW --> MASK
end
EG -->|pass| GW["Magpie gateway"]
GW --> MW
MASK --> LLM["LLM provider"]
OTHER["other agents<br/>Cursor / Copilot / Claude Code / scripts"] -.-> GW
LLM --> OUT["model output"]
OUT -.-> RH["privacy_rehydrate (optional)"]
RH --> ART["local artifact"]
classDef gate fill:#fff3cd,stroke:#b8860b,color:#000
classDef reject fill:#f8d7da,stroke:#b02a37,color:#000
class EG gate
class BLOCK reject
meta is not rewritten and
remains a documented local residual.pdftotext; scans use pdftoppm plus a local OCR
adapter (on Windows, the built-in Windows.Media.Ocr engine — no install, no network). If no
local engine exists the call is blocked (NO_LOCAL_OCR), never sent to a cloud converter.imageParts: 'block' or fileParts: 'block').data:-encoded documents
(contiguous, line-wrapped or dump-formatted), image/file/audio parts to non-local providers,
unknown binaries, encrypted PDFs. In textPolicy: filter the DSH egress guard allows plaintext
PII only through the default magpie* provider; Magpie must have Privacy masking enabled. For
other agents, binaryPolicy: guide replaces the binary part with type/size metadata and a prompt
to use a local extraction tool, without forwarding the bytes.privacy_rehydrate resolves placeholders inside the tool
and returns only {path, replaced, kinds}; the model can fill a form without seeing the value.pdftotext / pdftoppm / pdfinfo on PATH for PDF text and scan rendering (poppler).tesseract (an adapter exists but is untested here).The DSH bundle is on npm at 0.3.0 and contains the filter mode, image/PDF attachment extraction,
and the composer switch. The Magpie middleware is in-tree at magpie-community/plugins but is not on
npm yet; install it from a checkout (or the 0.4.0 branch in PR #1111) until the community publishes
it. This repository also mirrors the 0.4.0 source at plugins/magpie-privacy-gate; the
@shypie_privacy/magpie-privacy-gate@0.4.0 npm package is published.
git clone https://github.com/magpie-community/plugins, then
magpie plugin add <clone>/packages/privacy-gate (replace <clone> with the clone path), or add
plugins/magpie-privacy-gate from this repository to review the in-tree mirror. After the
community npm publish: magpie plugin add @magpie-community/middleware-privacy-gate.
The ShyPie-scoped published package is magpie plugin add @shypie_privacy/magpie-privacy-gate.dsh plugin --profile <name> add @shypie_privacy/dsh-privacy-gate
installs 0.3.0, including filter mode and PDF attachment extraction. Use the checkout
(dsh plugin --profile <name> add "$repo/plugins/dsh-privacy-gate") for an unreleased local build.Both plugins are reversible; no profile file is edited by hand. The install names are
@magpie-community/middleware-privacy-gate and @shypie_privacy/dsh-privacy-gate;
docs/publish.md covers the release state and the two marketplace listings.
node tests/run-all.mjs
Measured on the reference machine (Windows 11, Node 24, no network):
| Suite | Result |
|---|---|
pii-core |
61 tests, 60 pass (1 platform skip); 50,125-char doc with 2,133 hits redacts in 11.5 ms; 300k-digit run 40 ms |
local-extract |
49/49; text PDF, Office, local OCR, and all documented block reasons |
dsh-privacy-gate |
153/153; activation check registers 3 listeners, 1 guard, 5 tools; attached-image OCR and PDF/file extraction are covered; end-to-end image OCR against real winrt-ocr takes about 2.5 s |
plugins/magpie-privacy-gate (mirror) |
72/72 canonical middleware cases with npm test; the canonical in-tree 0.4.0 branch adds 4 page/policy checks (76 total) and bun scripts/check.mjs validates the registry. The canonical package lives in magpie-community/plugins and is not run by tests/run-all.mjs |
e2e |
11/11 — synthetic invoice → local text → placeholders → gateway → mock vendor, with zero plaintext on the wire |
The end-to-end suite uses only synthetic fixtures generated at test time. No real document, invoice, identity paper or personal record is present in this repository.
docs/
design.md design, threat model, gates, fail-closed matrix, limitations
install.md installation and verification guide
interface-contract.md frozen API / CLI / tool interfaces
publish.md npm publish order + Magpie and DSH marketplace listings
research/ evidence: DSH seams (path:line), Magpie hook docs (URL + quote),
detector catalogue, measured engine matrix, background, security review
packages/
pii-core/ detectors, keyed placeholders, encrypted vault
local-extract/ local-only PDF / Office / OCR to text
plugins/
dsh-privacy-gate/ DeepSeek Harness bundle
magpie-privacy-gate/ Magpie middleware mirror at 0.4.0 (canonical: magpie-community/plugins/packages/privacy-gate)
marketplace/ submission files; Magpie PR #685 merged, DSH catalog PR #12308 merged
assets/brand/shypie/ selected icon package (SVG, PNG, favicon, platform exports)
config/ example Magpie middleware options
tests/ end-to-end tests and the one-command runner
LICENSE MIT
Reference implementation, tested on one Windows machine. Published: all four @shypie_privacy
packages at 0.3.0 — pii-core, local-extract, dsh-privacy-gate, legacy magpie-privacy-gate.
The Magpie middleware upstream is in-tree at 0.4.0 in review
(PR #1111): per-agent controls, a page, an
Agents-page panel and an agent-row action. This repository mirrors that source at
plugins/magpie-privacy-gate@0.4.0; the ShyPie-scoped npm package is published at 0.4.0, while the
community npm package is not published yet, so install the canonical package from a checkout. The DSH catalog
PR #12308 is merged, and the
Magpie registry entry is merged. The legacy @shypie_privacy/magpie-privacy-gate npm package is
now 0.4.0 and remains a mirror of the canonical package; older 0.3.0 is still not deprecated. The guide-MIME issue
(#795) is closed, fixed by 0.3.1.
Tag v0.3.0 is pushed; the GitHub release can be created from it. The live wiring was exercised manually on
2026-11-03: DSH 0.2.1-rc.5 headless with the bundle installed from npm, two-turn DeepSeek and
Copilot gpt-6.1-sol sessions through a live Magpie gateway, and a temporary model-allowlist
block that the gate rejected. The llm/stream guard and its stable PRIVACY_EGRESS_BLOCKED code
were re-verified on 2026-11-05. On 2026-11-06 the merged guide mode was live-tested: an image was
withheld, the model was asked to process it locally, and no image bytes reached the provider.
OpenAI Responses encrypted_content and Anthropic thinking signature were replayed through
Copilot-routed models and accepted (HTTP 200). It is not part of the automated suite; remaining
verification limits are listed in docs/design.md §11.
Security issues: see SECURITY.md.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: privacy。