dsh-vigil 0.0.1
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 +201 -0
- package/README.md +188 -0
- package/client.js +4652 -0
- package/cordis.patch.yml +7 -0
- package/docs/DETAIL.md +66 -0
- package/icon.png +0 -0
- package/illustrations/notice.png +0 -0
- package/illustrations/warning.png +0 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +75 -0
- package/rules/audit.yaml +130 -0
- package/rules/manifest.json +7 -0
- package/rules/sentinel.yaml +289 -0
- package/src/alert-route.js +194 -0
- package/src/approval.js +398 -0
- package/src/artwork-route.js +87 -0
- package/src/audit/ast.js +213 -0
- package/src/audit/install-scan.js +127 -0
- package/src/audit/lexer.js +307 -0
- package/src/audit/narrative.js +320 -0
- package/src/audit/rules.js +1440 -0
- package/src/audit/scan.js +880 -0
- package/src/audit-clear-route.js +89 -0
- package/src/audit-feed.js +265 -0
- package/src/audit-log.js +887 -0
- package/src/config-schema.js +194 -0
- package/src/config.js +580 -0
- package/src/delete/command-kinds.js +46 -0
- package/src/delete/lex.js +46 -0
- package/src/delete/parser-posix.js +1427 -0
- package/src/delete/parser-pwsh.js +1729 -0
- package/src/delete/parser.js +2082 -0
- package/src/delete/policy.js +680 -0
- package/src/delete/quarantine.js +417 -0
- package/src/index.js +1134 -0
- package/src/install-scan-route.js +58 -0
- package/src/install-watch.js +389 -0
- package/src/integrity.js +509 -0
- package/src/live-config.js +88 -0
- package/src/quarantine-route.js +74 -0
- package/src/quarantine-view.js +44 -0
- package/src/rules/pack.js +423 -0
- package/src/rules/update.js +341 -0
- package/src/rules/yaml.js +186 -0
- package/src/sage-action-route.js +63 -0
- package/src/sage-provision.js +716 -0
- package/src/sentinel/guard.js +392 -0
- package/src/sentinel/hook.js +546 -0
- package/src/sentinel/rules.js +488 -0
- package/src/sentinel/sage-load.js +79 -0
- package/src/sentinel/sage.js +550 -0
- package/src/tools.js +727 -0
- package/src/update-check.js +339 -0
- package/src/util.js +400 -0
- package/threats/README.md +25 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin's declarative Config schema, projected by the Harness Settings
|
|
3
|
+
* service.
|
|
4
|
+
*
|
|
5
|
+
* Every leaf is `.volatile()` on purpose:
|
|
6
|
+
* - only volatile fields appear in Settings and may be written through
|
|
7
|
+
* `settings.update()` (the service rejects ordinary fields — see
|
|
8
|
+
* `@deepseek-ai/dsh-settings`), and
|
|
9
|
+
* - a saved value updates the running plugin in place instead of restarting
|
|
10
|
+
* the whole bundle, so the 守夜人 page applies changes without a reload.
|
|
11
|
+
*
|
|
12
|
+
* The schema mirrors `DEFAULT_CONFIG` so a fresh install already has complete
|
|
13
|
+
* effective values. Non-UI fields stay in the schema too: the profile patch may
|
|
14
|
+
* still set them by hand, and the form's merge write must not delete them.
|
|
15
|
+
*
|
|
16
|
+
* `@deepseek-ai/schemastery` is the one runtime dependency (a DSH package). It is
|
|
17
|
+
* loaded dynamically so a checkout that was installed without running
|
|
18
|
+
* `npm install` still activates the guard chain: the Host then reports no Config
|
|
19
|
+
* schema, the Settings page shows its "missing" state, and the README explains
|
|
20
|
+
* the one-time install. A schema-less Host plugin is still a working plugin.
|
|
21
|
+
*
|
|
22
|
+
/**
|
|
23
|
+
* @module dsh-vigil/config-schema
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { DEFAULT_CONFIG } from './config.js'
|
|
27
|
+
|
|
28
|
+
/** @type {any} */
|
|
29
|
+
let z = null
|
|
30
|
+
try {
|
|
31
|
+
z = (await import('@deepseek-ai/schemastery')).default
|
|
32
|
+
} catch {
|
|
33
|
+
z = null
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Whether the schema dependency resolved in this installation. */
|
|
37
|
+
export const SCHEMA_AVAILABLE = z !== null
|
|
38
|
+
|
|
39
|
+
/** @param {any} schema schemastery root */
|
|
40
|
+
function buildSchema(schema) {
|
|
41
|
+
/** Decision kind for one rule; validated again at runtime by resolveConfig. */
|
|
42
|
+
const decision = fallback => schema.string().default(fallback)
|
|
43
|
+
/** Boolean switch with a default. */
|
|
44
|
+
const flag = fallback => schema.boolean().default(fallback)
|
|
45
|
+
/** Non-negative integer with a default. */
|
|
46
|
+
const count = fallback => schema.number().default(fallback)
|
|
47
|
+
/** Plain string with a default. */
|
|
48
|
+
const text = fallback => schema.string().default(fallback)
|
|
49
|
+
/** String list with a default. */
|
|
50
|
+
const list = fallback => schema.array(schema.string()).default(fallback)
|
|
51
|
+
|
|
52
|
+
/** Delete-guard thresholds. */
|
|
53
|
+
const thresholds = () => schema.object({
|
|
54
|
+
maxFiles: count(1000).volatile().description('单次/会话预计删除文件数阈值'),
|
|
55
|
+
maxBytes: count(314572800).volatile().description('单次/会话预计删除字节阈值'),
|
|
56
|
+
perCallMaxFiles: count(20000).volatile().description('单次计量最多枚举的条目数'),
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
/** Runtime sentinel switches. */
|
|
60
|
+
const sentinel = () => schema.object({
|
|
61
|
+
enabled: flag(true).volatile().description('是否挂载运行时哨兵'),
|
|
62
|
+
credentialReads: decision('ask').volatile().description('触达凭证材料时的决策'),
|
|
63
|
+
credentialExfil: decision('deny').volatile().description('同时读凭证并外发时的决策'),
|
|
64
|
+
suspiciousHosts: list(DEFAULT_CONFIG.sentinel.suspiciousHosts).volatile(),
|
|
65
|
+
postToUnknownHost: decision('ask').volatile().description('向非白名单主机上传数据'),
|
|
66
|
+
downloadToUnknownHost: decision('allow').volatile().description('从非白名单主机下载'),
|
|
67
|
+
allowedHosts: list([]).volatile(),
|
|
68
|
+
dynamicRemoteCode: decision('deny').volatile().description('下载并立即执行的远程代码:deny 拒绝 / ask 询问 / allow 放行'),
|
|
69
|
+
encodedCommand: decision('ask').volatile().description('编码/混淆命令的决策'),
|
|
70
|
+
configTamper: decision('deny').volatile().description('修改 dsh 配置/沙箱/审批的决策'),
|
|
71
|
+
persistenceWrites: decision('ask').volatile().description('写入持久化位置的决策'),
|
|
72
|
+
dshPluginInstall: decision('ask').volatile().description('通过工具安装/移除插件的决策'),
|
|
73
|
+
destructiveSystem: decision('deny').volatile().description('不可逆的系统破坏性操作(格盘/注册表/卷影/事件日志/安全防护关闭/证书等)'),
|
|
74
|
+
destructiveData: decision('ask').volatile().description('大规模数据破坏操作(数据库/容器/云资源/Git 历史等)'),
|
|
75
|
+
allowTools: list([]).volatile(),
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
/** Deletion guard switches and protected roots. */
|
|
79
|
+
const deleteGuard = () => schema.object({
|
|
80
|
+
enabled: flag(true).volatile().description('是否启用删除防护'),
|
|
81
|
+
recursive: decision('ask').volatile().description('递归删除的决策'),
|
|
82
|
+
wildcard: decision('ask').volatile().description('通配符目标的决策'),
|
|
83
|
+
unknownTarget: decision('ask').volatile().description('无法解析目标时的决策'),
|
|
84
|
+
critical: decision('deny').volatile().description('关键保护根的决策(不允许 allow)'),
|
|
85
|
+
high: decision('ask').volatile().description('高风险根的决策'),
|
|
86
|
+
medium: decision('allow').volatile().description('高频大目录的决策'),
|
|
87
|
+
thresholds: thresholds(),
|
|
88
|
+
extraCriticalRoots: list([]).volatile(),
|
|
89
|
+
extraHighRoots: list([]).volatile(),
|
|
90
|
+
includeProjectRootAsHigh: flag(true).volatile(),
|
|
91
|
+
projectRoot: text('').volatile().description('相对删除目标与项目根保护使用的工作区目录(留空自动判断)'),
|
|
92
|
+
observeScale: flag(true).volatile().description('累计会话删除规模'),
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
/** Optional Sage engine adapter settings. */
|
|
96
|
+
const sage = () => schema.object({
|
|
97
|
+
enabled: flag(false).volatile(),
|
|
98
|
+
autoUpdate: flag(true).volatile(),
|
|
99
|
+
updateIntervalMs: count(86400000).volatile(),
|
|
100
|
+
required: flag(false).volatile(),
|
|
101
|
+
modulePath: text('').volatile(),
|
|
102
|
+
threatsDir: text('').volatile(),
|
|
103
|
+
trustedDomainsDir: text('').volatile(),
|
|
104
|
+
sensitivity: text('balanced').volatile(),
|
|
105
|
+
timeoutMs: count(2000).volatile(),
|
|
106
|
+
disableNetworkChecks: flag(true).volatile(),
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
/** Static audit tuning (AST level). */
|
|
110
|
+
const scan = () => schema.object({
|
|
111
|
+
ast: schema.object({
|
|
112
|
+
enabled: flag(true).volatile(),
|
|
113
|
+
level: text('medium').volatile().description('low/medium/high → notice/review/blocker'),
|
|
114
|
+
}),
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
/** Quarantine store settings. */
|
|
118
|
+
const quarantine = () => schema.object({
|
|
119
|
+
enabled: flag(true).volatile(),
|
|
120
|
+
dir: text('').volatile(),
|
|
121
|
+
ttlDays: count(7).volatile(),
|
|
122
|
+
maxEntries: count(5000).volatile(),
|
|
123
|
+
metadataFile: text('manifest.json').volatile(),
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
/** Self-integrity settings. */
|
|
127
|
+
const integrity = () => schema.object({
|
|
128
|
+
enabled: flag(true).volatile(),
|
|
129
|
+
baseline: flag(true).volatile(),
|
|
130
|
+
canary: flag(true).volatile(),
|
|
131
|
+
intervalMs: count(1800000).volatile(),
|
|
132
|
+
signatureEnabled: flag(false).volatile(),
|
|
133
|
+
publicKeyPem: text('').volatile(),
|
|
134
|
+
signatureFile: text('').volatile(),
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
/** Hash-chained audit log settings. */
|
|
138
|
+
const auditLog = () => schema.object({
|
|
139
|
+
enabled: flag(true).volatile(),
|
|
140
|
+
dir: text('').volatile(),
|
|
141
|
+
maxBytes: count(8388608).volatile(),
|
|
142
|
+
maxFiles: count(5).volatile(),
|
|
143
|
+
logArguments: flag(true).volatile(),
|
|
144
|
+
argumentChars: count(300).volatile(),
|
|
145
|
+
anchor: schema.object({
|
|
146
|
+
enabled: flag(false).volatile().description('用环境变量中的密钥对链头做 HMAC 锚定'),
|
|
147
|
+
keyEnv: text('DSH_VIGIL_ANCHOR_KEY').volatile(),
|
|
148
|
+
everyN: count(100).volatile(),
|
|
149
|
+
}),
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
return schema.object({
|
|
153
|
+
mode: text('enforce').volatile().description('enforce 执行拦截,monitor 只记录'),
|
|
154
|
+
locale: text('auto').volatile().description('卡片语言:auto/en/zh'),
|
|
155
|
+
allowSelfUninstall: flag(false).volatile().description('是否允许代理卸载/替换本插件'),
|
|
156
|
+
killSwitch: schema.object({
|
|
157
|
+
enabled: flag(true).volatile(),
|
|
158
|
+
path: text('').volatile(),
|
|
159
|
+
envVar: text('DSH_VIGIL_DISABLED').volatile(),
|
|
160
|
+
}),
|
|
161
|
+
sentinel: sentinel(),
|
|
162
|
+
deleteGuard: deleteGuard(),
|
|
163
|
+
sage: sage(),
|
|
164
|
+
quarantine: quarantine(),
|
|
165
|
+
integrity: integrity(),
|
|
166
|
+
auditLog: auditLog(),
|
|
167
|
+
tools: schema.object({
|
|
168
|
+
enabled: flag(true).volatile(),
|
|
169
|
+
}),
|
|
170
|
+
scan: scan(),
|
|
171
|
+
rules: schema.object({
|
|
172
|
+
dir: text('').volatile().description('外部规则包目录(YAML);留空使用 <DSH_HOME>/vigil/rules'),
|
|
173
|
+
source: text('https://raw.githubusercontent.com/DusklitSakura/dsh-vigil/main/rules/manifest.json').volatile().description('规则库更新清单 URL(HTTPS JSON);设置页可选 GitHub / jsDelivr / 关闭 / 自定义;空字符串表示关闭远程检测'),
|
|
174
|
+
autoUpdate: flag(false).volatile().description('按间隔自动检测并安装规则库更新'),
|
|
175
|
+
updateIntervalMs: count(21600000).volatile().description('自动更新检测间隔(毫秒)'),
|
|
176
|
+
}),
|
|
177
|
+
selfProtection: text('deny').volatile().description('删除、写入/编辑、卸载/停用/替换插件自身或状态目录时的决策:deny 或 ask'),
|
|
178
|
+
notify: schema.object({
|
|
179
|
+
enabled: flag(true).volatile(),
|
|
180
|
+
includeAsk: flag(true).volatile(),
|
|
181
|
+
inlineApproval: flag(true).volatile(),
|
|
182
|
+
approvalTimeoutMs: count(120000).volatile().description('对话内审批等待上限(毫秒)'),
|
|
183
|
+
alert: schema.object({
|
|
184
|
+
enabled: flag(true).volatile().description('未聚焦时提醒有待审批的请求'),
|
|
185
|
+
sound: flag(true).volatile().description('播放提示音'),
|
|
186
|
+
windowsNotification: flag(true).volatile().description('发送 Windows 通知中心通知'),
|
|
187
|
+
raiseWindow: flag(true).volatile().description('把 DSH 窗口带到前台并临时置顶'),
|
|
188
|
+
}),
|
|
189
|
+
}),
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Host plugin Config; `undefined` when the schema dependency is unavailable. */
|
|
194
|
+
export const Config = SCHEMA_AVAILABLE ? buildSchema(z) : undefined
|