@kenhkl/agent-moss 0.12.8 → 0.13.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/agents/__pycache__/__init__.cpython-310.pyc +0 -0
- package/dist/agents/__pycache__/__init__.cpython-311.pyc +0 -0
- package/dist/agents/__pycache__/base.cpython-310.pyc +0 -0
- package/dist/agents/__pycache__/base.cpython-311.pyc +0 -0
- package/dist/cli.js +682 -119
- package/dist/cli.js.map +1 -1
- package/dist/engine/coordinator.js +678 -174
- package/dist/engine/coordinator.js.map +1 -1
- package/dist/rules/mc_rules.json +137 -0
- package/dist/rules/tool_registry.json +25 -0
- package/dist/scenarios/__init__.py +29 -0
- package/dist/scenarios/__pycache__/__init__.cpython-310.pyc +0 -0
- package/dist/scenarios/__pycache__/__init__.cpython-311.pyc +0 -0
- package/dist/scenarios/__pycache__/__init__.cpython-312.pyc +0 -0
- package/dist/server.js +752 -188
- package/dist/server.js.map +1 -1
- package/dist/static/index.html +85 -9
- package/package.json +1 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "L2.2 模型检测规则单一事实源(Python + TS 共用)。原子命题正则 + LTL 公式(前缀 AST)。公式在事件迹位置 0 处评估:LTL 公式满足 = 攻击存在。对应站点 detection-l2-2.html 的 10 条 LTL + 5 条 CTL 规则(CTL 活性降级为 G(!φ) 安全不变量,见 docs/DETECTION_METHODS.md 5.4)。",
|
|
3
|
+
"ap_patterns": {
|
|
4
|
+
"reads_credential": [
|
|
5
|
+
"known_hosts|\\.ssh|id_rsa|\\.pem|/etc/shadow|/etc/passwd|\\.aws/credentials|credentials\\.json|netrc|secrets?\\.ya?ml|credential"
|
|
6
|
+
],
|
|
7
|
+
"network_egress": [
|
|
8
|
+
"https?://|scp\\s+.*@|rsync\\s+.*@|curl\\s+(-X\\s+POST|--data|-F)|wget\\s+--post|base64\\s+.*-o"
|
|
9
|
+
],
|
|
10
|
+
"execute_file": [
|
|
11
|
+
"subprocess|os\\.system|shell\\s*=\\s*True|\\beval\\(|\\bexec\\(|bash\\s+|sh\\s+-c|python\\s+|node\\s+|\\.\\/|chmod\\s+\\+x"
|
|
12
|
+
],
|
|
13
|
+
"write_file": [
|
|
14
|
+
">\\s*/|tee\\s+/-o\\s+|>>\\s*/|mv\\s+.*/|cp\\s+.*/"
|
|
15
|
+
],
|
|
16
|
+
"delete_file": [
|
|
17
|
+
"\\brm\\s+|\\bunlink\\s+|\\brmdir\\s+"
|
|
18
|
+
],
|
|
19
|
+
"disable_security": [
|
|
20
|
+
"iptables\\s+-F|setenforce\\s+0|systemctl\\s+stop\\s+(firewall|apparmor|fail2ban)|ufw\\s+disable"
|
|
21
|
+
],
|
|
22
|
+
"install_persistence": [
|
|
23
|
+
"crontab\\s+-e|echo.*\\|\\s*crontab|systemctl\\s+(enable|start)|/etc/init\\.d|\\.bashrc|\\.profile|at\\s+now|systemd"
|
|
24
|
+
],
|
|
25
|
+
"privilege_escalation": [
|
|
26
|
+
"\\bsudo\\b|\\bsu\\b|chmod\\s+u\\s*\\+\\s*s|setcap|pkexec|doas|setuid"
|
|
27
|
+
],
|
|
28
|
+
"download_file": [
|
|
29
|
+
"curl\\s+.*(-o|--output)\\s+|wget\\s+|git\\s+clone\\s+|docker\\s+pull\\s+|pip\\s+install\\s+"
|
|
30
|
+
],
|
|
31
|
+
"archive_data": [
|
|
32
|
+
"\\btar\\s+|\\bzip\\s+|gzip|base64\\s+|7z\\s+"
|
|
33
|
+
],
|
|
34
|
+
"prompt_injection": [
|
|
35
|
+
"ignore (?:previous|prior|all) (?:instructions?|commands?)|<INFORMATION>|TODO:\\s*(?:send|email|transfer|delete|forward|reserve)"
|
|
36
|
+
],
|
|
37
|
+
"sensitive_data": [
|
|
38
|
+
"api[_-]?token|access[_-]?token|bearer\\s+[a-z0-9._-]+|sk-[a-z0-9_-]+|-----BEGIN [A-Z ]*PRIVATE KEY-----|\\.env(?:\\.[a-z0-9_-]+)?|ssn|credit card|bank account|iban"
|
|
39
|
+
],
|
|
40
|
+
"lateral_movement": [
|
|
41
|
+
"\\bssh\\s+.*@|scp\\s+.*@|rsync\\s+.*@"
|
|
42
|
+
],
|
|
43
|
+
"clear_logs": [
|
|
44
|
+
"history\\s+-c|>/var/log/|journalctl.*--vacuum|logrotate.*-f|shred.*(log|journal)|rm\\s+(-rf|-r)\\s+/var/log/|truncate.*log"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"rules": [
|
|
48
|
+
{
|
|
49
|
+
"id": "mc-ltl-001",
|
|
50
|
+
"type": "ltl",
|
|
51
|
+
"formula": ["F", ["&", ["ap", "reads_credential"], ["F", ["ap", "network_egress"]]]],
|
|
52
|
+
"risk_level": "critical",
|
|
53
|
+
"action": "block",
|
|
54
|
+
"reason": "凭证读取后网络外传(mc-ltl-001)"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": "mc-ltl-002",
|
|
58
|
+
"type": "ltl",
|
|
59
|
+
"formula": ["F", ["&", ["ap", "download_file"], ["F", ["ap", "execute_file"]]]],
|
|
60
|
+
"risk_level": "critical",
|
|
61
|
+
"action": "block",
|
|
62
|
+
"reason": "下载后执行(mc-ltl-002)"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"id": "mc-ltl-003",
|
|
66
|
+
"type": "ltl",
|
|
67
|
+
"formula": ["F", ["&", ["ap", "disable_security"], ["F", ["|", ["ap", "execute_file"], ["|", ["ap", "delete_file"], ["ap", "privilege_escalation"]]]]]],
|
|
68
|
+
"risk_level": "critical",
|
|
69
|
+
"action": "block",
|
|
70
|
+
"reason": "禁用安全后破坏性操作(mc-ltl-003)"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"id": "mc-ltl-004",
|
|
74
|
+
"type": "ltl",
|
|
75
|
+
"formula": ["F", ["&", ["ap", "prompt_injection"], ["F", ["|", ["ap", "network_egress"], ["|", ["ap", "write_file"], ["ap", "execute_file"]]]]]],
|
|
76
|
+
"risk_level": "critical",
|
|
77
|
+
"action": "block",
|
|
78
|
+
"reason": "注入后敏感操作(mc-ltl-004)"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"id": "mc-ltl-005",
|
|
82
|
+
"type": "ltl",
|
|
83
|
+
"formula": ["F", ["&", ["ap", "reads_credential"], ["F", ["ap", "lateral_movement"]]]],
|
|
84
|
+
"risk_level": "critical",
|
|
85
|
+
"action": "block",
|
|
86
|
+
"reason": "凭证读取后横向移动(mc-ltl-005)"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": "mc-ltl-006",
|
|
90
|
+
"type": "ltl",
|
|
91
|
+
"formula": ["F", ["&", ["ap", "sensitive_data"], ["F", ["ap", "clear_logs"]]]],
|
|
92
|
+
"risk_level": "critical",
|
|
93
|
+
"action": "block",
|
|
94
|
+
"reason": "敏感数据访问后清除日志(mc-ltl-006)"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"id": "mc-ltl-007",
|
|
98
|
+
"type": "ltl",
|
|
99
|
+
"formula": ["F", ["&", ["ap", "privilege_escalation"], ["F", ["ap", "install_persistence"]]]],
|
|
100
|
+
"risk_level": "critical",
|
|
101
|
+
"action": "block",
|
|
102
|
+
"reason": "提权后安装持久化(mc-ltl-007)"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"id": "mc-ltl-008",
|
|
106
|
+
"type": "ltl",
|
|
107
|
+
"formula": ["F", ["&", ["ap", "download_file"], ["F", ["ap", "install_persistence"]]]],
|
|
108
|
+
"risk_level": "critical",
|
|
109
|
+
"action": "block",
|
|
110
|
+
"reason": "下载后安装持久化(mc-ltl-008)"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"id": "mc-ltl-009",
|
|
114
|
+
"type": "ltl",
|
|
115
|
+
"formula": ["F", ["&", ["ap", "sensitive_data"], ["F", ["&", ["ap", "archive_data"], ["F", ["ap", "network_egress"]]]]]],
|
|
116
|
+
"risk_level": "critical",
|
|
117
|
+
"action": "block",
|
|
118
|
+
"reason": "敏感数据→归档→外传(mc-ltl-009)"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"id": "mc-ltl-010",
|
|
122
|
+
"type": "ltl",
|
|
123
|
+
"formula": ["F", ["ap", "install_persistence"]],
|
|
124
|
+
"risk_level": "medium",
|
|
125
|
+
"action": "approval",
|
|
126
|
+
"reason": "持久化机制安装,需审批(mc-ltl-010)"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"id": "mc-ctl-001",
|
|
130
|
+
"type": "ltl",
|
|
131
|
+
"formula": ["F", ["ap", "clear_logs"]],
|
|
132
|
+
"risk_level": "critical",
|
|
133
|
+
"action": "block",
|
|
134
|
+
"reason": "安全不变量:任何情况不得清除日志(mc-ctl-001,AG(!clear_logs) 线性迹降级:违反 ⟺ 出现 clear_logs ⟺ F(clear_logs) 成立)"
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Tool Registry — 工具名/命令 → 数据流属性(单一事实源,双端共用)。对齐站点 registry.ts:actionClass(read/write/compute/network_egress/message_egress/unknown)+ requireHighIntegrity(该工具是否要求高完整性输入)。驱动 Rule 5/9/10/11 的按动作类分流 block/observe 与低完整性判定。",
|
|
3
|
+
"tools": {
|
|
4
|
+
"bash": { "actionClass": "compute", "requireHighIntegrity": true },
|
|
5
|
+
"shell": { "actionClass": "compute", "requireHighIntegrity": true },
|
|
6
|
+
"terminal": { "actionClass": "compute", "requireHighIntegrity": true },
|
|
7
|
+
"cmd": { "actionClass": "compute", "requireHighIntegrity": true },
|
|
8
|
+
"python": { "actionClass": "compute", "requireHighIntegrity": true },
|
|
9
|
+
"node": { "actionClass": "compute", "requireHighIntegrity": true },
|
|
10
|
+
"exec": { "actionClass": "compute", "requireHighIntegrity": true },
|
|
11
|
+
"curl": { "actionClass": "network_egress", "requireHighIntegrity": false },
|
|
12
|
+
"wget": { "actionClass": "network_egress", "requireHighIntegrity": false },
|
|
13
|
+
"scp": { "actionClass": "network_egress", "requireHighIntegrity": false },
|
|
14
|
+
"rsync": { "actionClass": "network_egress", "requireHighIntegrity": false },
|
|
15
|
+
"nc": { "actionClass": "network_egress", "requireHighIntegrity": false },
|
|
16
|
+
"file.read": { "actionClass": "read", "requireHighIntegrity": false },
|
|
17
|
+
"file_read": { "actionClass": "read", "requireHighIntegrity": false },
|
|
18
|
+
"read_file": { "actionClass": "read", "requireHighIntegrity": false },
|
|
19
|
+
"cat": { "actionClass": "read", "requireHighIntegrity": false },
|
|
20
|
+
"file.write": { "actionClass": "write", "requireHighIntegrity": false },
|
|
21
|
+
"file_write": { "actionClass": "write", "requireHighIntegrity": false },
|
|
22
|
+
"write_file": { "actionClass": "write", "requireHighIntegrity": false },
|
|
23
|
+
"echo": { "actionClass": "write", "requireHighIntegrity": false }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -109,11 +109,40 @@ def clear_scenario_extensions_cache() -> None:
|
|
|
109
109
|
_cache.clear()
|
|
110
110
|
|
|
111
111
|
|
|
112
|
+
def get_scenario_extensions_multi(scenario_spec: str | None) -> AgentExtensions | None:
|
|
113
|
+
"""按逗号分隔的场景列表加载并合并扩展(AGENT_MOSS_SCENARIO 支持多场景)。
|
|
114
|
+
|
|
115
|
+
引擎层兜底 env 时使用:`AGENT_MOSS_SCENARIO=bank,meow` 会被拆成多个场景 id,
|
|
116
|
+
逐个加载后合并成一个 AgentExtensions(append 语义,与 console 的
|
|
117
|
+
_enabled_scenario_ids 逗号分隔口径一致)。
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
scenario_spec: 逗号分隔的场景 id 字符串(可为空)。
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
合并后的 AgentExtensions,或 None(无任何场景可加载)。
|
|
124
|
+
"""
|
|
125
|
+
if not scenario_spec:
|
|
126
|
+
return None
|
|
127
|
+
ids = [s.strip() for s in scenario_spec.split(",") if s.strip()]
|
|
128
|
+
if not ids:
|
|
129
|
+
return None
|
|
130
|
+
exts = [get_scenario_extensions(sid) for sid in ids]
|
|
131
|
+
non_null = [e for e in exts if e is not None]
|
|
132
|
+
if not non_null:
|
|
133
|
+
return None
|
|
134
|
+
merged: AgentExtensions | None = non_null[0]
|
|
135
|
+
for e in non_null[1:]:
|
|
136
|
+
merged = AgentExtensions.merge(merged, e)
|
|
137
|
+
return merged
|
|
138
|
+
|
|
139
|
+
|
|
112
140
|
__all__ = [
|
|
113
141
|
"AgentExtensions",
|
|
114
142
|
"InjectionKeyword",
|
|
115
143
|
"CommandPattern",
|
|
116
144
|
"SensitivePath",
|
|
117
145
|
"get_scenario_extensions",
|
|
146
|
+
"get_scenario_extensions_multi",
|
|
118
147
|
"clear_scenario_extensions_cache",
|
|
119
148
|
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|