@kangyishuai/dsh-casefile 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DISCLAIMER.md +42 -2
- package/README.md +6 -0
- package/README.zh-CN.md +6 -0
- package/lib/core/brief.js +1 -0
- package/lib/core/manifest.js +1 -1
- package/lib/core/model.js +40 -0
- package/lib/core/report.js +44 -0
- package/lib/tools.js +53 -10
- package/package.json +1 -1
package/DISCLAIMER.md
CHANGED
|
@@ -10,9 +10,49 @@ This plugin is an **adapter** for [DeepSeek Harness](https://github.com/deepseek
|
|
|
10
10
|
- You are responsible for having the right to analyze the target, and for complying with the licenses, terms of service, and laws that apply to it. 你有责任确认自己有权分析目标,并遵守适用的许可、服务条款与法律。
|
|
11
11
|
- The plugin records an authorization tier (`owned` / `authorized` / `research`) with each project. That label records **your** attestation; it is not a legal determination and does not grant any right. 插件让每个项目记录授权档;该字段记录的是**你的**声明,不构成法律判断,也不授予任何权利。
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Acquisition boundary: three tiers / 采集边界:三段式
|
|
14
|
+
|
|
15
|
+
casefile does not acquire content. It ingests what an operator-supplied tool produced, records the
|
|
16
|
+
producer's identity and access mode, and verifies claims against checks. The three tiers below describe
|
|
17
|
+
what this plugin supports, what requires your explicit confirmation, and what it will not provide.
|
|
18
|
+
|
|
19
|
+
casefile 本身**不采集**内容:它摄入操作者所选工具产出的东西,记录生产者身份与获取方式,再用检查去验收结论。下面三段分别说明:支持什么、什么需要你明示确认、以及不提供什么。
|
|
20
|
+
|
|
21
|
+
### Tier 1 — supported as-is / 直接支持
|
|
22
|
+
|
|
23
|
+
- **Human-equivalent access** through a real browser: headful Chromium, your own normal profile, normal
|
|
24
|
+
user agent, ordinary pacing, single-page navigation. 以**人类等价**方式访问:有头浏览器、你自己的普通
|
|
25
|
+
profile、正常 UA、正常节奏、单页浏览。
|
|
26
|
+
- **Official APIs, public archives, and cached copies** (e.g. `web.archive.org`). 官方 API、公开归档与缓存副本。
|
|
27
|
+
- **Ingesting artifacts produced by other tools**, with provenance recorded (see `producer`). 摄入其他工具
|
|
28
|
+
产出的产物,并记录 `producer`(工具、版本、获取方式、产物类型)。
|
|
29
|
+
|
|
30
|
+
### Tier 2 — requires your explicit confirmation / 需你明示确认
|
|
31
|
+
|
|
32
|
+
- Reusing **your own** authenticated session or cookies in a tool you run yourself. 在你自行运行的工具里复用
|
|
33
|
+
**你自己的**登录态或 cookie。
|
|
34
|
+
- Any access mode you describe as `stealth` in the producer record. 你在 `producer.mode` 里标为 `stealth` 的获取方式。
|
|
35
|
+
|
|
36
|
+
Tier 2 is recorded, not endorsed: the evidence carries `accessConfirmedByUser` plus your note, and every
|
|
37
|
+
report renders the producer table with a statement that the operator chose and executed the acquisition.
|
|
38
|
+
Tier 2 只做**记录**,不做**背书**:证据会带上 `accessConfirmedByUser` 与你填的说明,报告会渲染生产者表,
|
|
39
|
+
并声明采集方式由操作者选择与执行、责任归操作者。
|
|
40
|
+
|
|
41
|
+
### Tier 3 — not provided, at all / 完全不提供
|
|
42
|
+
|
|
43
|
+
- CAPTCHA solving or human-click-farm integration. 验证码识别/打码平台接入。
|
|
44
|
+
- TLS/HTTP2 fingerprint impersonation, or forged challenge tokens. TLS/HTTP2 指纹伪造、伪造挑战 token。
|
|
45
|
+
- Proxy pools or IP rotation to evade blocks. 代理池/轮换 IP 规避封禁。
|
|
46
|
+
- High-rate bulk scraping. 高频批量抓取。
|
|
47
|
+
|
|
48
|
+
This plugin contains no code for Tier 3, and will not gain any: casefile is an evidence and acceptance
|
|
49
|
+
layer, not a circumvention toolkit. If your work needs Tier 3, that belongs in a dedicated scraping tool
|
|
50
|
+
outside this plugin, and its legality is your determination — moving the technique to another tool does
|
|
51
|
+
not make it permissible. 本插件不含 Tier 3 的任何代码,也不会加入:casefile 是证据与验收层,不是规避工具
|
|
52
|
+
箱。若你的工作需要 Tier 3,那属于插件之外的专门采集工具,合法性由你判断——把手段挪到别的工具里,性质不变。
|
|
53
|
+
|
|
54
|
+
## What this plugin deliberately does not contain / 刻意不包含
|
|
14
55
|
|
|
15
|
-
- **No circumvention.** It provides no way to bypass DRM, license checks, anti-debugging, integrity checks, or authentication. It observes and records; it does not defeat protections. **不提供绕过** DRM、许可校验、反调试、完整性校验或认证的能力:它只观察与记录,不破解保护。
|
|
16
56
|
- **No asset reuse.** It ships no third-party assets (logos, fonts, media, binaries) and offers no mechanism to reuse them. 不捆绑、也不提供复用第三方资产(logo、字体、素材、二进制)的机制。
|
|
17
57
|
- **No third-party engines.** It bundles no commercial reverse-engineering engines (IDA Pro, Hopper, JEB, …). If you use them, you must hold a valid license yourself. 不捆绑商业逆向引擎;若你使用它们,请自行持有有效授权。
|
|
18
58
|
- **No target disclosure.** The repository and its examples contain no record of any specific third-party target. 仓库与示例中不包含任何具体第三方目标的信息。
|
package/README.md
CHANGED
|
@@ -89,6 +89,12 @@ A project carries `authTier`: `owned`, `authorized`, or `research`. Starting a *
|
|
|
89
89
|
|
|
90
90
|
`case_project report` writes `reports/<timestamp>/report.md` + `report.json`: coverage (global and per feature), obligation table, check table with implementation digests, unknowns, loop state, and a declaration that `unknown` never means pass.
|
|
91
91
|
|
|
92
|
+
## Acquisition: ingest, don't acquire
|
|
93
|
+
|
|
94
|
+
casefile never fetches content itself. Evidence carries a **`producer`** record — tool, version, access mode (`headful` / `headless` / `api` / `archive` / `manual` / `stealth` / `unknown`), output kind, and whether you explicitly confirmed the access method. Reports render a producer table plus one statement: the operator chose and executed the acquisition.
|
|
95
|
+
|
|
96
|
+
That is what lets you feed it anything: REA's captures, a HAR from your proxy, an HTML snapshot from Scrapling, or a screenshot you took by hand. Tier 1 (human-equivalent browsing, official APIs, public archives) is supported as-is; Tier 2 (your own session, or a mode you label `stealth`) is recorded but not endorsed; Tier 3 (CAPTCHA solving, fingerprint forgery, proxy rotation, bulk high-rate scraping) is not provided and will not be — see [DISCLAIMER.md](DISCLAIMER.md#acquisition-boundary-three-tiers--采集边界三段式).
|
|
97
|
+
|
|
92
98
|
## Clean-room attestation
|
|
93
99
|
|
|
94
100
|
Every builder session writes an **attestation** (`attestations.jsonl`): the prompt digest, the spec digest, how many claims/evidence items were fed, the auth tier and any research override, and whether the "do not read the original target" clause was actually in the prompt. The report renders it as a `## 净室 attestation` section.
|
package/README.zh-CN.md
CHANGED
|
@@ -89,6 +89,12 @@ dsh plugin --profile desktop add /tmp/kangyishuai-dsh-casefile-*.tgz
|
|
|
89
89
|
|
|
90
90
|
`case_project report` 写出 `reports/<时间戳>/report.md` + `report.json`:全局覆盖率、**按功能覆盖率**、义务表、带实现 digest 的检查表、未知项、循环状态,以及「`unknown` 不等于通过」的声明。
|
|
91
91
|
|
|
92
|
+
## 采集:只摄入,不采集
|
|
93
|
+
|
|
94
|
+
casefile 自己不去抓任何内容。每条证据带一份 **`producer`** 记录——工具、版本、获取方式(`headful` / `headless` / `api` / `archive` / `manual` / `stealth` / `unknown`)、产物类型,以及你是否**明示确认**过这种获取方式。报告会渲染一张生产者表,外加一句声明:采集方式由操作者选择与执行。
|
|
95
|
+
|
|
96
|
+
这就是它能吃下任何东西的原因:REA 的采集、你自己代理录的 HAR、Scrapling 抓的 HTML 快照,或者你手动截的图。Tier 1(人类等价浏览、官方 API、公开归档)直接支持;Tier 2(你自己的会话,或你标为 `stealth` 的方式)只记录不背书;Tier 3(打码、指纹伪造、代理轮换、高频批量抓取)不提供、也不会加——见 [DISCLAIMER.md](DISCLAIMER.md#acquisition-boundary-three-tiers--采集边界三段式)。
|
|
97
|
+
|
|
92
98
|
## 净室 attestation
|
|
93
99
|
|
|
94
100
|
每次 builder 会话都会写一条 **attestation**(`attestations.jsonl`):prompt 摘要、规格包摘要、投喂了多少条结论/证据、授权档与是否 research 覆盖,以及「不要读取原始目标」这条指令**是否真的**在 prompt 里。报告里渲染成 `## 净室 attestation` 小节。
|
package/lib/core/brief.js
CHANGED
package/lib/core/manifest.js
CHANGED
package/lib/core/model.js
CHANGED
|
@@ -219,6 +219,45 @@ export function normalizeProjectInput(input) {
|
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
+
/**
|
|
223
|
+
* 规范化一条证据(只投影 REA 的结论)。
|
|
224
|
+
* @param {Record<string, any>} input
|
|
225
|
+
* @returns {Record<string, any>}
|
|
226
|
+
*/
|
|
227
|
+
/**
|
|
228
|
+
* 外部生产者(谁采的、用什么方式采的、用户是否明示确认过)。
|
|
229
|
+
* casefile 自己不采集:它只记录产出者,责任与合法性归操作者。
|
|
230
|
+
* @param {any} raw
|
|
231
|
+
* @returns {Record<string, any> | null}
|
|
232
|
+
*/
|
|
233
|
+
export function normalizeProducer(raw) {
|
|
234
|
+
if (raw == null) return null;
|
|
235
|
+
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
236
|
+
throw new CasefileInputError("invalid-input", "producer 必须是对象");
|
|
237
|
+
}
|
|
238
|
+
/** @type {Record<string, any>} */
|
|
239
|
+
const producer = {};
|
|
240
|
+
if (raw.tool != null) producer.tool = text(raw.tool, "producer.tool", { max: 200 });
|
|
241
|
+
if (raw.version != null) producer.version = text(raw.version, "producer.version", { max: 64 });
|
|
242
|
+
if (raw.mode != null) {
|
|
243
|
+
producer.mode = oneOf(
|
|
244
|
+
raw.mode,
|
|
245
|
+
["headful", "headless", "api", "archive", "manual", "stealth", "unknown"],
|
|
246
|
+
"producer.mode",
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
if (raw.outputKind != null)
|
|
250
|
+
producer.outputKind = text(raw.outputKind, "producer.outputKind", { max: 64 });
|
|
251
|
+
if (raw.accessConfirmedByUser === true) {
|
|
252
|
+
producer.accessConfirmedByUser = true;
|
|
253
|
+
producer.confirmationNote =
|
|
254
|
+
raw.confirmationNote == null
|
|
255
|
+
? null
|
|
256
|
+
: text(raw.confirmationNote, "producer.confirmationNote", { max: 1000 });
|
|
257
|
+
}
|
|
258
|
+
return Object.keys(producer).length === 0 ? null : producer;
|
|
259
|
+
}
|
|
260
|
+
|
|
222
261
|
/**
|
|
223
262
|
* 规范化一条证据(只投影 REA 的结论)。
|
|
224
263
|
* @param {Record<string, any>} input
|
|
@@ -238,6 +277,7 @@ export function normalizeEvidence(input) {
|
|
|
238
277
|
integrity: input?.integrity == null ? null : text(input.integrity, "integrity", { max: 256 }),
|
|
239
278
|
summary: text(input?.summary, "summary", { max: 4000 }),
|
|
240
279
|
refs: textList(input?.refs, "refs"),
|
|
280
|
+
producer: normalizeProducer(input?.producer),
|
|
241
281
|
claimIds: idList(input?.claimIds, "claimIds"),
|
|
242
282
|
};
|
|
243
283
|
}
|
package/lib/core/report.js
CHANGED
|
@@ -115,6 +115,35 @@ export function evaluateClose(input) {
|
|
|
115
115
|
return { ok: blockers.length === 0, blockers, coverage };
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
/**
|
|
119
|
+
* 汇总证据的生产者(去重,按工具+模式)。
|
|
120
|
+
* @param {Array<Record<string, any>>} evidence
|
|
121
|
+
* @returns {Array<Record<string, any>>}
|
|
122
|
+
*/
|
|
123
|
+
export function summarizeProducers(evidence) {
|
|
124
|
+
/** @type {Map<string, Record<string, any>>} */
|
|
125
|
+
const seen = new Map();
|
|
126
|
+
for (const item of evidence) {
|
|
127
|
+
const producer = item.producer;
|
|
128
|
+
if (!producer || typeof producer !== "object") continue;
|
|
129
|
+
const key = [producer.tool ?? "?", producer.mode ?? "?", producer.outputKind ?? "?"].join("|");
|
|
130
|
+
if (seen.has(key)) {
|
|
131
|
+
const existing = seen.get(key);
|
|
132
|
+
if (existing) existing.count += 1;
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
seen.set(key, {
|
|
136
|
+
tool: producer.tool ?? "?",
|
|
137
|
+
version: producer.version ?? null,
|
|
138
|
+
mode: producer.mode ?? null,
|
|
139
|
+
outputKind: producer.outputKind ?? null,
|
|
140
|
+
accessConfirmedByUser: producer.accessConfirmedByUser === true,
|
|
141
|
+
count: 1,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return [...seen.values()];
|
|
145
|
+
}
|
|
146
|
+
|
|
118
147
|
/**
|
|
119
148
|
* 组装报告对象。
|
|
120
149
|
* @param {{
|
|
@@ -150,6 +179,7 @@ export function buildReport(input) {
|
|
|
150
179
|
coverage,
|
|
151
180
|
coverageByFeature: computeCoverageByFeature(obligations, data.features ?? []),
|
|
152
181
|
cleanRoom: attestationSummary(data.attestations ?? []),
|
|
182
|
+
producers: summarizeProducers(data.evidence ?? []),
|
|
153
183
|
counts: {
|
|
154
184
|
evidence: (data.evidence ?? []).length,
|
|
155
185
|
claims: (data.claims ?? []).length,
|
|
@@ -287,6 +317,20 @@ export function renderReportMarkdown(report) {
|
|
|
287
317
|
const detail = report.stop.detail ?? {};
|
|
288
318
|
lines.push(`- 轮次:${detail.rounds ?? "—"} / 失败:${detail.failures ?? "—"}`);
|
|
289
319
|
}
|
|
320
|
+
if ((report.producers ?? []).length > 0) {
|
|
321
|
+
lines.push("");
|
|
322
|
+
lines.push("## 证据生产者");
|
|
323
|
+
lines.push("");
|
|
324
|
+
lines.push("| 工具 | 版本 | 获取方式 | 产物 | 用户已确认 |");
|
|
325
|
+
lines.push("| --- | --- | --- | --- | --- |");
|
|
326
|
+
for (const item of report.producers) {
|
|
327
|
+
lines.push(
|
|
328
|
+
`| ${item.tool} | ${item.version ?? "—"} | ${item.mode ?? "—"} | ${item.outputKind ?? "—"} | ${item.accessConfirmedByUser ? "是" : "否"} |`,
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
lines.push("");
|
|
332
|
+
lines.push("> casefile 不采集、不规避访问控制:以上生产者由操作者选择并执行,责任归操作者。");
|
|
333
|
+
}
|
|
290
334
|
if (report.cleanRoom) {
|
|
291
335
|
lines.push("");
|
|
292
336
|
lines.push("## 净室 attestation");
|
package/lib/tools.js
CHANGED
|
@@ -171,6 +171,26 @@ export function buildToolDefinitions(handlers, projectOf) {
|
|
|
171
171
|
const project = await handlers.updateProject(projectId(args, exec), args.patch ?? {});
|
|
172
172
|
return { project, summary: `已更新项目 ${project.id}` };
|
|
173
173
|
}
|
|
174
|
+
case "close": {
|
|
175
|
+
const id = projectId(args, exec);
|
|
176
|
+
// 先给只读预览再关:被闸门拒绝时把卡点原样带回去,别只说"失败"
|
|
177
|
+
const preview = await handlers.closePreview(id, { minCoverage: args.minCoverage });
|
|
178
|
+
if (preview.ok !== true) {
|
|
179
|
+
throw Object.assign(new Error(`项目还不能关闭:${preview.blockers.join("、")}`), {
|
|
180
|
+
code: "coverage-not-met",
|
|
181
|
+
blockers: preview.blockers,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const closed = await handlers.closeProject(id, { minCoverage: args.minCoverage });
|
|
185
|
+
return {
|
|
186
|
+
closed: closed.project,
|
|
187
|
+
coverage: preview.coverage,
|
|
188
|
+
summary: `项目已关闭(覆盖率 ${(preview.coverage.ratio * 100).toFixed(0)}%)`,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
case "report": {
|
|
192
|
+
return handlers.exportReport(projectId(args, exec));
|
|
193
|
+
}
|
|
174
194
|
default:
|
|
175
195
|
throw Object.assign(new Error(`未知 action:${String(args.action)}`), {
|
|
176
196
|
code: "invalid-input",
|
|
@@ -196,7 +216,28 @@ export function buildToolDefinitions(handlers, projectOf) {
|
|
|
196
216
|
additionalProperties: false,
|
|
197
217
|
properties: {
|
|
198
218
|
kind: { type: "string" },
|
|
199
|
-
sourceTool: {
|
|
219
|
+
sourceTool: {
|
|
220
|
+
type: "string",
|
|
221
|
+
description:
|
|
222
|
+
"产出该证据的工具标识(REA 工具名,或外部工具如 scrapling/StealthyFetcher)",
|
|
223
|
+
},
|
|
224
|
+
producer: {
|
|
225
|
+
type: "object",
|
|
226
|
+
additionalProperties: false,
|
|
227
|
+
description:
|
|
228
|
+
"外部证据的生产者:谁采的、什么方式采的。casefile 不采集也不规避访问控制,责任归操作者。",
|
|
229
|
+
properties: {
|
|
230
|
+
tool: { type: "string" },
|
|
231
|
+
version: { type: "string" },
|
|
232
|
+
mode: {
|
|
233
|
+
type: "string",
|
|
234
|
+
enum: ["headful", "headless", "api", "archive", "manual", "stealth", "unknown"],
|
|
235
|
+
},
|
|
236
|
+
outputKind: { type: "string" },
|
|
237
|
+
accessConfirmedByUser: { type: "boolean" },
|
|
238
|
+
confirmationNote: { type: "string" },
|
|
239
|
+
},
|
|
240
|
+
},
|
|
200
241
|
summary: { type: "string", description: "一句话结论" },
|
|
201
242
|
confidence: { type: "string", enum: ["observed", "derived", "inferred"] },
|
|
202
243
|
authority: {
|
|
@@ -494,16 +535,18 @@ export function buildToolDefinitions(handlers, projectOf) {
|
|
|
494
535
|
const action = assertAction(args.action, ["start", "status", "agent", "loop", "cycle"]);
|
|
495
536
|
const id = projectId(args, exec);
|
|
496
537
|
if (action === "cycle") {
|
|
538
|
+
// 只有显式要求 builder(prompt 或 featureIds)才起会话;
|
|
539
|
+
// cwd 是构建目录,单独给 cwd 不应该顺手启动一个 builder 子会话。
|
|
540
|
+
const wantsBuilder = args.prompt !== undefined || args.featureIds !== undefined;
|
|
497
541
|
const result = await handlers.runCycle(id, {
|
|
498
|
-
builder:
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
},
|
|
542
|
+
builder: wantsBuilder
|
|
543
|
+
? {
|
|
544
|
+
cwd: args.cwd,
|
|
545
|
+
prompt: args.prompt,
|
|
546
|
+
featureIds: args.featureIds,
|
|
547
|
+
timeoutMs: args.timeoutMs,
|
|
548
|
+
}
|
|
549
|
+
: undefined,
|
|
507
550
|
command: args.command,
|
|
508
551
|
cwd: args.cwd,
|
|
509
552
|
maxRounds: args.maxRounds,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kangyishuai/dsh-casefile",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Evidence-first reverse-engineering workbench on top of REA: observations become citable evidence, a handoff spec pack, and recomputable acceptance checks. No bridge, no engine.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|