@chenlipingjian-alt/dsh-plugin-guardian 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.en.md +89 -0
- package/README.md +108 -2
- package/cordis.patch.yml +11 -0
- package/icon.svg +13 -0
- package/lib/index.js +2813 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +96 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<!-- Writing guide: playbooks/reference/readme.md. Keep the same sections as README.md. -->
|
|
2
|
+
|
|
3
|
+
# Plugin Guardian
|
|
4
|
+
|
|
5
|
+
[简体中文](README.md) | English
|
|
6
|
+
|
|
7
|
+
[](LICENSE) 
|
|
8
|
+
|
|
9
|
+
One sentence: a plugin buyer plus a security reviewer for DSH — search candidates for a request, audit a pinned commit item by item, install only after approval, then verify what actually landed, with checkable evidence at every step.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Bounded search.** Searches GitHub inside `topic:dsh-plugin` only, returning at most 3 candidates; when the topic has more hits than were returned it sets `truncated: true` instead of presenting a slice as the whole set. Each candidate carries repository full name, description, stars, last push, default branch, HEAD commit SHA and source URL.
|
|
14
|
+
- **A fixed checklist.** Ten items against one pinned commit: provenance and topic-squatting signals, license, maintenance, dependency advisories (live OSV query), install-time scripts quoted verbatim, capabilities (shell/eval/filesystem/credential access), egress destinations, obfuscation and binaries, commit pinnability, DSH engine/bundle compatibility. Every item cites `file:line` or an API URL.
|
|
15
|
+
- **A verdict that gates.** Each audit ends in recommend / caution / reject. Credential reads, unexplained egress, obfuscation or privilege escalation reject the candidate outright, and no later install call can override that.
|
|
16
|
+
- **Install only on approval.** A dry run prints the candidate, commit, audit summary, command and expected changes, and issues a one-time token. The real install needs that token, the same `auditId` and the same commit SHA. Lifecycle scripts are **never** approved: a package that needs `install`/`postinstall` fails instead of running them, with no retry, no elevation and no bypass.
|
|
17
|
+
- **Verification with evidence.** Six post-install checks: dependency integrity, source versus the audited commit, the bundle layer in the composed configuration, live plugin load state, an optional functional smoke call, and the permissions actually granted. Any failure returns `ok: false` with the failing evidence.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
Requires DeepSeek Harness `0.2.1-rc.3`. Host-only bundle; any profile works (verified on `desktop`).
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
dsh plugin --profile desktop add github:local/dsh-plugin-guardian#v0.1.0
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
or from a local checkout:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
dsh plugin --profile desktop add /absolute/path/dsh-plugin-guardian
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Restart DSH afterwards and reload the page.
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
1. State the need in one sentence, e.g. "a plugin that shows a plugin marketplace inside the session".
|
|
38
|
+
2. `guardian_search` returns at most 3 candidates with their HEAD SHA.
|
|
39
|
+
3. `guardian_audit` returns the ten-item table, an `auditId` and an `installSpec` pinned to that commit. A reject verdict ends the chain.
|
|
40
|
+
4. `guardian_install` with `dryRun: true` returns the approval preview and a token; show it to the user.
|
|
41
|
+
5. After the user explicitly approves, install with the same `auditId`, the same commit SHA and that token.
|
|
42
|
+
6. `guardian_verify` checks the result item by item; pass `smokeTool` for an optional functional smoke call with temporary data.
|
|
43
|
+
|
|
44
|
+
## Configuration
|
|
45
|
+
|
|
46
|
+
| Key | Default | Description |
|
|
47
|
+
| --------------- | ------- | ------------------------------------------------------- |
|
|
48
|
+
| `enabled` | `true` | Enable the plugin. |
|
|
49
|
+
| `githubToken` | `""` | Optional GitHub token; falls back to `GITHUB_TOKEN`. |
|
|
50
|
+
| `maxCandidates` | `3` | Candidates per search; the specification caps this at 3. |
|
|
51
|
+
|
|
52
|
+
Defaults live in the packaged `cordis.patch.yml`. Without a token GitHub allows 60 API calls per hour; three candidates cost about four calls.
|
|
53
|
+
|
|
54
|
+
Audits and install records are kept in `$DSH_HOME/guardian/ledger.json` (default `~/.dsh/guardian/ledger.json`), which binds an approval token to one commit and one verdict.
|
|
55
|
+
|
|
56
|
+
## Update, rollback, uninstall
|
|
57
|
+
|
|
58
|
+
Pin the version, then restart DSH:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
dsh plugin --profile desktop add github:local/dsh-plugin-guardian#vX.Y.Z
|
|
62
|
+
dsh plugin --profile desktop remove @chenlipingjian-alt/dsh-plugin-guardian
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Uninstalling leaves no runtime data; delete `~/.dsh/guardian/ledger.json` to clear the audit history.
|
|
66
|
+
|
|
67
|
+
## Privacy and data
|
|
68
|
+
|
|
69
|
+
- No telemetry. Outbound destinations: `api.github.com` (search, metadata, tags), `codeload.github.com` (pinned commit archive for in-memory scanning), `api.osv.dev` (dependency advisories).
|
|
70
|
+
- Archives are decompressed in memory only — never written to disk, never executed; code is matched as text.
|
|
71
|
+
- No access to `~/.ssh`, `~/.aws`, `.npmrc`, `id_rsa` or any secret environment variable (only the optional `GITHUB_TOKEN` for quota).
|
|
72
|
+
- The only local write is `$DSH_HOME/guardian/ledger.json`.
|
|
73
|
+
|
|
74
|
+
## Compatibility
|
|
75
|
+
|
|
76
|
+
See [docs/compatibility.md](docs/compatibility.md). Known limitation: `dsh --profile desktop --dump-config` is refused because the Electron application manages that profile exclusively, so verification uses the live plugin-manager view and says so in the report.
|
|
77
|
+
|
|
78
|
+
## Development
|
|
79
|
+
|
|
80
|
+
See [docs/development.md](docs/development.md) and [CONTRIBUTING.md](CONTRIBUTING.md); AI agents should read [AGENTS.md](AGENTS.md) first.
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
pnpm install
|
|
84
|
+
pnpm verify # typecheck + build + tests + package check
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
[Apache License 2.0](LICENSE)
|
package/README.md
CHANGED
|
@@ -1,3 +1,109 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- 写作规范见 playbooks/reference/readme.md;与 README.en.md 保持相同章节。 -->
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# Plugin Guardian
|
|
4
|
+
|
|
5
|
+
简体中文 | [English](README.en.md)
|
|
6
|
+
|
|
7
|
+
[](LICENSE) 
|
|
8
|
+
|
|
9
|
+
一句话:给 DSH 装上"插件采购员 + 安检员"——按需求搜候选、对固定 commit 逐项排雷、只在批准后安装、装完逐项核验,每一步都给出可核对的证据。
|
|
10
|
+
|
|
11
|
+
## 功能
|
|
12
|
+
|
|
13
|
+
- **搜索有边界**:只在 GitHub `topic:dsh-plugin` 内按关键词搜索,一次最多 3 个候选;命中总数多于返回数时明确标注 `truncated: true`,绝不把切片当成全集。每个候选带 repo 全名、描述、stars、最后 push、默认分支、HEAD commit SHA 与来源 URL。
|
|
14
|
+
- **排查有清单**:对锁定 commit 执行固定的十项检查——来源与可疑抢注、许可证、维护状态、依赖漏洞(OSV 实时查询)、安装期脚本(逐字原文引用)、权限与能力(shell/eval/文件写入/凭证读取)、数据外传域名、代码混淆与二进制、commit 可固定性、DSH 引擎与 bundle 兼容性。每项都给出 `文件:行号` 或 API URL。
|
|
15
|
+
- **判定有闸门**:结论为「推荐 / 谨慎 / 拒绝」。出现凭证读取、可疑外传、混淆代码、提权等红线直接判「拒绝」,此后任何安装调用都会被拒绝。
|
|
16
|
+
- **安装有授权**:先输出安装预览(候选、commit、审计摘要、命令、预计变更)并发放一次性令牌;真正安装必须同时提供该令牌、同一个 `auditId` 与同一个 commit SHA。工具**永不批准**安装期脚本,需要构建脚本的包会失败并保持失败,不重试、不提权、不绕过。
|
|
17
|
+
- **校核有证据**:装完检查六项——依赖完整性、来源与审计 commit 是否一致、配置层是否挂载、插件是否真正激活、可选的功能冒烟、实际权限是否超出声明。任一项失败即 `ok: false`,并给出失败证据。
|
|
18
|
+
|
|
19
|
+
## 安装
|
|
20
|
+
|
|
21
|
+
环境要求:DeepSeek Harness 版本满足 `0.2.1-rc.3`。本插件为 host-only bundle,可在任意 profile 中使用(已在 `desktop` 验证)。
|
|
22
|
+
|
|
23
|
+
### 从 GitHub 安装
|
|
24
|
+
|
|
25
|
+
固定到某个 Release tag:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
dsh plugin --profile desktop add github:local/dsh-plugin-guardian#v0.1.0
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
安装后重启 DSH(桌面版请重启应用),刷新页面。命令会装到你平时使用的 DSH;如果你设置了自己的 `DSH_HOME`,请在同一个环境中运行。
|
|
32
|
+
|
|
33
|
+
### 本地目录安装
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
dsh plugin --profile desktop add /绝对路径/dsh-plugin-guardian
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
从源码安装用于开发调试,见 [docs/development.md](docs/development.md)。
|
|
40
|
+
|
|
41
|
+
## 使用
|
|
42
|
+
|
|
43
|
+
四个工具构成一条链路,按顺序调用即可;也可以只调用其中一步。
|
|
44
|
+
|
|
45
|
+
1. 用一句话说明需求,例如"我想要一个能在会话里显示插件市场的插件"。
|
|
46
|
+
2. Agent 调用 `guardian_search`,得到不超过 3 个候选(带 HEAD SHA)。
|
|
47
|
+
3. Agent 对候选调用 `guardian_audit`,得到十项清单、`auditId` 与锁定的 `installSpec`。
|
|
48
|
+
- 结论「拒绝」→ 到此为止,只报告失败项与证据。
|
|
49
|
+
4. 决定安装时,Agent 先用 `guardian_install` 的 `dryRun: true` 拿到预览与令牌,把候选、commit、审计摘要、命令、预计变更展示给你。
|
|
50
|
+
5. **你明确批准后**,Agent 才用同一个 `auditId`、同一个 commit SHA 和该令牌执行安装。
|
|
51
|
+
6. Agent 调用 `guardian_verify` 逐项校核;提供 `smokeTool` 时可再做一次功能冒烟(请给临时数据)。
|
|
52
|
+
|
|
53
|
+
## 配置
|
|
54
|
+
|
|
55
|
+
| 键 | 默认值 | 说明 |
|
|
56
|
+
| --------------- | ------ | -------------------------------------------------------- |
|
|
57
|
+
| `enabled` | `true` | 启用插件。 |
|
|
58
|
+
| `githubToken` | `""` | 可选 GitHub token;留空则读取环境变量 `GITHUB_TOKEN`。 |
|
|
59
|
+
| `maxCandidates` | `3` | 单次搜索返回的候选上限,规范上限为 3。 |
|
|
60
|
+
| `downloadTimeoutSeconds` | `120` | 固定 commit 归档的下载期限;超时即标 `download_truncated` + `audit_incomplete`,不给通过结论。 |
|
|
61
|
+
| `installSource` | `github` | 审计时假定的安装来源:`github`(源码直装)或 `npm`(发布包)。决定 `prepare` 是否算安装期脚本。 |
|
|
62
|
+
|
|
63
|
+
归档下载器尊重 `HTTPS_PROXY` / `HTTP_PROXY`(含 `https_proxy` / `http_proxy` 小写形式,支持 `user:pass@`),因为 Node 的全局 `fetch` 不读这些变量;GitHub API 与 OSV 仍走 `fetch`。
|
|
64
|
+
|
|
65
|
+
配置保存在 profile 的 `cordis.patch.yml`(bundle 默认值在安装包的 `cordis.patch.yml` 中)。`githubToken` 以明文保存在该文件里;未认证时 GitHub 每小时仅 60 次 API 调用,搜索 3 个候选约用 4 次。
|
|
66
|
+
|
|
67
|
+
审计与安装记录写入 `$DSH_HOME/guardian/ledger.json`(默认 `~/.dsh/guardian/ledger.json`),用于把审批令牌绑定到"某个 commit + 某次判定"。
|
|
68
|
+
|
|
69
|
+
## 更新、回滚与卸载
|
|
70
|
+
|
|
71
|
+
版本变更与升级说明见 [更新日志](https://github.com/chenlipingjian-alt/dsh-plugin-guardian/releases)。
|
|
72
|
+
|
|
73
|
+
更新或回滚时请写明版本号,然后重启 DSH(新版本发布后 24 小时内,不带版本号的安装命令可能仍会装到旧版本):
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
dsh plugin --profile desktop add github:local/dsh-plugin-guardian#vX.Y.Z
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
卸载:
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
dsh plugin --profile desktop remove @chenlipingjian-alt/dsh-plugin-guardian
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
卸载后不留下任何运行时数据;如需清除审计记录,可手动删除 `~/.dsh/guardian/ledger.json`。
|
|
86
|
+
|
|
87
|
+
## 隐私与数据
|
|
88
|
+
|
|
89
|
+
- 本插件不出站任何遥测。联网目的地只有:`api.github.com`(搜索、仓库元数据、tags)、`codeload.github.com`(下载锁定 commit 的归档用于内存扫描)、`api.osv.dev`(依赖漏洞查询)。
|
|
90
|
+
- 审计时归档只解压到内存,不落盘、不执行;代码只做文本匹配。
|
|
91
|
+
- 不读取 `~/.ssh`、`~/.aws`、`.npmrc`、`id_rsa` 等凭证文件,也不读取任何密钥型环境变量(只有可选的 `GITHUB_TOKEN` 用于提高 API 配额)。
|
|
92
|
+
- 本地写入只有 `$DSH_HOME/guardian/ledger.json`。
|
|
93
|
+
|
|
94
|
+
## 兼容性
|
|
95
|
+
|
|
96
|
+
见 [docs/compatibility.md](docs/compatibility.md)。已知限制:`dsh --profile desktop --dump-config` 因 profile 由 Electron 应用独占管理而不可用,校核改用运行中的 plugin manager 视图,并在报告中注明。
|
|
97
|
+
|
|
98
|
+
## 开发
|
|
99
|
+
|
|
100
|
+
见 [docs/development.md](docs/development.md) 与 [CONTRIBUTING.md](CONTRIBUTING.md)。使用 AI agent 开发、发布或维护时,让它先读 [AGENTS.md](AGENTS.md)。
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
pnpm install
|
|
104
|
+
pnpm verify # typecheck + build + tests + package check
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 许可证
|
|
108
|
+
|
|
109
|
+
[Apache License 2.0](LICENSE)
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Host activation for the DSH bundle. Defaults live here so a fresh install
|
|
2
|
+
# behaves the same as the schema defaults; users may override them in settings.
|
|
3
|
+
- insert:
|
|
4
|
+
- id: '@chenlipingjian-alt/dsh-plugin-guardian'
|
|
5
|
+
name: '@chenlipingjian-alt/dsh-plugin-guardian'
|
|
6
|
+
config:
|
|
7
|
+
enabled: true
|
|
8
|
+
githubToken: ''
|
|
9
|
+
maxCandidates: 3
|
|
10
|
+
downloadTimeoutSeconds: 120
|
|
11
|
+
installSource: github
|
package/icon.svg
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" role="img" aria-label="Plugin Guardian">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="guardian-shield" x1="16" y1="8" x2="112" y2="120" gradientUnits="userSpaceOnUse">
|
|
4
|
+
<stop stop-color="#1D4ED8"/>
|
|
5
|
+
<stop offset="1" stop-color="#0B1220"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
<rect x="4" y="4" width="120" height="120" rx="30" fill="url(#guardian-shield)"/>
|
|
9
|
+
<path d="M64 20 102 34v30c0 22-15 36-38 44-23-8-38-22-38-44V34Z" fill="#FFFFFF" fill-opacity="0.14" stroke="#FFFFFF" stroke-width="5" stroke-linejoin="round"/>
|
|
10
|
+
<path d="M46 66l13 13 25-27" fill="none" stroke="#FFFFFF" stroke-width="9" stroke-linecap="round" stroke-linejoin="round"/>
|
|
11
|
+
<circle cx="93" cy="91" r="13" fill="#22C55E" stroke="#0B1220" stroke-width="4"/>
|
|
12
|
+
<path d="M87 91l4 4 8-9" fill="none" stroke="#0B1220" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
13
|
+
</svg>
|