dsh-perm-gate 2.1.0 → 3.0.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/CHANGELOG.ja.md +82 -0
- package/CHANGELOG.ko.md +80 -0
- package/CHANGELOG.md +321 -0
- package/INSTALL.ja.md +70 -8
- package/INSTALL.ko.md +68 -9
- package/INSTALL.md +68 -8
- package/INSTALL.zh.md +59 -7
- package/README.ja.md +103 -16
- package/README.ko.md +101 -17
- package/README.md +152 -25
- package/README.zh.md +99 -12
- package/cordis.patch.yml +34 -3
- package/docs/baseline-guard.md +56 -0
- package/docs/plan-rules-to-settings.md +217 -0
- package/docs/rules-format.en.md +294 -0
- package/docs/rules-format.md +279 -0
- package/docs/ui-gap-analysis-and-branch-permissions.md +338 -0
- package/dsh.plugin.json +22 -0
- package/examples/permissions.example.yaml +16 -1
- package/lib/agent-identity.d.ts +43 -0
- package/lib/agent-identity.js +95 -0
- package/lib/allowlist.d.ts +27 -0
- package/lib/allowlist.js +103 -1
- package/lib/cli.js +11 -14
- package/lib/client.js +598 -6
- package/lib/client.js.map +1 -1
- package/lib/command-dispatcher.d.ts +22 -0
- package/lib/command-dispatcher.js +97 -0
- package/lib/command-semantics.d.ts +62 -0
- package/lib/command-semantics.js +6 -0
- package/lib/compiler.d.ts +50 -0
- package/lib/compiler.js +122 -0
- package/lib/config.d.ts +161 -7
- package/lib/config.js +78 -11
- package/lib/dry-run.d.ts +87 -0
- package/lib/dry-run.js +110 -0
- package/lib/engine.js +61 -4
- package/lib/evaluate.d.ts +9 -0
- package/lib/evaluate.js +264 -1
- package/lib/events.d.ts +69 -2
- package/lib/events.js +123 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +320 -11
- package/lib/network-lifecycle.d.ts +107 -0
- package/lib/network-lifecycle.js +180 -0
- package/lib/network.d.ts +109 -0
- package/lib/network.js +196 -0
- package/lib/parsers/git.d.ts +43 -0
- package/lib/parsers/git.js +404 -0
- package/lib/parsers/shell-cmds.d.ts +32 -0
- package/lib/parsers/shell-cmds.js +293 -0
- package/lib/preset.d.ts +13 -0
- package/lib/preset.js +17 -0
- package/lib/proxy.d.ts +160 -0
- package/lib/proxy.js +529 -0
- package/lib/risk.d.ts +17 -3
- package/lib/risk.js +19 -6
- package/lib/rule-chain.d.ts +39 -0
- package/lib/rule-chain.js +213 -0
- package/lib/rule-dims.d.ts +174 -0
- package/lib/rule-dims.js +230 -0
- package/lib/rule.d.ts +60 -0
- package/lib/rule.js +69 -7
- package/lib/rules-view.d.ts +52 -0
- package/lib/rules-view.js +126 -0
- package/lib/runtime.d.ts +208 -7
- package/lib/runtime.js +433 -27
- package/lib/session-sweep.d.ts +45 -0
- package/lib/session-sweep.js +153 -0
- package/lib/shadow.d.ts +34 -0
- package/lib/shadow.js +143 -0
- package/lib/shell.d.ts +14 -0
- package/lib/shell.js +17 -0
- package/lib/watch.d.ts +42 -0
- package/lib/watch.js +170 -0
- package/package.json +15 -2
- package/scripts/patch-permission-glyph.mjs +209 -0
package/README.ko.md
CHANGED
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
> | DSH 버전 | 브랜치 | 버전 | npm 태그 |
|
|
28
28
|
> | --- | --- | --- | --- |
|
|
29
29
|
> | 0.1.0-rc.7 ~ 0.1.1-rc.x | `legacy` | `1.x` | `@legacy` |
|
|
30
|
-
> | 0.1.2-alpha.1
|
|
30
|
+
> | 0.1.2-alpha.1 ~ 0.1.5-rc.0 | `main` | `2.x` | `@latest` / `@dsh-0.1.2` (`@2.x`는 범위) |
|
|
31
|
+
> | 0.1.5-rc.1+ | `sync/0.1.5-from-main` (=`compat/0.1.5`) | `3.x` | GitHub ref 설치 (dist-tag 미게시) |
|
|
31
32
|
>
|
|
32
33
|
> 버전 계열은 **DSH 라인**을 따릅니다(`1.x` = DSH ≤ 0.1.1, `2.x` = DSH 0.1.2+). 메이저
|
|
33
34
|
> 버전이 서로를 차단하므로 `^1.x` 설치가 `2.x`를 해석하는 일은 없고 그 반대도
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
> 모두에서 user-approval 서비스의 **개인** 메소드이므로 `typeof` 프로브를 통해
|
|
44
45
|
> 읽으며, 누락되거나 예외 발생 시 "정책_unknown"으로 후퇴합니다.
|
|
45
46
|
|
|
46
|
-
버전 **2.
|
|
47
|
+
버전 **2.6.0** — 변경 내역은 [한국어 changelog](./CHANGELOG.ko.md)를 참고하세요.
|
|
47
48
|
|
|
48
49
|
DeepSeek Harness용 단일·자족적·결정론 우선·fail-closed 권한 게이트입니다.
|
|
49
50
|
|
|
@@ -84,7 +85,7 @@ DSH 안전 생태계에서는 이 역할이 `dsh-permission-rules` / `dsh-auto-m
|
|
|
84
85
|
모드**. 범용 "자동 승인"도 아니고 포괄적 권한 부여도 아닙니다. 프론트는 **단일 스위치**
|
|
85
86
|
(`permissive`)만 노출하고, 백엔드의 네 가지 전략은 **조합 가능**하며 플러그인
|
|
86
87
|
설정으로 제어됩니다. P0에 대해서는 여전히 fail-closed입니다.
|
|
87
|
-
권한 선택기와 설정 행 모두 제품명 「自动审查」로
|
|
88
|
+
권한 선택기와 설정 행 모두 제품명 「自动审查」로 표시합니다. 아이콘은 아래를 참고하세요(내장 티어는 기본 제공, 플러그인 티어는 패치 필요).
|
|
88
89
|
- **샌드박스 승격 자동 응답** (`trustEscalation`) — 샌드박스 승격은 shell / pwsh /
|
|
89
90
|
edit 도구의 **내부**(`tools/pre-execute` 이후)에서 발생하므로 게이트가 이를 볼 수
|
|
90
91
|
없고, 게이트가 자동 허용한 호출에도 확인 프롬프트가 나타납니다. 이 전략을 켜면 게이트가
|
|
@@ -114,7 +115,7 @@ dsh plugin --profile web add dsh-perm-gate
|
|
|
114
115
|
rulesFile: ./permissions.yaml # 선택. 기본값은 $DSH_HOME/perm-gate/rules.yml
|
|
115
116
|
dshHome: $DSH_HOME # 보호 대상 검사의 고정 루트
|
|
116
117
|
defaultAction: ask # allow | ask | deny
|
|
117
|
-
gatePresets: [permissive]
|
|
118
|
+
gatePresets: [permissive, permissive-full] # 게이트가 활성화되는 티어(기본)
|
|
118
119
|
```
|
|
119
120
|
|
|
120
121
|
### 규칙 파일
|
|
@@ -144,18 +145,97 @@ permissions:
|
|
|
144
145
|
|
|
145
146
|
전체 예시: [examples/permissions.example.yaml](./examples/permissions.example.yaml)
|
|
146
147
|
|
|
148
|
+
### 네트워크 정책(선택적 활성화)
|
|
149
|
+
|
|
150
|
+
로컬 HTTP/CONNECT 프록시입니다. **동일한 규칙 파일**로 **shell 서브프로세스**의 아웃바운드
|
|
151
|
+
트래픽을 심사하고, 어떤 규칙에도 해당하지 않는 대상에는 승인 경로를 제공합니다. **기본값은
|
|
152
|
+
비활성** —— 활성화하면 루프백 포트를 바인딩하고 자식 프로세스의 프록시 환경 변수를 다시 쓰기
|
|
153
|
+
때문에 암묵적으로 켜지지 않습니다.
|
|
154
|
+
|
|
155
|
+
```yaml
|
|
156
|
+
- id: dsh-perm-gate
|
|
157
|
+
config:
|
|
158
|
+
networkEnabled: false # 마스터 스위치(기본 false)
|
|
159
|
+
networkMode: whitelist # deny-all | whitelist | allow-all
|
|
160
|
+
networkUnlisted: ask # ask | deny —— 미등록 대상 처리
|
|
161
|
+
networkUnattributed: allow # allow | deny —— shell 귀속 없는 트래픽
|
|
162
|
+
networkInjectEnv: true # 자식 프로세스에 HTTP(S)_PROXY / ALL_PROXY 주입
|
|
163
|
+
networkAskTimeoutMs: 120000 # 승인 대기 상한, 초과 시 거부
|
|
164
|
+
networkGrantTtlMs: 1800000 # 승인 1회가 유효한 세션 기간
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**단계적 동작**: 허용 규칙이 없으면 어떤 대상도 나갈 수 없습니다. 미등록 대상은 해당 연결을
|
|
168
|
+
연 shell 명령의 세션에 대해 대화형 승인으로 에스컬레이션되고, 승인하면 그 대상이 해당
|
|
169
|
+
세션에서 허용됩니다. **`deny` 규칙은 승인으로 올라가지 않습니다** —— 승인은 "어떤 규칙도
|
|
170
|
+
금지하지 않은 대상"의 도달 범위를 넓힐 수 있지만, 금지하는 규칙을 뒤집을 수는 없습니다.
|
|
171
|
+
|
|
172
|
+
**경계 —— 의존하기 전에 반드시 읽으십시오**: 이 프록시는 **협조형** 정책 계층이며 강제
|
|
173
|
+
경계가 아닙니다. 프록시 환경 변수를 **읽는** 클라이언트의 트래픽만 볼 수 있습니다.
|
|
174
|
+
|
|
175
|
+
| 클라이언트 | 차단 가능? |
|
|
176
|
+
|------------|------------|
|
|
177
|
+
| `curl`, `wget`, `git`, Go `net/http`, Python `requests` | ✅ |
|
|
178
|
+
| **Node.js `http` / `https` / `fetch`** | ❌ **직접 연결. 프록시가 보지 못함** |
|
|
179
|
+
| Java(`-D` 프록시 미지정), .NET `HttpClient` | ❌ |
|
|
180
|
+
| 원시 소켓, 직접 구현한 TCP | ❌ |
|
|
181
|
+
| DNS, QUIC/HTTP3, 비 HTTP 프로토콜 | ❌ |
|
|
182
|
+
| 리터럴 IP 연결 | ❌ |
|
|
183
|
+
|
|
184
|
+
따라서 `node -e "require('http').get('http://host/')"` 같은 명령은 **차단되지 않습니다**.
|
|
185
|
+
이것을 "실수를 막는 가드레일이자 의도를 선언하는 지점"으로 보십시오. 밀폐된 샌드박스가
|
|
186
|
+
아닙니다.
|
|
187
|
+
|
|
188
|
+
DSH **자신**의 트래픽 —— 내장 네트워크 도구와 LLM 전송 —— 은 의도적으로 대상에서 제외됩니다.
|
|
189
|
+
이 연결들은 shell 귀속이 없고, `networkUnattributed: allow`(기본값)가 그대로 통과시킵니다.
|
|
190
|
+
심사하면 호스트가 **스스로를 차단**하게 되며, 이는 놓치는 것보다 훨씬 나쁜 장애입니다.
|
|
191
|
+
호스트의 클라이언트가 프록시 환경 변수를 읽지 않는다고 확신할 때만 `deny`로 바꾸십시오.
|
|
192
|
+
|
|
193
|
+
실시간 상태 조회: `GET /api/dsh-perm-gate/network`(모드 / 바인드 / 포트 / 프록시 활성 /
|
|
194
|
+
환경 주입 상태 / 차단 카운터 / 최근 차단).
|
|
195
|
+
|
|
147
196
|
## 自动审查 티어(머신 값 `permissive`)
|
|
148
197
|
|
|
149
198
|
自动审查는 권한 선택기에서 읽기 전용 / 워크스페이스 내 수정 / 완전 권한 / 허용 목록과
|
|
150
199
|
나란한 **독립 승인 티어**입니다. 범용 "자동 승인"이 아니며 포괄적 권한을 발행하지도 않습니다.
|
|
151
|
-
사람/LLM 심 **이전에** 판정을 좁히거나 넓힐 뿐이고, P0 하드 거부는
|
|
152
|
-
불가능하게 유지됩니다.
|
|
153
|
-
|
|
154
|
-
|
|
200
|
+
사람/LLM 심 **이전에** 판정을 좁히거나 넓힐 뿐이고, P0 하드 거부는 **게이트 자체 범위 안에서**
|
|
201
|
+
단조롭고 협상 불가능하게 유지됩니다.
|
|
202
|
+
|
|
203
|
+
> **P0는 범위가 있으며 전역이 아닙니다.** 이 게이트는 세션 권한 프리셋이 `gatePresets`(기본값
|
|
204
|
+
> `permissive` / `permissive-full`) 중 하나일 때만 동작합니다. 그 밖의 프리셋 —— 읽기 전용 /
|
|
205
|
+
> 워크스페이스 내 수정 / 완전 권한 —— 에서는 **P0 하드 거부를 포함한 게이트 전체가 정지**하고,
|
|
206
|
+
> 선택된 티어 자체의 정책이 그 세션을 통치합니다. 의도된 설계이지만(설정 표의 `gatePresets` 참조),
|
|
207
|
+
> "P0는 협상 불가"는 **게이트의 티어 안에서** 성립하는 것이지 모든 티어에 걸친 것이 아닙니다.
|
|
208
|
+
> 정지는 **침묵하지 않습니다**: 세션/프리셋 전환마다 `stand-down` 이벤트 1건을 기록하고 브라우저는
|
|
209
|
+
> 입력창 위에 **GATE OFF** 상시 표시줄을 띄웁니다. `gatePresets: ['*']`로 설정하면 P0는 다시
|
|
210
|
+
> 전역이 됩니다.
|
|
211
|
+
|
|
212
|
+
**두 가지 변형을 함께 제공합니다.** 프리셋의 `sandbox`와 `approval`은 **독립된** 노브이며, 둘을
|
|
213
|
+
묶으면 나쁜 트레이드오프를 강요받기 때문입니다.
|
|
214
|
+
|
|
215
|
+
| 선택기 표시 이름 | 머신 값 | sandbox | approval |
|
|
216
|
+
|------------------|---------|---------|----------|
|
|
217
|
+
| 自动审查 | `permissive` | `workspace-write` | `ask` |
|
|
218
|
+
| 自动审查(고권한) | `permissive-full` | `danger-full-access` | `ask` |
|
|
219
|
+
|
|
220
|
+
일반 티어는 내장 파일 샌드박스를 유지합니다. 그 샌드박스는 자식 프로세스 시작에 필요한 이름 있는
|
|
221
|
+
파이프도 거부하므로 `git clone`, MSYS2/Cygwin의 `sh.exe`, ConPTY가 `Win32 error 5` /
|
|
222
|
+
`couldn't create signal pipe`로 실패합니다. 게다가 게이트는 **`gatePresets`에 나열한 티어에서만
|
|
223
|
+
동작**하므로, 게이트를 쓰려면 이 제한을 받아들여야 했습니다. 「自动审查(고권한)」는 이 결합을
|
|
224
|
+
풉니다 —— **승인 동작은 동일하게 유지하고 파일 샌드박스 제한만 해제합니다**. 둘 다 기본
|
|
225
|
+
`gatePresets`에 포함되므로 어느 쪽을 선택해도 P0–P4 전체 체인이 동작합니다. 게이트는 프리셋의
|
|
226
|
+
**이름**만 읽고 sandbox 모드는 읽지 않습니다.
|
|
227
|
+
|
|
228
|
+
선택기의 표시 이름은 **호스트가 공급하는 제품명**이며 언어별 사전 항목이 아닙니다. DSH는
|
|
155
229
|
플러그인 티어의 `name:`을 두 권한 화면(일반 설정 기본 행과 입력창 선택기)에 그대로 렌더링하고
|
|
156
230
|
자체 지역화 라벨은 세 가지 내장 값에만 부여하므로, `cordis.patch.yml`이 모든 세션에 중국어
|
|
157
|
-
라벨을 배포합니다.
|
|
158
|
-
|
|
231
|
+
라벨을 배포합니다.
|
|
232
|
+
|
|
233
|
+
**아이콘은 다른 이야기입니다.** 입력창의 글리프 표는 닫혀 있고, 그 표 자체의 주석이 규칙을
|
|
234
|
+
말합니다: *host-configured names outside the design set get none*. `permissive`는 내장 값이라
|
|
235
|
+
「自动审查」에는 원래부터 방패+눈 아이콘이 있습니다. 「自动审查(高权限)」가 같은 아이콘을
|
|
236
|
+
갖는 것은 `npx dsh-perm-gate-patch-glyph`가 그 표에 항목 하나를 추가했기 때문입니다.
|
|
237
|
+
이 패치는 **호스트** 패키지를 고치므로 DSH 업그레이드마다 사라집니다 ——
|
|
238
|
+
[DSH 업그레이드 후: 입력창 아이콘 패치 재적용](./INSTALL.ko.md)을 참고하세요.
|
|
159
239
|
|
|
160
240
|
`cordis.yml`에서:
|
|
161
241
|
|
|
@@ -221,11 +301,13 @@ never` 패스스루 — 는 사람에 그대로 위임되므로 향후 DSH 변
|
|
|
221
301
|
선택기에는 "auto-approval"이 아니라 **독립적으로 선택 가능한 승인 티어**인
|
|
222
302
|
「自动审查」가 놓입니다.
|
|
223
303
|
|
|
224
|
-
게이트가 동작하는 범위는 **`gatePresets`에 나열한 티어 안뿐**입니다(기본
|
|
225
|
-
이 플러그인이 추가하는 티어). 그 밖의 티어(Read Only / Workspace Write / Full access /
|
|
304
|
+
게이트가 동작하는 범위는 **`gatePresets`에 나열한 티어 안뿐**입니다(기본
|
|
305
|
+
`['permissive', 'permissive-full']`, 이 플러그인이 추가하는 두 티어). 그 밖의 티어(Read Only / Workspace Write / Full access /
|
|
226
306
|
`custom`)에서는 게이트의 판정 흐름이 **전혀 실행되지 않습니다** — 허용도, ask도, 거부도,
|
|
227
|
-
P0 하드 거부도, 거부 키워드
|
|
228
|
-
호출을 결정합니다.
|
|
307
|
+
P0 하드 거부도, 거부 키워드 차단도 하지 않습니다. 선택한 티어의 자체 정책이
|
|
308
|
+
호출을 결정합니다. 다만 **침묵하지는 않습니다**: 세션/프리셋 전환마다 `stand-down` 이벤트를 1건만
|
|
309
|
+
기록하고(판정이 아니라 알림입니다), 브라우저는 입력창 위에 **GATE OFF** 상시 표시줄을 띄웁니다.
|
|
310
|
+
`danger-full-access`의 정의는 "승인 프롬프트 없는 전체 접근"이며, 이를 ask로
|
|
229
311
|
덮어써도 의미가 없습니다(그 정책에서는 DSH 승인 시임이 **어떤 answerer보다도 먼저** `rejected`를
|
|
230
312
|
반환해 전달된 ask는 패널을 한 번도 띄우지 못하고 `the user rejected tool "..."`만 남습니다).
|
|
231
313
|
하드 거부로 덮어쓰는 것 역시 사용자가 고른 티어를 조용히 뒤집는 일입니다.
|
|
@@ -245,7 +327,8 @@ host는 네임스페이스를 live로 읽으므로 변경은 재시작 없이
|
|
|
245
327
|
`llmAssist`가 켜져 있으면 설정된 LLM(OpenAI 호환 엔드포인트라면 무엇이든 — `classifierEndpoint` / `classifierModel` / `classifierApiKey`을 자신의 API로 지정)이 구조화된 프로토콜로 `ask`를 하나씩 판정합니다. **판정은 게이트의 `tools/pre-execute` 워터폴 안에서, 결정이 호스트로 반환되기 전에 이루어집니다**: `safe`는 곧바로 위임되므로 승인 패널이 아예 표시되지 않고, 정말로 판단할 수 없는 판정만 사람에게 전달됩니다.
|
|
246
328
|
|
|
247
329
|
- `safe` → 자동 허용(감사 소스 `classifier`), 패널 없음.
|
|
248
|
-
- `risky` + **하드 위험 카테고리**(`deletion`, `credential`, `remote`, `system`, `bulk`) →
|
|
330
|
+
- `risky` + **하드 위험 카테고리**(`deletion`, `credential`, `remote`, `system`, `bulk`) → **사람 확인(ask)을 유지**합니다. 분류기는 **결코 거부하지 않습니다**. 거부는 결정론적 계층(P0 하드 거부, 거부 키워드 블랙리스트, 명시적 `deny:` 규칙)에만 속하므로, 잘못 판정된 카테고리는 언제나 협상 가능하며 이의를 제기할 수 없는 차단이 되지 않습니다. 하드 카테고리가 `neutral`과 다른 중요한 점은 하나뿐입니다: **결코 학습되지 않으므로** 승인을 반복해도 자동 허용으로 침전되지 않습니다.
|
|
331
|
+
(모델의 판단을 거부 근거로 삼은 결과는 실측되었습니다: 무해한 `git commit -F …`가 `remote`로 판정되어 패널도, 재시도용 grant도 없는 자동 거부가 발생했습니다.)
|
|
249
332
|
- `risky:neutral` → `riskLearning` 활성 시(설정 카드, 기본 꺼짐), 사람이 승인하고 실제 실행된 neutral 위험은 `tool|카테고리` 키로 카운트되며, `riskThreshold`(기본 3) 도달 및 새 호출의 작업 지문(명령어 단어 + 대상 기본 이름)이 확인된 샘플과 일치하면 **동일 작업만** 자동 허용됩니다. 학습 침전(`riskSediment`, 기본 켜짐)을 사용하면 임계값에 도달한 키의 확인 샘플이 **결정론적 허용 규칙**이 됩니다: 지문이 정확히 일치하면 LLM 호출 없이 바로 허용——llmAssist가 꺼져도 유지되며, 침전 규칙은 설정 카드에서 확인·관리(종료 / 샘플 삭제)할 수 있습니다.
|
|
250
333
|
- 시간 초과(`riskTimeoutMs`, 기본 20초, 1회 재시도), 전송 실패, 프로토콜 외 출력은 원래 `ask`를 유지합니다.
|
|
251
334
|
|
|
@@ -261,8 +344,9 @@ host는 네임스페이스를 live로 읽으므로 변경은 재시작 없이
|
|
|
261
344
|
카드에서 목록으로 편집할 수 있고(프리셋 항목에는 태그 표시, 원클릭 복원 지원) 미설정·빈 목록 시 프리셋이
|
|
262
345
|
적용됩니다——블랙리스트가 조용히 꺼지지 않습니다.
|
|
263
346
|
블랙리스트가 조용히 꺼지는 일은 없습니다.
|
|
264
|
-
|
|
265
|
-
|
|
347
|
+
「自动审查」와 「自动审查(高权限)」는 둘 다 선택기에 방패+눈 아이콘을 그립니다 — 전자는
|
|
348
|
+
DSH 내장 표에서, 후자는 설치 안내에 적힌 호스트 패치에서 옵니다. 그 패치가 없으면 두 번째
|
|
349
|
+
티어는 모든 화면에서 텍스트만 표시됩니다. 라벨과 게이트는 영향을 받지 않습니다.
|
|
266
350
|
|
|
267
351
|
|
|
268
352
|
## CLI(독립 실행 dry-run)
|
package/README.md
CHANGED
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
> | DSH version | Branch | Version | npm tag |
|
|
27
27
|
> | --- | --- | --- | --- |
|
|
28
28
|
> | 0.1.0-rc.7 ~ 0.1.1-rc.x | `legacy` | `1.x` | `@legacy` |
|
|
29
|
-
> | 0.1.2-alpha.1
|
|
29
|
+
> | 0.1.2-alpha.1 ~ 0.1.5-rc.0 | `main` | `2.x` | `@latest` / `@dsh-0.1.2` (`@2.x` is a range) |
|
|
30
|
+
> | 0.1.5-rc.1+ | `sync/0.1.5-from-main` (=`compat/0.1.5`) | `3.x` | GitHub ref install (no dist-tag yet) |
|
|
30
31
|
>
|
|
31
32
|
> The series number tracks the **DSH line** (`1.x` = DSH ≤ 0.1.1, `2.x` = DSH 0.1.2+),
|
|
32
33
|
> and the majors fence each other: a `^1.x` install never resolves a `2.x` release and
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
> **private** method of the user-approval service on both, so it is read behind a
|
|
43
44
|
> `typeof` probe and degrades to “policy unknown” when absent or throwing.
|
|
44
45
|
|
|
45
|
-
Version **2.
|
|
46
|
+
Version **2.6.0** — see the [Changelog](./CHANGELOG.md).
|
|
46
47
|
|
|
47
48
|
A single, self-sufficient, deterministic-first, fail-closed permission gate for DeepSeek Harness.
|
|
48
49
|
|
|
@@ -77,11 +78,13 @@ cross-plugin version coupling.
|
|
|
77
78
|
malformed rules, and source-hash compile caching.
|
|
78
79
|
- **Audit** — every decision is logged as an `{ignorable:true}` event with its `callId`; the
|
|
79
80
|
model-visible reason matches the recorded outcome.
|
|
80
|
-
- **自动审查 tier** (`permissive`) — an **independent approval mode**
|
|
81
|
-
full-access and whitelist tiers) that is neither "auto-approve" nor
|
|
82
|
-
exposes a **single switch** (`permissive`); the four backend strategies
|
|
83
|
-
driven by plugin settings — still fail-closed against P0. The permission
|
|
84
|
-
settings row both show it under the product label 自动审查, with no icon.
|
|
81
|
+
- **自动审查 tier** (`permissive`, plus `permissive-full`) — an **independent approval mode**
|
|
82
|
+
(separate from read-only, full-access and whitelist tiers) that is neither "auto-approve" nor
|
|
83
|
+
blanket trust. Front-end exposes a **single switch** (`permissive`); the four backend strategies
|
|
84
|
+
are **combinable** and driven by plugin settings — still fail-closed against P0. The permission
|
|
85
|
+
picker and the settings row both show it under the product label 自动审查, with no icon. The
|
|
86
|
+
`permissive-full` variant keeps the identical approval behaviour but drops the built-in file
|
|
87
|
+
sandbox, which otherwise denies the named pipes `git clone` / Cygwin / ConPTY need.
|
|
85
88
|
- **Sandbox-escalation auto-answer** (`trustEscalation`) — a sandbox escalation is asked from
|
|
86
89
|
*inside* the shell / pwsh / edit tool body, after `tools/pre-execute`, so the gate never saw
|
|
87
90
|
it and a call it auto-allowed still prompted you to approve the widening. With this strategy
|
|
@@ -125,9 +128,24 @@ Add the plugin to `cordis.yml`:
|
|
|
125
128
|
rulesFile: ./permissions.yaml # optional; defaults to $DSH_HOME/perm-gate/rules.yml
|
|
126
129
|
dshHome: $DSH_HOME # root pinned for protected-target checks
|
|
127
130
|
defaultAction: ask # allow | ask | deny
|
|
128
|
-
gatePresets: [permissive]
|
|
131
|
+
gatePresets: [permissive, permissive-full] # tiers where the gate is active (default)
|
|
132
|
+
sessionSweep: true # hourly cleanup of archived/dead sessions' gate data
|
|
129
133
|
```
|
|
130
134
|
|
|
135
|
+
### Session sweep
|
|
136
|
+
|
|
137
|
+
On startup and every hour the gate reads DSH's workspace store
|
|
138
|
+
(`$DSH_HOME/storages/workspace.json`, read-only) and classifies every session it
|
|
139
|
+
holds authorization-chain data for. Sessions DSH has archived (`global.archivedSessionIds`)
|
|
140
|
+
or no longer tracks at all have their decision events dropped from
|
|
141
|
+
`$DSH_HOME/perm-gate/events.jsonl` and their pre-change snapshot files deleted
|
|
142
|
+
from `$DSH_HOME/perm-gate/snapshots/` — history the review page can no longer
|
|
143
|
+
reach, for data the harness itself considers gone. Live sessions are untouched,
|
|
144
|
+
unattributable rows (empty session id) are never deleted, and any failure is
|
|
145
|
+
fail-open: the round is skipped and retried an hour later. Set `sessionSweep: false`
|
|
146
|
+
to disable; `workspaceStoreFile` overrides the store path. Restoring an archived
|
|
147
|
+
session does not restore its swept history.
|
|
148
|
+
|
|
131
149
|
### Rules file
|
|
132
150
|
|
|
133
151
|
```yaml
|
|
@@ -154,18 +172,104 @@ permissions:
|
|
|
154
172
|
A command entry `word#flag` matches the command word (`word`) with the modifier `recursive` or
|
|
155
173
|
`force` — so `rm#recursive` matches `rm -rf`, `env rm -rf`, and `sh -c "rm -rf /"`.
|
|
156
174
|
|
|
175
|
+
### Network policy (opt-in)
|
|
176
|
+
|
|
177
|
+
A local HTTP/CONNECT proxy that adjudicates the outbound traffic of **shell
|
|
178
|
+
subprocesses** against the same rules file, plus an approval path for targets no
|
|
179
|
+
rule covers. **Off by default** — enabling it binds a loopback port and rewrites
|
|
180
|
+
the proxy environment for child processes, so it is never turned on implicitly.
|
|
181
|
+
|
|
182
|
+
```yaml
|
|
183
|
+
- id: dsh-perm-gate
|
|
184
|
+
config:
|
|
185
|
+
networkEnabled: false # master switch (default false)
|
|
186
|
+
networkMode: whitelist # deny-all | whitelist | allow-all
|
|
187
|
+
networkUnlisted: ask # ask | deny — unlisted target handling
|
|
188
|
+
networkUnattributed: allow # allow | deny — traffic with no shell attribution
|
|
189
|
+
networkInjectEnv: true # rewrite HTTP(S)_PROXY/ALL_PROXY for children
|
|
190
|
+
networkAskTimeoutMs: 120000 # approval wait before failing closed
|
|
191
|
+
networkGrantTtlMs: 1800000 # how long one approval covers its target
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Tiered behaviour.** Nothing reaches the network without an allow rule.
|
|
195
|
+
An unlisted target is escalated to the interactive approval seam, raised on
|
|
196
|
+
behalf of the shell command that opened the connection; approving widens reach
|
|
197
|
+
for that target for the session. A `deny` rule is **never** escalated —
|
|
198
|
+
approval can widen what an unlisted target may reach, but it can never override
|
|
199
|
+
a rule that says no.
|
|
200
|
+
|
|
201
|
+
**The boundary — read this before relying on it.** The proxy is a *cooperative*
|
|
202
|
+
policy layer, not an enforcement boundary. It only sees traffic from clients
|
|
203
|
+
that read the proxy environment:
|
|
204
|
+
|
|
205
|
+
| Client | Covered? |
|
|
206
|
+
|--------|----------|
|
|
207
|
+
| `curl`, `wget`, `git`, Go `net/http`, Python `requests` | yes |
|
|
208
|
+
| **Node.js `http`/`https`/`fetch`** | **no — connects directly** |
|
|
209
|
+
| Java (without `-D` proxy flags), .NET `HttpClient` | no |
|
|
210
|
+
| Raw sockets, custom TCP | no |
|
|
211
|
+
| DNS, QUIC/HTTP3, non-HTTP protocols | no |
|
|
212
|
+
| Connections to a literal IP | no |
|
|
213
|
+
|
|
214
|
+
So a shell command like `node -e "require('http').get('http://host/')"` is not
|
|
215
|
+
intercepted. Treat this as a guardrail against accidents and a place to state
|
|
216
|
+
intent, not as a hermetic sandbox.
|
|
217
|
+
|
|
218
|
+
DSH's **own** network traffic — the built-in network tools and the LLM
|
|
219
|
+
transport — is deliberately left alone. Those connections carry no shell
|
|
220
|
+
attribution, and `networkUnattributed: allow` (the default) passes them
|
|
221
|
+
through unreviewed: reviewing them would let the host block *itself*, which is
|
|
222
|
+
a worse failure than a missed block. Set `networkUnattributed: deny` only if
|
|
223
|
+
you know your host's clients ignore the proxy environment.
|
|
224
|
+
|
|
225
|
+
Query the live state at `GET /api/dsh-perm-gate/network` (mode, bind, port,
|
|
226
|
+
proxy liveness, env-injection state, block counters, recent blocks).
|
|
227
|
+
|
|
157
228
|
## The 自动审查 tier (machine value `permissive`)
|
|
158
229
|
|
|
159
230
|
自动审查 is an **independent approval tier** in the DSH permission picker, parallel to
|
|
160
231
|
Read Only / Workspace Write / Full access / Whitelist. It is **not** generic "auto-approval" and
|
|
161
232
|
never mints blanket authority: it only narrows or widens the seam *before* the human/LLM step
|
|
162
|
-
while P0 hard-deny stays monotonic and non-negotiable
|
|
233
|
+
while P0 hard-deny stays monotonic and non-negotiable **within the gate's own scope**.
|
|
234
|
+
|
|
235
|
+
> **P0 is scoped, not global.** The gate acts only while the session's permission preset is one
|
|
236
|
+
> of `gatePresets` (default `permissive` / `permissive-full`). Under any other preset — Read Only,
|
|
237
|
+
> Workspace Write, or Full access — the **entire** gate stands down, P0 hard-deny included,
|
|
238
|
+
> because the selected tier's own policy governs that session. This is deliberate (see
|
|
239
|
+
> `gatePresets` in the configuration table), but it means "P0 is non-negotiable" holds *inside*
|
|
240
|
+
> the gate's tiers rather than across every tier. A stand-down is not silent: the gate records one
|
|
241
|
+
> `stand-down` event per session/preset transition and the browser shows a sticky **GATE OFF**
|
|
242
|
+
> strip above the input. Set `gatePresets: ['*']` to make P0 global again.
|
|
243
|
+
|
|
244
|
+
**Two variants ship**, because a preset's `sandbox` and `approval` are independent knobs and
|
|
245
|
+
coupling them forced a bad trade:
|
|
246
|
+
|
|
247
|
+
| Picker label | Machine value | sandbox | approval |
|
|
248
|
+
|--------------|---------------|---------|----------|
|
|
249
|
+
| 自动审查 | `permissive` | `workspace-write` | `ask` |
|
|
250
|
+
| 自动审查(高权限) | `permissive-full` | `danger-full-access` | `ask` |
|
|
251
|
+
|
|
252
|
+
The plain tier keeps the built-in file sandbox. That sandbox also denies the named pipes a child
|
|
253
|
+
process needs to start, so `git clone`, MSYS2/Cygwin `sh.exe` and ConPTY fail under it with
|
|
254
|
+
`Win32 error 5` / `couldn't create signal pipe`. Because the gate is active **only** in the tiers
|
|
255
|
+
listed in `gatePresets`, wanting the gate meant accepting that restriction. 自动审查(高权限)
|
|
256
|
+
removes the coupling: identical approval behaviour, no file-sandbox restriction. The tier's own
|
|
257
|
+
description states the trade plainly — the workflow is smoother, approvals still apply per call,
|
|
258
|
+
but there is **no system sandbox left as a backstop**. Both are in the
|
|
259
|
+
default `gatePresets`, so either one gives you the full P0–P4 chain — the gate reads the preset
|
|
260
|
+
**name** only, never the sandbox mode.
|
|
163
261
|
|
|
164
262
|
The picker label is a **host-supplied product string**, not a per-locale dictionary entry: DSH
|
|
165
|
-
|
|
263
|
+
renders a plugin tier's `name:` verbatim on both permission surfaces (the General-settings
|
|
166
264
|
default row and the composer picker) and only supplies its own localized labels for the three
|
|
167
|
-
built-in values, so `cordis.patch.yml` ships the Chinese label for every session.
|
|
168
|
-
|
|
265
|
+
built-in values, so `cordis.patch.yml` ships the Chinese label for every session.
|
|
266
|
+
|
|
267
|
+
The **icon** is a different story. The composer's glyph map is closed, and its own comment states
|
|
268
|
+
the rule: *host-configured names outside the design set get none.* `permissive` is a built-in
|
|
269
|
+
value, so 自动审查 already has a shield+eye glyph; `permissive-full` gets the same glyph only
|
|
270
|
+
because `npx dsh-perm-gate-patch-glyph` adds it to that map. That patch edits a **host**
|
|
271
|
+
package, so it is lost on every DSH upgrade — see
|
|
272
|
+
[After a DSH upgrade](./INSTALL.md#after-a-dsh-upgrade-re-apply-the-composer-glyph-patch).
|
|
169
273
|
|
|
170
274
|
In `cordis.yml`:
|
|
171
275
|
|
|
@@ -232,7 +336,13 @@ optionally overridden with `classifierProvider` / `classifierModel`). A **health
|
|
|
232
336
|
|
|
233
337
|
- `safe` → the call is auto-allowed (audited as the `classifier` source); no panel is shown.
|
|
234
338
|
- `risky` + a **hard category** (`deletion`, `credential`, `remote`, `system`, `bulk`) → the call
|
|
235
|
-
|
|
339
|
+
**keeps the human ask**. The classifier **never denies**: the deny path belongs to the
|
|
340
|
+
deterministic layers alone (P0 hard-deny, the deny-keyword blacklist, explicit `deny:` rules), so
|
|
341
|
+
a misgraded category is always negotiable instead of an unappealable block. Hard categories stay
|
|
342
|
+
distinct from `neutral` in one way that matters: they are **never learned**, so repeated
|
|
343
|
+
approvals can never sediment them into an auto-allow.
|
|
344
|
+
(Denying on the model's word was measured live: a benign `git commit -F …` graded `remote`
|
|
345
|
+
produced an auto-deny with no panel and no grant to retry with.)
|
|
236
346
|
- `risky:neutral` → with `riskLearning` enabled (Settings card, off by default), each human
|
|
237
347
|
approval that actually executes (settled via the host's `tools/result` event) counts toward
|
|
238
348
|
a `tool|category` key; once the count reaches `riskThreshold` (default 3) **and** the new
|
|
@@ -265,8 +375,9 @@ channel existed), with `tools/result` settling the same ask as a fallback when t
|
|
|
265
375
|
correlate it. Approvals report the post-approval learning progress (`n`/threshold), and the notice
|
|
266
376
|
strip labels all three terminal states.
|
|
267
377
|
|
|
268
|
-
|
|
269
|
-
built-in
|
|
378
|
+
自动审查 and 自动审查(高权限) both draw the shield+eye glyph in the picker — the first from DSH's
|
|
379
|
+
built-in map, the second from the host patch the installation guide describes. Without that patch
|
|
380
|
+
the second tier is text-only on every surface; its label and its gating are unaffected.
|
|
270
381
|
|
|
271
382
|
### A selectable session tier
|
|
272
383
|
|
|
@@ -278,16 +389,17 @@ built-ins (`read-only` / `workspace-write` / `danger-full-access`, from
|
|
|
278
389
|
session permission picker offers 自动审查 as an independent selectable approval tier, not a
|
|
279
390
|
generic "auto-approval" mode.
|
|
280
391
|
|
|
281
|
-
The gate is active **only in the tiers listed in `gatePresets`** (default
|
|
282
|
-
|
|
283
|
-
`custom` — the gate's decision flow does not run at all:
|
|
284
|
-
hard-deny, no deny-keyword veto, and no audit event. The
|
|
285
|
-
call, which is the point:
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
392
|
+
The gate is active **only in the tiers listed in `gatePresets`** (default
|
|
393
|
+
`['permissive', 'permissive-full']`, the two tiers this plugin adds). In every other tier —
|
|
394
|
+
Read Only, Workspace Write, Full access, `custom` — the gate's decision flow does not run at all:
|
|
395
|
+
no allow, no ask, no deny, no P0 hard-deny, no deny-keyword veto, and no audit event. The
|
|
396
|
+
selected tier's own policy governs the call, which is the point: the built-in
|
|
397
|
+
`danger-full-access` is defined as "full access without approval prompts", so overruling it with
|
|
398
|
+
an ask (unanswerable there — the approval seam rejects before any answerer runs, producing
|
|
399
|
+
`the user rejected tool "..."` with no panel) or with a hard-deny would silently contradict the
|
|
400
|
+
tier the user chose. `gatePresets: ['*']` makes the gate global again (hard-deny included);
|
|
401
|
+
inside an active tier an `ask` is still degraded to passthrough when the session's effective
|
|
402
|
+
approval policy is `never` — which is why both 自动审查 tiers declare `approval: ask`.
|
|
291
403
|
|
|
292
404
|
### Configurable in the UI
|
|
293
405
|
|
|
@@ -297,6 +409,21 @@ The tier is also adjustable at runtime from **Settings → Plugins → 自动审
|
|
|
297
409
|
namespace live, so a change applies to the next tool call without a restart. This is an
|
|
298
410
|
independent approval class, NOT a generic "auto-approval" mode.
|
|
299
411
|
|
|
412
|
+
### Rule test (dry-run)
|
|
413
|
+
|
|
414
|
+
The same page carries a **Rule test** panel: type a tool name and a command, press Test, and the
|
|
415
|
+
gate judges that call against the ruleset it currently has loaded — without running anything and
|
|
416
|
+
without writing any rule. You get the verdict, the matched rule (index and action), the dimensions
|
|
417
|
+
that rule constrains, and the reason.
|
|
418
|
+
|
|
419
|
+
It reports the effective verdict (the whole P0 → P1 → P2 → P3 → P4 chain) *and* the rule layer's own
|
|
420
|
+
answer, which are not the same thing: a P0 hard-deny or a preset deny-keyword fires before the rule
|
|
421
|
+
chain and leaves no rule index behind, so the panel says "no rule matched" rather than naming an
|
|
422
|
+
unrelated rule. A `0 rules loaded` note means the `rulesFile` path resolved to nothing.
|
|
423
|
+
|
|
424
|
+
The panel talks to `POST /api/dsh-perm-gate/dry-run`, which is **read-only by construction** — it
|
|
425
|
+
has no write form at all, so testing a rule can never change it.
|
|
426
|
+
|
|
300
427
|
## CLI
|
|
301
428
|
|
|
302
429
|
Dry-run one call against a rules file (no harness needed):
|
package/README.zh.md
CHANGED
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
> | DSH 版本 | 分支 | 版本号 | npm 标签 |
|
|
26
26
|
> | --- | --- | --- | --- |
|
|
27
27
|
> | 0.1.0-rc.7 ~ 0.1.1-rc.x | `legacy` | `1.x` | `@legacy` |
|
|
28
|
-
> | 0.1.2-alpha.1
|
|
28
|
+
> | 0.1.2-alpha.1 ~ 0.1.5-rc.0 | `main` | `2.x` | `@latest` / `@dsh-0.1.2` (`@2.x` 是范围) |
|
|
29
|
+
> | 0.1.5-rc.1+ | `sync/0.1.5-from-main`(=`compat/0.1.5`) | `3.x` | GitHub ref 安装(暂无 dist-tag) |
|
|
29
30
|
>
|
|
30
31
|
> 版本序列号跟的是 **DSH 线**(`1.x` = DSH ≤ 0.1.1,`2.x` = DSH 0.1.2+),两条大版本互
|
|
31
32
|
> 相隔离:锁在 `^1.x` 的安装绝不会解析到 `2.x`,反之亦然。`engines.dsh` 表达同样的
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
> 线上都是 user-approval 服务的**私有**方法,因此通过 `typeof` 探测读取,缺失
|
|
40
41
|
> 或抛错时降级为「策略未知」。
|
|
41
42
|
|
|
42
|
-
版本 **2.
|
|
43
|
+
版本 **2.6.0** —— 变更见 [Changelog](./CHANGELOG.md)。
|
|
43
44
|
|
|
44
45
|
一个**单一自足、确定性优先、fail-closed** 的 DeepSeek Harness 权限门插件。
|
|
45
46
|
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
- **会话放行** — 精确的 `(工具, 规范化 fingerprint)` grant,带 `TTL` + `maxUses`;换目标绝不复用。子代理继承但不可自授。
|
|
63
64
|
- **纯函数规则引擎** — glob/regex 编译 + ReDoS 上限、坏规则 loud fail、按源内容哈希缓存。
|
|
64
65
|
- **审计** — 每次决策写为 `{ignorable:true}` 事件并带 `callId`;模型可见理由与记录一致。
|
|
65
|
-
- **自动审查档位**(机器值 `permissive`)——一个**独立审批模式**(区别于只读、完全权限与白名单档),既不是"自动审批",也不授予泛化权限。前端只暴露**一个开关**(`permissive`),后台四个审批策略**可组合**、由插件设置决定——仍对 P0 保持 fail-closed
|
|
66
|
+
- **自动审查档位**(机器值 `permissive`)——一个**独立审批模式**(区别于只读、完全权限与白名单档),既不是"自动审批",也不授予泛化权限。前端只暴露**一个开关**(`permissive`),后台四个审批策略**可组合**、由插件设置决定——仍对 P0 保持 fail-closed。权限下拉框与设置行都按产品名「自动审查」显示;图标见下文(内置档自带,插件档需补丁)。
|
|
66
67
|
- **沙箱提权自动答复**(`trustEscalation`)— 沙箱提权是从 shell / pwsh / edit 工具**体内部**(`tools/pre-execute` 之后)发出的,所以门禁从未见过它,一个它自动放行的调用仍会弹出确认。开启后,门禁以 `callId` 精确匹配已放行调用并直接答复。
|
|
67
68
|
|
|
68
69
|
## 安装
|
|
@@ -87,21 +88,103 @@ dsh plugin --profile web add dsh-perm-gate
|
|
|
87
88
|
rulesFile: ./permissions.yaml # 可选;默认 $DSH_HOME/perm-gate/rules.yml
|
|
88
89
|
dshHome: $DSH_HOME
|
|
89
90
|
defaultAction: ask
|
|
90
|
-
gatePresets: [permissive]
|
|
91
|
+
gatePresets: [permissive, permissive-full] # 门禁生效的档位(默认值)
|
|
92
|
+
sessionSweep: true # 每小时清理已归档/已删除会话的门禁数据
|
|
91
93
|
```
|
|
92
94
|
|
|
95
|
+
### 会话清扫(session sweep)
|
|
96
|
+
|
|
97
|
+
插件启动时及每小时读取 DSH 的工作区存储(`$DSH_HOME/storages/workspace.json`,只读),
|
|
98
|
+
对门禁持有授权链数据的每个会话做归类。已被 DSH 归档(`global.archivedSessionIds`)
|
|
99
|
+
或彻底不存在的会话,其决策事件会从 `$DSH_HOME/perm-gate/events.jsonl` 中移除,
|
|
100
|
+
其决策前文件快照会从 `$DSH_HOME/perm-gate/snapshots/` 中删除——宿主已视为消失的数据,
|
|
101
|
+
审查页也不再保留其历史。活跃会话不受影响;无法归属的行(空 sessionId)永不删除;
|
|
102
|
+
任何失败都 fail-open:本轮跳过,一小时后重试。设 `sessionSweep: false` 关闭;
|
|
103
|
+
`workspaceStoreFile` 可覆盖存储路径。恢复归档会话不会找回已被清扫的历史。
|
|
104
|
+
|
|
93
105
|
规则示例:见 [examples/permissions.example.yaml](./examples/permissions.example.yaml)。
|
|
94
106
|
|
|
107
|
+
### 网络策略(可选开启)
|
|
108
|
+
|
|
109
|
+
本地 HTTP/CONNECT 代理,用**同一份规则文件**审查 **shell 子进程**的出站流量,并对无规则
|
|
110
|
+
覆盖的目标提供审批通道。**默认关闭** —— 开启后会绑定回环端口并改写子进程的代理环境变量,
|
|
111
|
+
因此绝不隐式启用。
|
|
112
|
+
|
|
113
|
+
```yaml
|
|
114
|
+
- id: dsh-perm-gate
|
|
115
|
+
config:
|
|
116
|
+
networkEnabled: false # 总开关(默认 false)
|
|
117
|
+
networkMode: whitelist # deny-all | whitelist | allow-all
|
|
118
|
+
networkUnlisted: ask # ask | deny —— 未列出目标的处理方式
|
|
119
|
+
networkUnattributed: allow # allow | deny —— 无 shell 归属的流量
|
|
120
|
+
networkInjectEnv: true # 为子进程改写 HTTP(S)_PROXY / ALL_PROXY
|
|
121
|
+
networkAskTimeoutMs: 120000 # 审批等待上限,超时按拒绝处理
|
|
122
|
+
networkGrantTtlMs: 1800000 # 一次批准的会话有效期
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**分层行为**:没有 allow 规则,任何目标都出不去。未列出的目标会升级到交互审批,挂在该
|
|
126
|
+
shell 命令的会话上;批准后该目标在本次会话内放行。**`deny` 规则永不升级为审批** —— 审批
|
|
127
|
+
只能为「无规则禁止的目标」拓宽可达性,永远不能推翻一条说「不」的规则。
|
|
128
|
+
|
|
129
|
+
**边界 —— 依赖它之前请先读这段**:代理是**协作式**策略层,不是强制边界。它只能看到
|
|
130
|
+
**愿意读代理环境变量**的客户端的流量。
|
|
131
|
+
|
|
132
|
+
| 客户端 | 能拦吗 |
|
|
133
|
+
|--------|--------|
|
|
134
|
+
| `curl`、`wget`、`git`、Go `net/http`、Python `requests` | ✅ |
|
|
135
|
+
| **Node.js `http` / `https` / `fetch`** | ❌ **直连,代理看不到** |
|
|
136
|
+
| Java(未加 `-D` 代理参数)、.NET `HttpClient` | ❌ |
|
|
137
|
+
| 原始 socket、自写 TCP | ❌ |
|
|
138
|
+
| DNS、QUIC/HTTP3、非 HTTP 协议 | ❌ |
|
|
139
|
+
| 连接字面 IP | ❌ |
|
|
140
|
+
|
|
141
|
+
因此 `node -e "require('http').get('http://host/')"` 这类命令**不会被拦截**。请把它当作
|
|
142
|
+
「防误操作的护栏 + 声明意图的地方」,而不是密闭沙箱。
|
|
143
|
+
|
|
144
|
+
DSH **自身**的网络流量 —— 内建网络工具与 LLM 传输 —— 刻意不管:这些连接不带 shell 归属,
|
|
145
|
+
而 `networkUnattributed: allow`(默认)会直接放行。审查它们会导致宿主**把自己拦死**,
|
|
146
|
+
那比漏拦严重得多。只有在你确定宿主的客户端不读代理环境变量时,才考虑改成 `deny`。
|
|
147
|
+
|
|
148
|
+
实时状态查询:`GET /api/dsh-perm-gate/network`(模式 / 绑定 / 端口 / 代理存活 / 环境注入
|
|
149
|
+
状态 / 阻断计数 / 最近阻断)。
|
|
150
|
+
|
|
95
151
|
## 自动审查档位(机器值 `permissive`)
|
|
96
152
|
|
|
97
153
|
自动审查是权限下拉框里一个**独立审批档**,与只读 / 工作区内修改 / 完全权限 / 白名单平行。
|
|
98
154
|
它不是泛化的"自动审批"、也不授予泛化权限:只会在人类/LLM 接缝**之前**收窄或放宽决策,
|
|
99
|
-
P0
|
|
100
|
-
|
|
101
|
-
|
|
155
|
+
P0 硬拒绝在**本门禁自身的档位作用域内**始终单调且不可协商。
|
|
156
|
+
|
|
157
|
+
> **P0 是档位作用域内的,不是全局的。** 门禁只在会话权限档位属于 `gatePresets`
|
|
158
|
+
> (默认 `permissive` / `permissive-full`)时生效。其他档位 —— 只读、工作区内修改、完全权限
|
|
159
|
+
> —— 下**整个门禁停用,包括 P0 硬拒绝**,因为该档位自身的策略接管了这个会话。这是刻意设计
|
|
160
|
+
> (见配置表的 `gatePresets`),但也就意味着「P0 不可协商」成立于**门禁的档位之内**,而非所有档位。
|
|
161
|
+
> 停用**不是静默的**:每次会话档位切换会记录一条 `stand-down` 事件,浏览器在输入框上方常驻一条
|
|
162
|
+
> **GATE OFF** 提示条。把 `gatePresets` 设为 `['*']` 可让 P0 重新变成全局。
|
|
163
|
+
|
|
164
|
+
**提供两个变体** —— 因为预设的 `sandbox` 与 `approval` 是两根**独立**旋钮,把它们绑死会逼出
|
|
165
|
+
一个糟糕的取舍:
|
|
166
|
+
|
|
167
|
+
| 下拉框名称 | 机器值 | sandbox | approval |
|
|
168
|
+
|-----------|--------|---------|----------|
|
|
169
|
+
| 自动审查 | `permissive` | `workspace-write` | `ask` |
|
|
170
|
+
| 自动审查(高权限) | `permissive-full` | `danger-full-access` | `ask` |
|
|
171
|
+
|
|
172
|
+
普通档保留内置文件沙箱。而那个沙箱**同时**拒绝子进程启动所需的命名管道 —— 所以 `git clone`、
|
|
173
|
+
MSYS2/Cygwin 的 `sh.exe`、ConPTY 都会以 `Win32 error 5` / `couldn't create signal pipe` 失败。
|
|
174
|
+
又因为门禁**只在 `gatePresets` 列出的档位里生效**,想用门禁就必须接受这个限制。
|
|
175
|
+
「自动审查(高权限)」解开了这个耦合:**审批行为完全相同,但不限制文件沙箱** —— 档位自带的描述已把代价
|
|
176
|
+
写明:流程更顺畅、审批仍逐次生效,但**不再有系统沙箱兜底**。两者都在默认
|
|
177
|
+
`gatePresets` 里,任选其一都能获得完整的 P0–P4 链路 —— 门禁只读预设的**名字**,从不读 sandbox 模式。
|
|
178
|
+
|
|
179
|
+
下拉框里的名字是**宿主提供的产品名**,不是逐语言的字典项:DSH 对插件档位在**两个**权限界面上
|
|
102
180
|
(通用设置默认档行、输入栏权限选择器)都原样渲染补丁里的 `name:`,只给三个内置档提供自己的本地化
|
|
103
|
-
标签,因此 `cordis.patch.yml`
|
|
104
|
-
|
|
181
|
+
标签,因此 `cordis.patch.yml` 直接写中文名,对所有会话一致。
|
|
182
|
+
|
|
183
|
+
**图标是另一回事。** 输入栏的图标表是闭合的,表自己的注释写明了规则:*host-configured names
|
|
184
|
+
outside the design set get none*。`permissive` 是内置值,所以「自动审查」本来就有盾+眼图标;
|
|
185
|
+
「自动审查(高权限)」能拿到同一个图标,靠的是 `npx dsh-perm-gate-patch-glyph` 往那张表里
|
|
186
|
+
加了一项。该补丁改的是**宿主**包,每次 DSH 升级都会丢 —— 见
|
|
187
|
+
[DSH 升级后:重打输入区图标补丁](./INSTALL.zh.md)。
|
|
105
188
|
|
|
106
189
|
`cordis.yml`:
|
|
107
190
|
|
|
@@ -156,7 +239,8 @@ LLM 评定为 `safe` 且门禁自动放行的调用因此仍会弹出确认。
|
|
|
156
239
|
`@deepseek-ai/dsh-base/cordis.patch.yml`);`test/patch-presets.spec.ts` 固定了这份键集合。因此会话权限
|
|
157
240
|
下拉里会出现「自动审查」这个**独立可选审批档**,而不是"auto-approval"档。
|
|
158
241
|
|
|
159
|
-
门禁**只在 `gatePresets` 列出的档位里生效**(默认 `['permissive']
|
|
242
|
+
门禁**只在 `gatePresets` 列出的档位里生效**(默认 `['permissive', 'permissive-full']`,即本插件新增的
|
|
243
|
+
两个档位)。在其余任何档位
|
|
160
244
|
(Read Only、Workspace Write、Full access、`custom`)里,门禁的判定流程**完全不运行**:不放行、不弹审批、
|
|
161
245
|
不拒绝、不执行 P0 硬拒绝、不做黑名单关键词拦截,也不写审计事件——该档位自己的策略说了算。这正是重点所在:
|
|
162
246
|
`danger-full-access` 的定义就是"全权限、不弹审批",用 ask 去覆盖它毫无意义(该档 `approval: never` 会让审批接缝
|
|
@@ -176,7 +260,8 @@ LLM 评定为 `safe` 且门禁自动放行的调用因此仍会弹出确认。
|
|
|
176
260
|
开启 `llmAssist` 后,接收 LLM(自定义 OpenAI 兼容端点,或 DSH 宿主模型组——见上文)按结构化协议逐条评估 `ask`。**判定发生在门禁的 `tools/pre-execute` 瀑布内部、决策返回宿主之前**:`safe` 直接放行,审批面板根本不会出现;只有真正无法确定的判定才会弹到你面前。
|
|
177
261
|
|
|
178
262
|
- `safe` → 自动放行(审计来源为 `classifier`),不弹面板。
|
|
179
|
-
- `risky` + **硬风险类别**(`deletion`、`credential`、`remote`、`system`、`bulk`)→
|
|
263
|
+
- `risky` + **硬风险类别**(`deletion`、`credential`、`remote`、`system`、`bulk`)→ **维持人工确认(ask)**。分类器**永不拒绝**:拒绝只属于确定性层(P0 硬拒绝、黑名单关键词、显式 `deny:` 规则),所以被误判的类别永远可协商,而不会变成无法申诉的封禁。硬类别与 `neutral` 仅保留一条关键区别:**永不进入学习**,因此反复确认也不可能把它沉淀成自动放行。
|
|
264
|
+
(拿模型的判断当拒绝依据是实测出来的问题:一条无害的 `git commit -F …` 被判 `remote`,直接自动拒绝——没有面板、也没有可重试的授权入口。)
|
|
180
265
|
- `risky:neutral` → 若开启 `riskLearning`(设置卡片内,默认关闭),人工批准且真实执行的 neutral 风险会按 `tool|类别` 计数;计数达到 `riskThreshold`(默认 3)且新调用的操作指纹(命令词 + 目标基名)命中已确认样本时,**同一操作**自动放行。不同目标永不复用该放行。开启学习沉淀(`riskSediment`,默认开)后,满阈值 key 的确认样本会成为**确定性放行规则**:指纹精确命中即直接放行、无需再过 LLM——即使关闭 llmAssist 也继续生效;沉淀规则在设置卡片中可见、可管理(终止学习 / 删除样本)。
|
|
181
266
|
- 超时(`riskTimeoutMs`,默认 20s,重试 1 次)、传输失败与协议外输出均维持原 `ask`——门禁绝不猜测。
|
|
182
267
|
|
|
@@ -191,7 +276,9 @@ LLM 评定为 `safe` 且门禁自动放行的调用因此仍会弹出确认。
|
|
|
191
276
|
调用文本命中任一关键词(大小写不敏感子串)即直接拒绝,且先于白名单 / 授权 / LLM。黑名单在设置
|
|
192
277
|
卡片中按列表查看与增删(预置条目带标签,可一键恢复预置);未设置或为空时应用预置列表——黑名单
|
|
193
278
|
不会静默关闭。
|
|
194
|
-
|
|
279
|
+
「自动审查」与「自动审查(高权限)」在选择器里都画盾+眼图标 —— 前者来自 DSH 内置表,后者来自
|
|
280
|
+
安装指南里描述的那次宿主补丁。没有该补丁时,第二个档位在所有界面上都是纯文字;它的标签与门禁
|
|
281
|
+
不受影响。
|
|
195
282
|
|
|
196
283
|
|
|
197
284
|
## CLI(独立 dry-run)
|