@dommaker/harness 1.12.0 → 1.14.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.
Files changed (168) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cli/commands/check.js +3 -3
  3. package/dist/cli/commands/check.js.map +1 -1
  4. package/dist/cli/commands/security.d.ts +19 -0
  5. package/dist/cli/commands/security.d.ts.map +1 -1
  6. package/dist/cli/commands/security.js +105 -0
  7. package/dist/cli/commands/security.js.map +1 -1
  8. package/dist/core/app-constraints-loader.d.ts +5 -3
  9. package/dist/core/app-constraints-loader.d.ts.map +1 -1
  10. package/dist/core/app-constraints-loader.js +20 -7
  11. package/dist/core/app-constraints-loader.js.map +1 -1
  12. package/dist/core/constraints/checker.d.ts +5 -3
  13. package/dist/core/constraints/checker.d.ts.map +1 -1
  14. package/dist/core/constraints/checker.js +31 -10
  15. package/dist/core/constraints/checker.js.map +1 -1
  16. package/dist/core/constraints/checkers/capability-sync.d.ts.map +1 -1
  17. package/dist/core/constraints/checkers/capability-sync.js +21 -8
  18. package/dist/core/constraints/checkers/capability-sync.js.map +1 -1
  19. package/dist/core/constraints/checkers/context-doc-sync.d.ts.map +1 -1
  20. package/dist/core/constraints/checkers/context-doc-sync.js +7 -1
  21. package/dist/core/constraints/checkers/context-doc-sync.js.map +1 -1
  22. package/dist/core/constraints/checkers/docs-freshness.d.ts.map +1 -1
  23. package/dist/core/constraints/checkers/docs-freshness.js +41 -26
  24. package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
  25. package/dist/core/constraints/checkers/governance-presence.d.ts +3 -0
  26. package/dist/core/constraints/checkers/governance-presence.d.ts.map +1 -1
  27. package/dist/core/constraints/checkers/governance-presence.js +7 -10
  28. package/dist/core/constraints/checkers/governance-presence.js.map +1 -1
  29. package/dist/core/constraints/checkers/index.d.ts +6 -6
  30. package/dist/core/constraints/checkers/index.d.ts.map +1 -1
  31. package/dist/core/constraints/checkers/index.js +14 -9
  32. package/dist/core/constraints/checkers/index.js.map +1 -1
  33. package/dist/core/constraints/checkers/iron-flags.js +1 -1
  34. package/dist/core/constraints/checkers/iron-flags.js.map +1 -1
  35. package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts +11 -4
  36. package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts.map +1 -1
  37. package/dist/core/constraints/checkers/no-hardcoded-credentials.js +117 -30
  38. package/dist/core/constraints/checkers/no-hardcoded-credentials.js.map +1 -1
  39. package/dist/core/constraints/checkers/no-test-simplification.d.ts +16 -2
  40. package/dist/core/constraints/checkers/no-test-simplification.d.ts.map +1 -1
  41. package/dist/core/constraints/checkers/no-test-simplification.js +115 -15
  42. package/dist/core/constraints/checkers/no-test-simplification.js.map +1 -1
  43. package/dist/core/constraints/checkers/templated/exec.d.ts +19 -0
  44. package/dist/core/constraints/checkers/templated/exec.d.ts.map +1 -0
  45. package/dist/core/constraints/checkers/templated/exec.js +124 -0
  46. package/dist/core/constraints/checkers/templated/exec.js.map +1 -0
  47. package/dist/core/constraints/checkers/templated/index.d.ts +1 -0
  48. package/dist/core/constraints/checkers/templated/index.d.ts.map +1 -1
  49. package/dist/core/constraints/checkers/templated/index.js +3 -1
  50. package/dist/core/constraints/checkers/templated/index.js.map +1 -1
  51. package/dist/core/constraints/checkers/templates-registry.d.ts +2 -1
  52. package/dist/core/constraints/checkers/templates-registry.d.ts.map +1 -1
  53. package/dist/core/constraints/checkers/templates-registry.js +3 -1
  54. package/dist/core/constraints/checkers/templates-registry.js.map +1 -1
  55. package/dist/core/constraints/checkers/types.d.ts +67 -6
  56. package/dist/core/constraints/checkers/types.d.ts.map +1 -1
  57. package/dist/core/constraints/checkers/types.js +51 -6
  58. package/dist/core/constraints/checkers/types.js.map +1 -1
  59. package/dist/core/constraints/definitions/guidelines.d.ts +1 -0
  60. package/dist/core/constraints/definitions/guidelines.d.ts.map +1 -1
  61. package/dist/core/constraints/definitions/guidelines.js +4 -0
  62. package/dist/core/constraints/definitions/guidelines.js.map +1 -1
  63. package/dist/core/constraints/definitions/iron-laws.d.ts +1 -0
  64. package/dist/core/constraints/definitions/iron-laws.d.ts.map +1 -1
  65. package/dist/core/constraints/definitions/iron-laws.js +6 -1
  66. package/dist/core/constraints/definitions/iron-laws.js.map +1 -1
  67. package/dist/core/constraints/definitions.d.ts +7 -0
  68. package/dist/core/constraints/definitions.d.ts.map +1 -1
  69. package/dist/core/constraints/definitions.js +10 -0
  70. package/dist/core/constraints/definitions.js.map +1 -1
  71. package/dist/core/constraints/git-evidence.d.ts +10 -0
  72. package/dist/core/constraints/git-evidence.d.ts.map +1 -1
  73. package/dist/core/constraints/git-evidence.js +2 -0
  74. package/dist/core/constraints/git-evidence.js.map +1 -1
  75. package/dist/core/constraints/index.d.ts +3 -1
  76. package/dist/core/constraints/index.d.ts.map +1 -1
  77. package/dist/core/constraints/index.js +8 -1
  78. package/dist/core/constraints/index.js.map +1 -1
  79. package/dist/core/index.d.ts +2 -2
  80. package/dist/core/index.d.ts.map +1 -1
  81. package/dist/core/index.js +6 -1
  82. package/dist/core/index.js.map +1 -1
  83. package/dist/gates/checker-gate.d.ts +5 -1
  84. package/dist/gates/checker-gate.d.ts.map +1 -1
  85. package/dist/gates/checker-gate.js +10 -3
  86. package/dist/gates/checker-gate.js.map +1 -1
  87. package/dist/gates/command.d.ts +5 -1
  88. package/dist/gates/command.d.ts.map +1 -1
  89. package/dist/gates/command.js +6 -2
  90. package/dist/gates/command.js.map +1 -1
  91. package/dist/gates/definitions.d.ts.map +1 -1
  92. package/dist/gates/definitions.js +6 -1
  93. package/dist/gates/definitions.js.map +1 -1
  94. package/dist/index.d.ts +3 -1
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +14 -3
  97. package/dist/index.js.map +1 -1
  98. package/dist/pretool-use-hook.d.ts +13 -4
  99. package/dist/pretool-use-hook.d.ts.map +1 -1
  100. package/dist/pretool-use-hook.js +89 -8
  101. package/dist/pretool-use-hook.js.map +1 -1
  102. package/dist/types/constraint.d.ts +32 -3
  103. package/dist/types/constraint.d.ts.map +1 -1
  104. package/dist/types/constraint.js +6 -1
  105. package/dist/types/constraint.js.map +1 -1
  106. package/dist/types/trace.d.ts +7 -0
  107. package/dist/types/trace.d.ts.map +1 -1
  108. package/package.json +1 -1
  109. package/src/CONTEXT.md +2 -2
  110. package/src/__tests__/app-constraints-loader.test.ts +86 -3
  111. package/src/__tests__/checker-extra.test.ts +80 -4
  112. package/src/__tests__/checker-primitives-sdk.test.ts +70 -0
  113. package/src/__tests__/exec-checker-full-chain.test.ts +118 -0
  114. package/src/__tests__/layering.test.ts +3 -1
  115. package/src/__tests__/pretool-use-hook.test.ts +211 -4
  116. package/src/__tests__/public-exports.test.ts +5 -0
  117. package/src/__tests__/public-type-surface.test.ts +22 -0
  118. package/src/__tests__/public-value-surface.test.ts +5 -0
  119. package/src/cli/commands/CONTEXT.md +1 -1
  120. package/src/cli/commands/__tests__/check-skip-output.test.ts +4 -4
  121. package/src/cli/commands/__tests__/check.test.ts +2 -0
  122. package/src/cli/commands/__tests__/security.test.ts +89 -1
  123. package/src/cli/commands/check.ts +3 -3
  124. package/src/cli/commands/security.ts +99 -0
  125. package/src/core/CONTEXT.md +6 -6
  126. package/src/core/app-constraints-loader.ts +23 -8
  127. package/src/core/constraints/__tests__/git-evidence.test.ts +20 -0
  128. package/src/core/constraints/__tests__/run-env.test.ts +2 -0
  129. package/src/core/constraints/checker.ts +35 -12
  130. package/src/core/constraints/checkers/__tests__/capability-sync.test.ts +21 -3
  131. package/src/core/constraints/checkers/__tests__/context-doc-sync.test.ts +20 -12
  132. package/src/core/constraints/checkers/__tests__/docs-freshness-degraded.test.ts +89 -0
  133. package/src/core/constraints/checkers/__tests__/docs-freshness.test.ts +4 -2
  134. package/src/core/constraints/checkers/__tests__/exec-checker.test.ts +99 -0
  135. package/src/core/constraints/checkers/__tests__/fixtures/public-repo-sanitization.mjs +40 -0
  136. package/src/core/constraints/checkers/__tests__/governance-presence.test.ts +23 -2
  137. package/src/core/constraints/checkers/__tests__/input-contract.test.ts +135 -0
  138. package/src/core/constraints/checkers/__tests__/iron-flags.test.ts +15 -2
  139. package/src/core/constraints/checkers/__tests__/no-hardcoded-credentials.test.ts +110 -5
  140. package/src/core/constraints/checkers/__tests__/no-test-simplification.test.ts +144 -21
  141. package/src/core/constraints/checkers/__tests__/three-state-consistency.test.ts +6 -2
  142. package/src/core/constraints/checkers/capability-sync.ts +24 -10
  143. package/src/core/constraints/checkers/context-doc-sync.ts +8 -1
  144. package/src/core/constraints/checkers/docs-freshness.ts +44 -26
  145. package/src/core/constraints/checkers/governance-presence.ts +7 -8
  146. package/src/core/constraints/checkers/index.ts +22 -10
  147. package/src/core/constraints/checkers/iron-flags.ts +1 -1
  148. package/src/core/constraints/checkers/no-hardcoded-credentials.ts +135 -29
  149. package/src/core/constraints/checkers/no-test-simplification.ts +128 -17
  150. package/src/core/constraints/checkers/templated/exec.ts +138 -0
  151. package/src/core/constraints/checkers/templated/index.ts +1 -0
  152. package/src/core/constraints/checkers/templates-registry.ts +4 -2
  153. package/src/core/constraints/checkers/types.ts +106 -9
  154. package/src/core/constraints/definitions/guidelines.ts +4 -0
  155. package/src/core/constraints/definitions/iron-laws.ts +6 -1
  156. package/src/core/constraints/definitions.ts +10 -0
  157. package/src/core/constraints/git-evidence.ts +13 -0
  158. package/src/core/constraints/index.ts +22 -0
  159. package/src/core/index.ts +16 -0
  160. package/src/gates/CONTEXT.md +3 -3
  161. package/src/gates/__tests__/checker-gate.test.ts +19 -2
  162. package/src/gates/checker-gate.ts +11 -4
  163. package/src/gates/command.ts +6 -2
  164. package/src/gates/definitions.ts +6 -1
  165. package/src/index.ts +26 -0
  166. package/src/pretool-use-hook.ts +104 -10
  167. package/src/types/constraint.ts +35 -3
  168. package/src/types/trace.ts +8 -0
@@ -3,10 +3,19 @@
3
3
  *
4
4
  * 验收口径:block/warn/audit 行为与 studio-agent 生成版脚本一致——
5
5
  * block 级 exit 2 阻断,warn/audit 放行,坏输入 fail-open。
6
+ *
7
+ * P1-7(ADR-0031,wayfinder 票08):命中留痕走 traces 通道——整个套件 chdir 到
8
+ * tmp 目录运行(TraceCollector 缺省按 cwd 解析 projectPath),断言 JSONL 行;
9
+ * 留痕失败不挡拦截主路径。
6
10
  */
7
11
 
12
+ import * as fs from 'fs';
13
+ import * as os from 'os';
14
+ import * as path from 'path';
8
15
  import { describe, it, expect, jest, beforeEach, afterEach } from '@jest/globals';
9
16
  import { decidePreToolUse, runPreToolUseHook, HOOK_MARKER } from '../pretool-use-hook';
17
+ import { CommandGate } from '../gates/command';
18
+ import { TraceCollector } from '../monitoring/traces';
10
19
 
11
20
  /** 构造 provider PreToolUse stdin JSON */
12
21
  function stdinOf(command: string): string {
@@ -14,6 +23,32 @@ function stdinOf(command: string): string {
14
23
  }
15
24
 
16
25
  describe('pretool-use-hook', () => {
26
+ const origCwd = process.cwd();
27
+ let workDir: string;
28
+
29
+ beforeEach(() => {
30
+ // 留痕落点 = <cwd>/.harness/logs/traces.log:chdir 到每轮唯一 tmp 目录,
31
+ // 不污染本仓真 traces.log(回收走 mkdtemp-cleanup 劫持)
32
+ workDir = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-pretool-'));
33
+ process.chdir(workDir);
34
+ });
35
+
36
+ afterEach(() => {
37
+ process.chdir(origCwd);
38
+ jest.restoreAllMocks();
39
+ });
40
+
41
+ /** 读本轮 tmp 目录下的 trace JSONL 行 */
42
+ function readTraces(): Array<Record<string, unknown>> {
43
+ const file = path.join(workDir, '.harness', 'logs', 'traces.log');
44
+ if (!fs.existsSync(file)) return [];
45
+ return fs
46
+ .readFileSync(file, 'utf-8')
47
+ .split('\n')
48
+ .filter(Boolean)
49
+ .map((line) => JSON.parse(line) as Record<string, unknown>);
50
+ }
51
+
17
52
  describe('decidePreToolUse', () => {
18
53
  it('block 级命令被拦截(rm -rf /)', () => {
19
54
  const r = decidePreToolUse(stdinOf('rm -rf /'));
@@ -48,6 +83,12 @@ describe('pretool-use-hook', () => {
48
83
  it('缺 tool_input 字段放行', () => {
49
84
  expect(decidePreToolUse(JSON.stringify({ tool_name: 'Bash' })).allowed).toBe(true);
50
85
  });
86
+
87
+ it('命中明细随判定带出(hits 含 rule id 与 level)', () => {
88
+ const r = decidePreToolUse(stdinOf('rm -rf /'));
89
+ expect(r.hits.map((h) => h.id)).toContain('rm-rf-root');
90
+ expect(r.hits.every((h) => h.level === 'block')).toBe(true);
91
+ });
51
92
  });
52
93
 
53
94
  describe('runPreToolUseHook', () => {
@@ -57,10 +98,6 @@ describe('pretool-use-hook', () => {
57
98
  errorSpy = jest.spyOn(console, 'error').mockImplementation(() => undefined);
58
99
  });
59
100
 
60
- afterEach(() => {
61
- errorSpy.mockRestore();
62
- });
63
-
64
101
  it('block 级返回 exit 2 并写 stderr(含 marker 与原命令)', () => {
65
102
  const code = runPreToolUseHook(stdinOf('rm -rf ~'));
66
103
  expect(code).toBe(2);
@@ -79,4 +116,174 @@ describe('pretool-use-hook', () => {
79
116
  expect(errorSpy).not.toHaveBeenCalled();
80
117
  });
81
118
  });
119
+
120
+ describe('命中留痕(P1-7:traces 通道,只记账不加拦截)', () => {
121
+ beforeEach(() => {
122
+ // 阻断时 stderr 是 provider 回填面,与本组断言无关,收下不打到测试输出
123
+ jest.spyOn(console, 'error').mockImplementation(() => undefined);
124
+ });
125
+
126
+ it('block 命中写一条 error/fail 汇总 trace(规则 id + 命令首 token 进 evidence,不记完整命令)', () => {
127
+ expect(runPreToolUseHook(stdinOf('rm -rf /'))).toBe(2);
128
+
129
+ const traces = readTraces();
130
+ expect(traces).toHaveLength(1);
131
+ expect(traces[0]).toMatchObject({
132
+ constraintId: 'command-gate',
133
+ severity: 'error',
134
+ result: 'fail',
135
+ operation: 'pretool-use-hook',
136
+ });
137
+ const evidence = traces[0].evidence as string[];
138
+ expect(evidence).toContain('rule:rm-rf-root');
139
+ expect(evidence).toContain('cmd:rm');
140
+ // 脱敏:完整命令文本(可能含敏感参数)不进 evidence
141
+ expect(evidence.join(' ')).not.toContain('rm -rf /');
142
+ });
143
+
144
+ it('warn 命中写 warning/pass trace,仍放行', () => {
145
+ expect(runPreToolUseHook(stdinOf('psql -c "DROP TABLE users"'))).toBe(0);
146
+
147
+ const traces = readTraces();
148
+ expect(traces).toHaveLength(1);
149
+ expect(traces[0]).toMatchObject({
150
+ constraintId: 'command-gate',
151
+ severity: 'warning',
152
+ result: 'pass',
153
+ operation: 'pretool-use-hook',
154
+ });
155
+ expect(traces[0].evidence).toContain('rule:drop-table');
156
+ });
157
+
158
+ it('audit 命中写 info/pass trace,仍放行', () => {
159
+ expect(runPreToolUseHook(stdinOf('cat .env'))).toBe(0);
160
+
161
+ const traces = readTraces();
162
+ expect(traces).toHaveLength(1);
163
+ expect(traces[0]).toMatchObject({
164
+ constraintId: 'command-gate',
165
+ severity: 'info',
166
+ result: 'pass',
167
+ operation: 'pretool-use-hook',
168
+ });
169
+ expect(traces[0].evidence).toContain('rule:read-env');
170
+ });
171
+
172
+ it('干净命令不写 trace', () => {
173
+ expect(runPreToolUseHook(stdinOf('git status'))).toBe(0);
174
+ expect(readTraces()).toHaveLength(0);
175
+ });
176
+
177
+ it('留痕失败不影响拦截主路径(fail-open:block 照拦、放行照放)', () => {
178
+ jest.spyOn(TraceCollector.prototype, 'record').mockImplementation(() => {
179
+ throw new Error('disk full');
180
+ });
181
+
182
+ expect(runPreToolUseHook(stdinOf('rm -rf /'))).toBe(2);
183
+ expect(runPreToolUseHook(stdinOf('killall node'))).toBe(0);
184
+ });
185
+ });
186
+
187
+ describe('非 Bash 工具事件(P1-5:只留痕不拦截,拦截归 codex 沙箱)', () => {
188
+ it('Edit 事件放行(exit 0)并写 tool-event trace(evidence 记工具名 + file_path,不记内容正文)', () => {
189
+ const stdin = JSON.stringify({
190
+ tool_name: 'Edit',
191
+ tool_input: { file_path: 'src/a.ts', old_string: 'SECRET=abc123', new_string: 'SECRET=def456' },
192
+ });
193
+ expect(runPreToolUseHook(stdin)).toBe(0);
194
+
195
+ const traces = readTraces();
196
+ expect(traces).toHaveLength(1);
197
+ expect(traces[0]).toMatchObject({
198
+ constraintId: 'tool-event:Edit',
199
+ severity: 'info',
200
+ result: 'pass',
201
+ operation: 'pretool-use-hook',
202
+ });
203
+ expect(traces[0].evidence).toEqual(['tool:Edit', 'path:src/a.ts']);
204
+ // 内容正文(可能含敏感值)不进 trace
205
+ expect(JSON.stringify(traces[0])).not.toContain('abc123');
206
+ });
207
+
208
+ it('Write 事件放行并留痕', () => {
209
+ const stdin = JSON.stringify({
210
+ tool_name: 'Write',
211
+ tool_input: { file_path: 'docs/note.md', content: 'body' },
212
+ });
213
+ expect(runPreToolUseHook(stdin)).toBe(0);
214
+
215
+ const traces = readTraces();
216
+ expect(traces).toHaveLength(1);
217
+ expect(traces[0].constraintId).toBe('tool-event:Write');
218
+ expect(traces[0].evidence).toEqual(['tool:Write', 'path:docs/note.md']);
219
+ });
220
+
221
+ it('apply_patch 事件(无 file_path)放行并留痕,evidence 只记工具名', () => {
222
+ const stdin = JSON.stringify({
223
+ tool_name: 'apply_patch',
224
+ tool_input: { patch: '*** Begin Patch' },
225
+ });
226
+ expect(runPreToolUseHook(stdin)).toBe(0);
227
+
228
+ const traces = readTraces();
229
+ expect(traces).toHaveLength(1);
230
+ expect(traces[0].constraintId).toBe('tool-event:apply_patch');
231
+ expect(traces[0].evidence).toEqual(['tool:apply_patch']);
232
+ });
233
+
234
+ it('MCP 工具事件放行并留痕', () => {
235
+ const stdin = JSON.stringify({
236
+ tool_name: 'mcp__local-rag__query_documents',
237
+ tool_input: { query: 'x' },
238
+ });
239
+ expect(runPreToolUseHook(stdin)).toBe(0);
240
+
241
+ const traces = readTraces();
242
+ expect(traces).toHaveLength(1);
243
+ expect(traces[0].constraintId).toBe('tool-event:mcp__local-rag__query_documents');
244
+ });
245
+
246
+ it('非 Bash 事件即使 tool_input 带危险 command 字段也不拦(判定面只认 Bash)', () => {
247
+ const stdin = JSON.stringify({
248
+ tool_name: 'Edit',
249
+ tool_input: { file_path: 'a.ts', command: 'rm -rf /' },
250
+ });
251
+ const r = decidePreToolUse(stdin);
252
+ expect(r.allowed).toBe(true);
253
+ expect(r.toolName).toBe('Edit');
254
+ expect(runPreToolUseHook(stdin)).toBe(0);
255
+ });
256
+
257
+ it('Bash 事件判定维持不变(回归:block 仍 exit 2)', () => {
258
+ jest.spyOn(console, 'error').mockImplementation(() => undefined);
259
+ expect(runPreToolUseHook(stdinOf('rm -rf /'))).toBe(2);
260
+ const traces = readTraces();
261
+ expect(traces).toHaveLength(1);
262
+ expect(traces[0].constraintId).toBe('command-gate');
263
+ });
264
+
265
+ it('缺 tool_name 的旧事件形状按 Bash 兼容(command 照常判定)', () => {
266
+ jest.spyOn(console, 'error').mockImplementation(() => undefined);
267
+ expect(runPreToolUseHook(JSON.stringify({ tool_input: { command: 'rm -rf /' } }))).toBe(2);
268
+ });
269
+ });
270
+
271
+ describe('CommandGate.match 公共只读面(P1-7)', () => {
272
+ it('返回命中规则明细(id/level/message),与 isAllowed 同一谓词', () => {
273
+ const gate = new CommandGate();
274
+ const hits = gate.match('rm -rf /');
275
+ expect(hits.length).toBeGreaterThan(0);
276
+ expect(hits.some((r) => r.id === 'rm-rf-root' && r.level === 'block')).toBe(true);
277
+ expect(gate.isAllowed('rm -rf /')).toBe(false);
278
+ });
279
+
280
+ it('干净命令命中为空', () => {
281
+ expect(new CommandGate().match('git status')).toEqual([]);
282
+ });
283
+
284
+ it('类别忽略对 match 同样生效', () => {
285
+ const gate = new CommandGate({ ignoreCategories: ['system'] });
286
+ expect(gate.match('rm -rf /')).toEqual([]);
287
+ });
288
+ });
82
289
  });
@@ -69,6 +69,7 @@ const EXPECTED_RUNTIME_EXPORTS = [
69
69
  'assertGateRegistryClosed',
70
70
  'bootstrapHarness',
71
71
  'bootstrapHarnessSync',
72
+ 'buildCheckEnv',
72
73
  'buildConstraintsUsageReport',
73
74
  'checkBeforeExecution',
74
75
  'checkConstraint',
@@ -77,6 +78,8 @@ const EXPECTED_RUNTIME_EXPORTS = [
77
78
  'classifyError',
78
79
  'collectUsageByConstraint',
79
80
  'configureTraceCollector',
81
+ 'contextEvidenceFlag',
82
+ 'contextFlag',
80
83
  'createAnalyzer',
81
84
  'createCheckerGate',
82
85
  'createCommandGate',
@@ -92,6 +95,7 @@ const EXPECTED_RUNTIME_EXPORTS = [
92
95
  'diagnoseRetireCandidates',
93
96
  'extractCodeStructure',
94
97
  'findConstraintsByTrigger',
98
+ 'formatEvidence',
95
99
  'getAllConstraints',
96
100
  'getCommandGate',
97
101
  'getCommandRiskLevel',
@@ -109,6 +113,7 @@ const EXPECTED_RUNTIME_EXPORTS = [
109
113
  'matchAnyGlob',
110
114
  'matchGlob',
111
115
  'migrateKnowledgeEntries',
116
+ 'normalizeCheckOutcome',
112
117
  'readProjectTraces',
113
118
  'readProjectTracesReport',
114
119
  'registeredGateCount',
@@ -121,8 +121,14 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
121
121
  'CheckCacheConfig',
122
122
  'CheckConfig',
123
123
  'CheckConstraintsOptions',
124
+ 'CheckDetail',
125
+ 'CheckEnv',
126
+ 'CheckEvidenceInput',
127
+ 'CheckInputNeeds',
128
+ 'CheckOutcome',
124
129
  'CheckResult',
125
130
  'CheckSamplingConfig',
131
+ 'CheckSkip',
126
132
  'CheckType',
127
133
  'CheckerVerdict',
128
134
  'Checkpoint',
@@ -141,6 +147,8 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
141
147
  'CompletionCheckersConfig',
142
148
  'ConstCountActual',
143
149
  'Constraint',
150
+ 'ConstraintChannel',
151
+ 'ConstraintCheck',
144
152
  'ConstraintCheckResult',
145
153
  'ConstraintContext',
146
154
  'ConstraintId',
@@ -154,6 +162,7 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
154
162
  'ConsumptionMode',
155
163
  'ContextAverages',
156
164
  'ContextDocsCheck',
165
+ 'ContextEvidenceFlag',
157
166
  'ContextFilesConfig',
158
167
  'ContextSource',
159
168
  'ContextSourceType',
@@ -174,6 +183,7 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
174
183
  'EffectiveConfigLint',
175
184
  'ErrorClassificationRule',
176
185
  'ErrorClassifierConfig',
186
+ 'EvidenceProviders',
177
187
  'EventHandler',
178
188
  'ExecutionResult',
179
189
  'ExecutionTrace',
@@ -206,6 +216,7 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
206
216
  'MaturityChange',
207
217
  'MaturityLevel',
208
218
  'MergedConstraintsConfig',
219
+ 'NormalizedOutcome',
209
220
  'PassesGateCheckResult',
210
221
  'PassesGateConfig',
211
222
  'PassesGateViolation',
@@ -256,14 +267,22 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
256
267
  'CheckCacheConfig',
257
268
  'CheckConfig',
258
269
  'CheckConstraintsOptions',
270
+ 'CheckDetail',
271
+ 'CheckEnv',
272
+ 'CheckEvidenceInput',
273
+ 'CheckInputNeeds',
274
+ 'CheckOutcome',
259
275
  'CheckResult',
260
276
  'CheckSamplingConfig',
277
+ 'CheckSkip',
261
278
  'CheckType',
262
279
  'Checkpoint',
263
280
  'CheckpointCheck',
264
281
  'CheckpointContext',
265
282
  'CheckpointResult',
266
283
  'Constraint',
284
+ 'ConstraintChannel',
285
+ 'ConstraintCheck',
267
286
  'ConstraintCheckResult',
268
287
  'ConstraintContext',
269
288
  'ConstraintId',
@@ -271,9 +290,12 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
271
290
  'ConstraintSeverity',
272
291
  'ConstraintResult',
273
292
  'ConstraintTrigger',
293
+ 'ContextEvidenceFlag',
274
294
  'ContextFilesResolution',
275
295
  'EffectiveConfigLint',
296
+ 'EvidenceProviders',
276
297
  'IronLawContext',
298
+ 'NormalizedOutcome',
277
299
  'PassesGateConfig',
278
300
  'RunEnv',
279
301
  'RunTarget',
@@ -56,12 +56,16 @@ const PUBLISHED_ENTRY_VALUES: Record<string, string[]> = {
56
56
  'PassesGate',
57
57
  'ProjectConfigLoader',
58
58
  'SpecValidator',
59
+ 'buildCheckEnv',
59
60
  'checkBeforeExecution',
60
61
  'checkConstraint',
61
62
  'checkConstraints',
62
63
  'constraintChecker',
64
+ 'contextEvidenceFlag',
65
+ 'contextFlag',
63
66
  'createPassesGate',
64
67
  'findConstraintsByTrigger',
68
+ 'formatEvidence',
65
69
  'getAllConstraints',
66
70
  'getCapabilitiesMode',
67
71
  'getConstraint',
@@ -69,6 +73,7 @@ const PUBLISHED_ENTRY_VALUES: Record<string, string[]> = {
69
73
  'getGovernanceConfig',
70
74
  'lintEffectiveConfig',
71
75
  'loadRawProjectConfig',
76
+ 'normalizeCheckOutcome',
72
77
  'resolveContextFiles',
73
78
  ],
74
79
  './presets': [
@@ -16,7 +16,7 @@ H5(#44)起:
16
16
  - knowledge 投影面(`src/cli/commands/knowledge-view.ts`)— 11 个 knowledge 子操作的**display model** 渲染与出口:`emitKnowledgeView`(json/人读唯一分派 + 退出码)、`announce`(取数期进度行,`--json` 下静默)、`TONE_STYLES` 角色→样式单表、维度/规则 label 与 `toneForMaturity`/`toneForScore`/`toneForSeverity` 三张映射、`resolveKnowledgeBaseDir` + `openKnowledgeStore`(路径兜底与 store 构造单点)(harness#133)
17
17
  - 各命令文件:check / validate / passes-gate / init / report / status / spec / sync-docs / knowledge / sdd / failure / release / constraints / spec-baseline-check
18
18
  - `report` 的约束面走生效集(ADR-0033 修缺口):collectConstraints 传 getMergedConstraintsConfig 的 merged config(与 check.ts 同一入口),总数/分级计数按生效集——此前跑内置全集,config.yml 禁用与应用层条目(`.harness/constraints.yml`)都进不了报告面
19
- - 6 门禁命令实现在 `acceptance` / `command` / `contract` / `performance` / `review` / `security`(其 CLI 元数据在 `src/gates/definitions.ts`,形状同为 `CommandDefinition`,ADR-0007);**判定一律穿过统一接口 `evaluate()`**,成败与措辞由共享面映射。`command` 只复用映射、保留自己的单行 ✓/✗ 输出(已对外的机器友好形状);`security audit` / `acceptance list` / `contract validate-schema` / `review status` / `command --list/--level` 是只展示不判断的子命令,直读报告面(`scan()` 等),不套骨架
19
+ - 6 门禁命令实现在 `acceptance` / `command` / `contract` / `performance` / `review` / `security`(其 CLI 元数据在 `src/gates/definitions.ts`,形状同为 `CommandDefinition`,ADR-0007);**判定一律穿过统一接口 `evaluate()`**,成败与措辞由共享面映射。`command` 只复用映射、保留自己的单行 ✓/✗ 输出(已对外的机器友好形状);`security audit` / `acceptance list` / `contract validate-schema` / `review status` / `command --list/--level` 是只展示不判断的子命令,直读报告面(`scan()` 等),不套骨架;`security secrets`(P1-8,ADR-0031,wayfinder 票08)是判定子命令但不经门禁——直跑 gitleaks 全历史扫描:二进制缺失 → skip(不 fail),有泄露 → fail(只列条数与文件、不打印密钥原文),干净 → ok;CI 的 secrets job(harness-governance.yml,fetch-depth: 0 + 固定版本安装 gitleaks)跑同一命令,安装后才是真门
20
20
  - CLI 子命令 `command` 的两个分支共用同一台 gate 实例(#135/ADR-0024):默认分支经 `evaluate()` 取裁决、`--level` 经同一实例的 `getRiskLevel()` 取等级,命令侧不再引用模块级单例出口——「配置传进去却到不了判定」的那条路已封。`--strict` 旗帜随 `CommandGateConfig.strict`(零消费者、从不生效)一并删除
21
21
 
22
22
  `constraints` 下挂治理子命令:`constraints report`(使用统计 + 退役候选诊断 + 配置健康,`--export` 脱敏;JSON 输出走 `--json-output`——原名 `--json` 与父命令同名会被 commander 消费在父侧、JSON 分支不可达,E1 复盘修正 M3.1 换名,闸见 `__tests__/constraints-report-json-flag.test.ts`)、`constraints retire`(交互选择 + 人确认退役;带 id 直达需显式 `--yes`(#24 人确认闸门),无 `--yes` 报错 + 非零退出码且不落盘;落 config.yml retired 墓碑 + KnowledgeStore 沉淀——沉淀写口的 baseDir 走 knowledge-view `openKnowledgeStore` 同一解析点,与 knowledge 读口同根,不再硬编码 projectRoot 拼接(harness#177)。ADR-0029:注入漂移小节、prompt 注入清单、custom 落点与治理注入段同步已随文本注入层关停移除。ADR-0032:already_retired 只认 retired 墓碑,裸 enabled:false 由退休流程接管补墓碑+沉淀(票 02 断点 6);落盘后 git 仓内附 commit 提示,不替用户动 git(断点 4)。ADR-0033:findRetireTarget 扩到内置 + 应用层(`.harness/constraints.yml`)——应用层退休墓碑同写 config.yml(enabled:false + retired 同形),constraints.yml 条文保留不删,沉淀条目 tags 加 `source:app`)、`constraints reactivate`(点对点复活:删 retired 墓碑段 + 写 `constraint-reactivated-<id>` 新沉淀,不改历史(ADR-0032 决策 6.5,票 02 断点 5);直达同需 `--yes`,无交互模式;ADR-0033 起对应用层约束同路径可用)、`constraints pack-proposal`(升级提案材料打包,ADR-0033 决策 4,块 3 子项 5:条文 + checker 模板与参数 + traces 使用统计 + 升级理由留白的脱敏 markdown,缺省落 `.harness/reports/proposal-<id>-<YYYYMMDD>.md`,`--stdout` 打印不落盘;脱敏只做项目根路径→`<repoRoot>` 替换,params 原文带出并标注人工确认——打包是质量前置不是保密闸门,人拿材料去 harness 仓开 issue)。
@@ -83,12 +83,12 @@ describe('check 命令 skip 输出', () => {
83
83
  jest.clearAllMocks();
84
84
  });
85
85
 
86
- it('skipped 单独列示,不计入 error 级通过条数', async () => {
86
+ it('skipped 单独列示,不计入 error 级通过条数;skipReason 随行列出(harness#182)', async () => {
87
87
  mockChecker.checkConstraints.mockResolvedValue({
88
88
  passed: true,
89
89
  errors: [
90
90
  { id: 'law_pass', severity: 'error', satisfied: true, checkedAt: new Date(), constraint: fakeConstraint('law_pass', 'error') },
91
- { id: 'law_skip', severity: 'error', satisfied: true, skipped: true, checkedAt: new Date(), constraint: fakeConstraint('law_skip', 'error') },
91
+ { id: 'law_skip', severity: 'error', satisfied: true, skipped: true, skipReason: 'staged diff 不可得(git 取证失败或未接线)', checkedAt: new Date(), constraint: fakeConstraint('law_skip', 'error') },
92
92
  ],
93
93
  warnings: [],
94
94
  warningCount: 0,
@@ -98,9 +98,9 @@ describe('check 命令 skip 输出', () => {
98
98
 
99
99
  // 通过条数只计实际评估的 1 条
100
100
  expect(io.outText()).toContain('error 级约束: 全部通过 (1 条)');
101
- // skipped 单独列示
101
+ // skipped 单独列示,原因随行(降级跳过与约定未采用在结果面可区分)
102
102
  expect(io.outText()).toContain('跳过评估: 1 条');
103
- expect(io.outText()).toContain('- law_skip');
103
+ expect(io.outText()).toContain('- law_skip:staged diff 不可得');
104
104
  // skip 不影响整体通过
105
105
  expect(io.outText()).toContain('约束检查通过');
106
106
  });
@@ -132,6 +132,8 @@ function recordingEvidence(projectPath: string): {
132
132
  requests.push('headDirs');
133
133
  return shared.headDirs();
134
134
  },
135
+ stagedDiffAvailable: () => shared.stagedDiffAvailable(),
136
+ changedFileNamesAvailable: (staged: boolean) => shared.changedFileNamesAvailable(staged),
135
137
  };
136
138
  return { evidence, requests, commands };
137
139
  }
@@ -2,7 +2,10 @@
2
2
  * security 命令测试
3
3
  */
4
4
 
5
- import { security, auditDetails } from '../security';
5
+ import * as fs from 'fs';
6
+ import * as os from 'os';
7
+ import * as path from 'path';
8
+ import { security, auditDetails, secretsScan } from '../security';
6
9
  import { captureIO, type CapturingIO } from '../../command-contract';
7
10
  import { decide, fakeGate } from './gate-decision';
8
11
  import { SecurityGate } from '../../../gates/security';
@@ -137,4 +140,89 @@ describe('security command', () => {
137
140
  );
138
141
  });
139
142
  });
143
+
144
+ describe('secretsScan(P1-8:gitleaks 全历史机密扫描)', () => {
145
+ let repoRoot: string;
146
+
147
+ beforeEach(() => {
148
+ repoRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-secrets-repo-'));
149
+ });
150
+
151
+ /**
152
+ * 假执行器(测试不依赖真 gitleaks 二进制):按 exitCode 抛错,
153
+ * 需要时把 report/rawReport 落到命令行里解析出的 --report-path。
154
+ */
155
+ function fakeExec(behavior: { exitCode: number; report?: unknown; rawReport?: string }) {
156
+ return (async (cmd: string) => {
157
+ const reportPath = cmd.match(/--report-path "([^"]+)"/)![1];
158
+ if (behavior.rawReport !== undefined) {
159
+ fs.writeFileSync(reportPath, behavior.rawReport);
160
+ } else if (behavior.report !== undefined) {
161
+ fs.writeFileSync(reportPath, JSON.stringify(behavior.report));
162
+ }
163
+ if (behavior.exitCode !== 0) {
164
+ throw Object.assign(new Error(`exit ${behavior.exitCode}`), { code: behavior.exitCode });
165
+ }
166
+ return { stdout: '', stderr: '' };
167
+ }) as any;
168
+ }
169
+
170
+ it('干净(exit 0 + 空报告)→ ok', async () => {
171
+ const result = await secretsScan({ projectPath: repoRoot }, io, fakeExec({ exitCode: 0, report: [] }));
172
+
173
+ expect(result).toEqual({ kind: 'ok' });
174
+ expect(io.outText()).toContain('未发现泄露');
175
+ });
176
+
177
+ it('有泄露(exit 1 + 报告有条目)→ fail:列条数与文件,不打印密钥原文', async () => {
178
+ // 假密钥值含 fake 占位标记:no_hardcoded_credentials checker 对 placeholder 行豁免
179
+ const report = [
180
+ { File: 'config/app.yml', RuleID: 'aws-access-key', Secret: 'fake-leak-value-1', Match: 'fake-leak-value-1' },
181
+ { File: 'config/app.yml', RuleID: 'aws-access-key', Secret: 'fake-leak-value-2', Match: 'fake-leak-value-2' },
182
+ { File: 'scripts/deploy.sh', RuleID: 'generic-api-key', Secret: 'fake-token-value-3', Match: 'fake-token-value-3' },
183
+ ];
184
+
185
+ const result = await secretsScan({ projectPath: repoRoot }, io, fakeExec({ exitCode: 1, report }));
186
+
187
+ expect(result.kind).toBe('fail');
188
+ expect(result.kind === 'fail' && result.reason).toContain('3 potential leaks in 2 files');
189
+ expect(io.outText()).toContain('发现 3 处疑似机密泄露');
190
+ expect(io.outText()).toContain('config/app.yml');
191
+ expect(io.outText()).toContain('scripts/deploy.sh');
192
+ // 密钥原文(Secret/Match 字段)不进输出
193
+ expect(io.outText()).not.toContain('fake-leak-value');
194
+ expect(io.outText()).not.toContain('fake-token-value');
195
+ });
196
+
197
+ it('gitleaks 二进制缺失(exit 127)→ skip 并提示安装,不 fail', async () => {
198
+ const result = await secretsScan({ projectPath: repoRoot }, io, fakeExec({ exitCode: 127 }));
199
+
200
+ expect(result.kind).toBe('skip');
201
+ expect(result.kind === 'skip' && result.reason).toContain('gitleaks binary not found');
202
+ expect(io.outText()).toContain('跳过全历史机密扫描');
203
+ });
204
+
205
+ it('gitleaks 异常退出(非 0/1/127)→ fail(scan error)', async () => {
206
+ const result = await secretsScan({ projectPath: repoRoot }, io, fakeExec({ exitCode: 2 }));
207
+
208
+ expect(result).toEqual({ kind: 'fail', reason: 'secrets scan error: gitleaks exited 2' });
209
+ });
210
+
211
+ it('报告 JSON 损坏 → fail(report parse failed)', async () => {
212
+ const result = await secretsScan(
213
+ { projectPath: repoRoot },
214
+ io,
215
+ fakeExec({ exitCode: 1, rawReport: 'not json {{{' }),
216
+ );
217
+
218
+ expect(result.kind).toBe('fail');
219
+ expect(result.kind === 'fail' && result.reason).toContain('report parse failed');
220
+ });
221
+
222
+ it('exit 0 且报告文件未落盘 → 按干净处理(ok)', async () => {
223
+ const result = await secretsScan({ projectPath: repoRoot }, io, fakeExec({ exitCode: 0 }));
224
+
225
+ expect(result).toEqual({ kind: 'ok' });
226
+ });
227
+ });
140
228
  });
@@ -189,11 +189,11 @@ export async function check(
189
189
  hints.forEach(r => logEvidence(io, r, 'gray', r.id));
190
190
  }
191
191
 
192
- // Skipped:约定未采用 / 证据未接线,未评估(不计通过/失败)
192
+ // Skipped:约定未采用 / 证据未接线 / 输入不可得,未评估(不计通过/失败;harness#182 起原因随行列出)
193
193
  if (skippedResults.length > 0) {
194
- log(io, chalk.gray(`⏭️ 跳过评估: ${skippedResults.length} 条(约定未采用或证据未接线,不计通过/失败)`));
194
+ log(io, chalk.gray(`⏭️ 跳过评估: ${skippedResults.length} 条(未评估,不计通过/失败)`));
195
195
  skippedResults.forEach(r => {
196
- log(io, chalk.gray(` - ${r.id}`));
196
+ log(io, chalk.gray(` - ${r.id}${r.skipReason ? `:${r.skipReason}` : ''}`));
197
197
  });
198
198
  }
199
199
 
@@ -5,7 +5,11 @@
5
5
  */
6
6
 
7
7
  import chalk from 'chalk';
8
+ import * as fs from 'fs';
9
+ import * as os from 'os';
10
+ import * as path from 'path';
8
11
  import { SecurityGate } from '../../gates/security';
12
+ import { execAsync } from '../../utils/exec';
9
13
  import { log, processIO, type CommandIO, type CommandResult } from '../command-contract';
10
14
  import { reportGateDecision } from '../gate-command';
11
15
 
@@ -92,6 +96,101 @@ function getSeverityColor(severity: string): (text: string) => string {
92
96
  }
93
97
  }
94
98
 
99
+ // ========== security secrets:全历史机密扫描(P1-8,ADR-0031,wayfinder 票08) ==========
100
+
101
+ export interface SecretsOptions {
102
+ /** 项目路径(= 待扫仓库根) */
103
+ projectPath?: string;
104
+ }
105
+
106
+ /** 执行器注入缝(测试不依赖真 gitleaks 二进制) */
107
+ type ExecFn = typeof execAsync;
108
+
109
+ /** gitleaks 报告条目中允许外显的字段(Secret/Match/Entropy 等一律不读不打印) */
110
+ interface GitleaksFinding {
111
+ File?: string;
112
+ RuleID?: string;
113
+ Description?: string;
114
+ }
115
+
116
+ /**
117
+ * 全历史机密扫描(`gitleaks git`,P1-8)。
118
+ *
119
+ * 口径:harness 出命令包 gitleaks——二进制缺失 → skip(不 fail),CI 安装后
120
+ * 才是真门(见 .github/workflows/harness-governance.yml 的 secrets job,
121
+ * fetch-depth: 0 + 固定版本安装后跑本命令,与本命令同一判定口径)。
122
+ *
123
+ * 出口纪律:有泄露只列条数与文件(截断 20 条),**不打印密钥原文**
124
+ * (报告里的 Secret/Match 字段从不进输出与 reason)。
125
+ */
126
+ export async function secretsScan(
127
+ options: SecretsOptions,
128
+ io: CommandIO = processIO,
129
+ execFn: ExecFn = execAsync,
130
+ ): Promise<CommandResult> {
131
+ log(io, chalk.blue('🔒 全历史机密扫描(gitleaks)...'));
132
+
133
+ const repoRoot = options.projectPath || process.cwd();
134
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-gitleaks-'));
135
+ const reportPath = path.join(tmpDir, 'report.json');
136
+
137
+ try {
138
+ let exitCode = 0;
139
+ try {
140
+ await execFn(
141
+ `gitleaks git --report-format json --report-path "${reportPath}" "${repoRoot}"`,
142
+ { cwd: repoRoot, maxBuffer: 10 * 1024 * 1024 },
143
+ );
144
+ } catch (error: any) {
145
+ // gitleaks 退出码:0 = 干净,1 = 发现泄露(报告已落盘);127 = 二进制不存在
146
+ exitCode = typeof error?.code === 'number' ? error.code : -1;
147
+ }
148
+
149
+ if (exitCode === 127) {
150
+ log(io, chalk.yellow('⏭️ 未检测到 gitleaks 二进制,跳过全历史机密扫描'));
151
+ log(io, chalk.gray(' 安装:https://github.com/gitleaks/gitleaks(CI 已接线为真门)'));
152
+ return { kind: 'skip', reason: 'gitleaks binary not found' };
153
+ }
154
+ if (exitCode !== 0 && exitCode !== 1) {
155
+ log(io, chalk.red(`❌ gitleaks 执行失败(exit ${exitCode})`));
156
+ return { kind: 'fail', reason: `secrets scan error: gitleaks exited ${exitCode}` };
157
+ }
158
+
159
+ let findings: GitleaksFinding[] = [];
160
+ if (fs.existsSync(reportPath)) {
161
+ try {
162
+ const parsed: unknown = JSON.parse(fs.readFileSync(reportPath, 'utf-8'));
163
+ findings = Array.isArray(parsed) ? (parsed as GitleaksFinding[]) : [];
164
+ } catch (error) {
165
+ const message = error instanceof Error ? error.message : String(error);
166
+ log(io, chalk.red(`❌ gitleaks 报告解析失败: ${message}`));
167
+ return { kind: 'fail', reason: `secrets scan error: report parse failed: ${message}` };
168
+ }
169
+ }
170
+
171
+ if (findings.length === 0) {
172
+ log(io, chalk.green('✅ 全历史机密扫描通过:未发现泄露'));
173
+ return { kind: 'ok' };
174
+ }
175
+
176
+ const files = [...new Set(findings.map((f) => f.File || '(unknown)'))];
177
+ log(io, chalk.red(`❌ 发现 ${findings.length} 处疑似机密泄露(涉及 ${files.length} 个文件):`));
178
+ for (const file of files.slice(0, 20)) {
179
+ log(io, chalk.gray(` - ${file}`));
180
+ }
181
+ if (files.length > 20) {
182
+ log(io, chalk.gray(` ... 其余 ${files.length - 20} 个文件略`));
183
+ }
184
+ log(io, chalk.gray(' 密钥原文不打印;详情用 gitleaks 本地复查,泄露凭证按已泄露处置(吊销轮换)'));
185
+ return {
186
+ kind: 'fail',
187
+ reason: `secrets scan failed: ${findings.length} potential leaks in ${files.length} files`,
188
+ };
189
+ } finally {
190
+ fs.rmSync(tmpDir, { recursive: true, force: true });
191
+ }
192
+ }
193
+
95
194
  /**
96
195
  * 运行安全审计详情
97
196
  */