@x-otto/guard 0.1.0-alpha.43 → 0.3.0-beta.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/dist/build-revision.json +4 -0
- package/dist/index.d.ts +116 -419
- package/dist/index.js +4219 -4
- package/package.json +13 -17
- package/README.md +0 -72
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x-otto/guard",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0-beta.0",
|
|
4
|
+
"description": "权限组件:策略引擎 + always-allow + 审计 + settings 同步(guard-rfc)",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
5
8
|
"type": "module",
|
|
6
9
|
"main": "./dist/index.js",
|
|
7
10
|
"types": "./dist/index.d.ts",
|
|
@@ -11,23 +14,16 @@
|
|
|
11
14
|
"import": "./dist/index.js"
|
|
12
15
|
}
|
|
13
16
|
},
|
|
14
|
-
"files": [
|
|
15
|
-
"dist"
|
|
16
|
-
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@x-otto/
|
|
19
|
-
"@x-otto/
|
|
20
|
-
"@x-otto/
|
|
18
|
+
"@x-otto/hooks": "^0.3.0-beta.0",
|
|
19
|
+
"@x-otto/i18n": "^0.3.0-beta.0",
|
|
20
|
+
"@x-otto/kernel": "^0.3.0-beta.0",
|
|
21
|
+
"@x-otto/shared": "^0.3.0-beta.0",
|
|
22
|
+
"@x-otto/shell-lex": "^0.3.0-beta.0",
|
|
23
|
+
"@x-otto/universal": "^0.3.0-beta.0"
|
|
21
24
|
},
|
|
22
25
|
"publishConfig": {
|
|
23
26
|
"access": "public",
|
|
24
|
-
"
|
|
25
|
-
"tag": "alpha"
|
|
26
|
-
},
|
|
27
|
-
"private": false,
|
|
28
|
-
"scripts": {
|
|
29
|
-
"build": "tsdown",
|
|
30
|
-
"typecheck": "tsc --noEmit",
|
|
31
|
-
"test": "vitest run"
|
|
27
|
+
"tag": "beta"
|
|
32
28
|
}
|
|
33
|
-
}
|
|
29
|
+
}
|
package/README.md
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# @x-otto/guard
|
|
2
|
-
|
|
3
|
-
## Module Purpose
|
|
4
|
-
|
|
5
|
-
安全域叶包(RFC-395 从 `@x-otto/hooks` 拆出)。承载三个共享安全/诊断语义的子系统:**权限策略引擎**、**沙箱安全评估**、**失败信号诊断**。单向依赖 `@x-otto/hooks` 引擎核心(权限守卫以 hook 形态接入 `tool.execute.before`)。
|
|
6
|
-
|
|
7
|
-
## Core Features
|
|
8
|
-
|
|
9
|
-
| 子系统 | 模块 | 职责 |
|
|
10
|
-
| --- | --- | --- |
|
|
11
|
-
| 权限 | PermissionPolicyRegistry | 策略注册与评估(deny-wins collect-all:deny > ask > allow) |
|
|
12
|
-
| 权限 | PermissionAuditLog | 权限决策审计(环形缓冲,默认 1000 条) |
|
|
13
|
-
| 权限 | createPermissionGuardHook | 权限 → `tool.execute.before` 拦截器工厂 |
|
|
14
|
-
| 权限 | 内置策略 | file-guard / destructive-command / credential-read / otto-state-domain / egress-allowlist / disabled-tools / 5 种 mode |
|
|
15
|
-
| 权限 | provisionBaselineSecurity | bare-runtime safe-by-default 基线安全供给(幂等) |
|
|
16
|
-
| 沙箱 | assessSandboxSafety | 写路径/网络的三态沙箱评估(auto-allow / ask / deny) |
|
|
17
|
-
| 沙箱 | computeSandboxRoots / defaultDeniedRoots | 可写根与拒绝根计算 |
|
|
18
|
-
| 诊断 | FailureSignalStore | 跨会话失败信号聚合(tool-error / permission-denied) |
|
|
19
|
-
| 诊断 | Diagnoser | 失败信号 → 改进提案 |
|
|
20
|
-
|
|
21
|
-
## Installation
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
pnpm add @x-otto/guard
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Quick Start
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
import { createPermissionRegistry, createPermissionGuardHook } from '@x-otto/guard'
|
|
31
|
-
import { createHookRegistry } from '@x-otto/hooks'
|
|
32
|
-
|
|
33
|
-
const permissions = createPermissionRegistry()
|
|
34
|
-
const hooks = createHookRegistry({ preset: 'none' })
|
|
35
|
-
hooks.register(createPermissionGuardHook(permissions))
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Directory Overview
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
src/
|
|
42
|
-
permission/
|
|
43
|
-
policy-registry.ts # 策略注册 + evaluate(deny-wins)+ compilePolicyFromSetting(ReDoS guard)
|
|
44
|
-
builtin-policies.ts # 内置策略 + 5 mode + 工具集派生
|
|
45
|
-
audit-log.ts # 审计日志
|
|
46
|
-
always-allow.ts # always-allow 条目解析 + bash 前缀覆盖
|
|
47
|
-
command-canonicalize.ts # shell 去混淆器 + 写目标提取
|
|
48
|
-
permission-guard.ts # 权限守卫 hook 工厂
|
|
49
|
-
baseline-provisioning.ts # bare-runtime 基线供给
|
|
50
|
-
register-builtin.ts # 内置策略装载
|
|
51
|
-
risk.ts # 风险等级派生
|
|
52
|
-
protected-paths.ts # 受保护路径正则单源
|
|
53
|
-
types.ts # 权限类型(配置形状 re-export 自 hook-contracts)
|
|
54
|
-
sandbox-safety.ts # 沙箱安全评估(三态矩阵)
|
|
55
|
-
observability/
|
|
56
|
-
failure-signals.ts # 失败信号存储 + 采集 hook
|
|
57
|
-
diagnoser.ts # 诊断提案生成
|
|
58
|
-
index.ts
|
|
59
|
-
tests/ # 8 test files
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Development Commands
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
pnpm --filter @x-otto/guard build
|
|
66
|
-
pnpm --filter @x-otto/guard typecheck
|
|
67
|
-
pnpm --filter @x-otto/guard test
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## Related Packages
|
|
71
|
-
|
|
72
|
-
`@x-otto/hooks`(引擎核心,本包单向依赖它)、`@x-otto/hook-contracts`(权限配置形状类型源)、`@x-otto/shared`
|