huaweicloud-devkit 2.0.0-next.3 → 2.0.0-next.5
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/README.md +3 -1
- package/package.json +3 -1
- package/plugins/huaweicloud-core/.claude-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.codex-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.hermes-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.mcp.json +55 -1
- package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/dist/agents/codex-config.js +374 -0
- package/plugins/huaweicloud-core/dist/agents/codex-desktop.js +8 -1
- package/plugins/huaweicloud-core/dist/agents/codex.js +9 -0
- package/plugins/huaweicloud-core/dist/agents/opencode-config.js +141 -86
- package/plugins/huaweicloud-core/dist/agents/opencode.js +106 -39
- package/plugins/huaweicloud-core/dist/approval-gate.js +1185 -0
- package/plugins/huaweicloud-core/dist/approval-ledger.js +2331 -0
- package/plugins/huaweicloud-core/dist/approval-roster.js +89 -0
- package/plugins/huaweicloud-core/dist/approval-types.js +1 -0
- package/plugins/huaweicloud-core/dist/approvals-cli.js +4 -4
- package/plugins/huaweicloud-core/dist/data/icons-manifest.v1.json +23 -5
- package/plugins/huaweicloud-core/dist/dep/receipts.js +65 -5
- package/plugins/huaweicloud-core/dist/explain-error.js +9 -1
- package/plugins/huaweicloud-core/dist/hcloud-cli.js +1 -1
- package/plugins/huaweicloud-core/dist/hcloud-plan.js +68 -62
- package/plugins/huaweicloud-core/dist/lib/approval-mode.js +7 -5
- package/plugins/huaweicloud-core/dist/lib/approval-tokens.js +18 -4
- package/plugins/huaweicloud-core/dist/lib/call-trace.js +7 -14
- package/plugins/huaweicloud-core/dist/lib/confirm-language.js +50 -0
- package/plugins/huaweicloud-core/dist/lib/credentials.js +9 -9
- package/plugins/huaweicloud-core/dist/lib/hdkit/hdkit-gate.js +1398 -0
- package/plugins/huaweicloud-core/dist/lib/hdkit/hdkitservice-api.js +371 -32
- package/plugins/huaweicloud-core/dist/lib/hdkit/sandbox-pool.js +6 -16
- package/plugins/huaweicloud-core/dist/lib/opencode-ask-rule.js +224 -78
- package/plugins/huaweicloud-core/dist/lib/opencode-saved-perms.js +282 -0
- package/plugins/huaweicloud-core/dist/lib/supplemental-redaction.js +116 -0
- package/plugins/huaweicloud-core/dist/lib/tool-schema-parts.js +31 -0
- package/plugins/huaweicloud-core/dist/lib/workspace-glob.js +442 -0
- package/plugins/huaweicloud-core/dist/mcp-config-io.js +28 -1
- package/plugins/huaweicloud-core/dist/mcp-protocol.js +68 -16
- package/plugins/huaweicloud-core/dist/mcp-server.js +6933 -1186
- package/plugins/huaweicloud-core/dist/mcp-server.js.map +4 -4
- package/plugins/huaweicloud-core/dist/mcp-stdio-transport.js +14 -4
- package/plugins/huaweicloud-core/dist/packs/auth/approval.js +249 -0
- package/plugins/huaweicloud-core/dist/packs/auth/tools.js +44 -44
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-cli/tools.js +85 -130
- package/plugins/huaweicloud-core/dist/packs/obs/approval.js +110 -0
- package/plugins/huaweicloud-core/dist/packs/obs/tools.js +7 -2
- package/plugins/huaweicloud-core/dist/packs/registry.js +20 -1
- package/plugins/huaweicloud-core/dist/packs/sandbox/approval.js +245 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/expose-task.js +71 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-account.js +180 -23
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-credentials.js +13 -1
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-hwexec.js +136 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-session.js +11 -1
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-tunnel.js +29 -3
- package/plugins/huaweicloud-core/dist/packs/sandbox/schemas.js +93 -9
- package/plugins/huaweicloud-core/dist/packs/sandbox/tools.js +37 -10
- package/plugins/huaweicloud-core/dist/packs/secrets/approval.js +46 -0
- package/plugins/huaweicloud-core/dist/packs/secrets/tools.js +4 -1
- package/plugins/huaweicloud-core/dist/packs/update/approval.js +79 -0
- package/plugins/huaweicloud-core/dist/packs/update/tools.js +8 -1
- package/plugins/huaweicloud-core/dist/packs/voucher/tools.js +1 -1
- package/plugins/huaweicloud-core/dist/packs-configure.js +74 -0
- package/plugins/huaweicloud-core/dist/risk-rule-engine.js +20 -4
- package/plugins/huaweicloud-core/dist/safety/classify-hcloud.js +6 -6
- package/plugins/huaweicloud-core/dist/safety/classify-text.js +36 -0
- package/plugins/huaweicloud-core/dist/safety/policy.js +2 -0
- package/plugins/huaweicloud-core/dist/safety/redact.js +21 -3
- package/plugins/huaweicloud-core/dist/safety/risk-merge.js +24 -4
- package/plugins/huaweicloud-core/dist/sandbox/deploy-check.js +1 -1
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-auth.js +65 -14
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-cleanup.js +422 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-expose-flow.js +66 -16
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-expose.js +13 -10
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-keepalive.js +42 -2
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-key.js +11 -3
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-tunnel.js +6 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-validation.js +10 -1
- package/plugins/huaweicloud-core/dist/sandbox/hwexec-task.js +244 -0
- package/plugins/huaweicloud-core/dist/setup-cli.js +36 -1
- package/plugins/huaweicloud-core/dist/tool-definitions.js +13 -1
- package/plugins/huaweicloud-core/dist/tool-schemas.js +32 -6
- package/plugins/huaweicloud-core/dist/tools.js +76 -9
- package/plugins/huaweicloud-core/dist/update-registry.js +358 -5
- package/plugins/huaweicloud-core/dist/update-upgrade.js +1083 -14
- package/plugins/huaweicloud-core/dist/vendor-gate.js +2 -2
- package/plugins/huaweicloud-core/hooks/huaweicloud-safety.mjs +150 -1
- package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +67 -4
- package/plugins/huaweicloud-core/openclaw.plugin.json +2 -2
- package/plugins/huaweicloud-core/safety/policy.json +18 -11
- package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +115 -11
- package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +198 -143
- package/plugins/huaweicloud-core/skills/huawei-sandbox/references/resource-pool.md +36 -12
- package/plugins/huaweicloud-core/skills/huawei-voucher/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +2 -2
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +11 -7
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/references/approvals.md +74 -29
- package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +21 -19
- package/plugins/huaweicloud-core/src/agents/codex-config.ts +432 -0
- package/plugins/huaweicloud-core/src/agents/codex-desktop.ts +8 -1
- package/plugins/huaweicloud-core/src/agents/codex.ts +10 -0
- package/plugins/huaweicloud-core/src/agents/opencode-config.ts +176 -88
- package/plugins/huaweicloud-core/src/agents/opencode.ts +125 -54
- package/plugins/huaweicloud-core/src/approval-gate.ts +1306 -0
- package/plugins/huaweicloud-core/src/approval-ledger.ts +2446 -0
- package/plugins/huaweicloud-core/src/approval-roster.ts +127 -0
- package/plugins/huaweicloud-core/src/approval-types.ts +237 -0
- package/plugins/huaweicloud-core/src/approvals-cli.ts +4 -4
- package/plugins/huaweicloud-core/src/data/icons-manifest.v1.json +23 -5
- package/plugins/huaweicloud-core/src/dep/receipts.ts +84 -5
- package/plugins/huaweicloud-core/src/explain-error.ts +9 -1
- package/plugins/huaweicloud-core/src/hcloud-cli.ts +3 -0
- package/plugins/huaweicloud-core/src/hcloud-plan.ts +74 -71
- package/plugins/huaweicloud-core/src/lib/approval-mode.ts +7 -5
- package/plugins/huaweicloud-core/src/lib/approval-tokens.ts +19 -4
- package/plugins/huaweicloud-core/src/lib/call-trace.ts +7 -17
- package/plugins/huaweicloud-core/src/lib/confirm-language.ts +51 -0
- package/plugins/huaweicloud-core/src/lib/credentials.ts +9 -8
- package/plugins/huaweicloud-core/src/lib/hdkit/hdkit-gate.ts +1428 -0
- package/plugins/huaweicloud-core/src/lib/hdkit/hdkitservice-api.ts +408 -30
- package/plugins/huaweicloud-core/src/lib/hdkit/sandbox-pool.ts +8 -15
- package/plugins/huaweicloud-core/src/lib/opencode-ask-rule.ts +302 -83
- package/plugins/huaweicloud-core/src/lib/opencode-saved-perms.ts +354 -0
- package/plugins/huaweicloud-core/src/lib/supplemental-redaction.ts +129 -0
- package/plugins/huaweicloud-core/src/lib/tool-schema-parts.ts +40 -0
- package/plugins/huaweicloud-core/src/lib/workspace-glob.ts +414 -0
- package/plugins/huaweicloud-core/src/mcp-config-io.ts +27 -1
- package/plugins/huaweicloud-core/src/mcp-protocol.ts +81 -17
- package/plugins/huaweicloud-core/src/mcp-server.ts +7 -7
- package/plugins/huaweicloud-core/src/mcp-stdio-transport.ts +14 -4
- package/plugins/huaweicloud-core/src/packs/auth/approval.ts +302 -0
- package/plugins/huaweicloud-core/src/packs/auth/tools.ts +54 -45
- package/plugins/huaweicloud-core/src/packs/huaweicloud-cli/tools.ts +99 -137
- package/plugins/huaweicloud-core/src/packs/obs/approval.ts +122 -0
- package/plugins/huaweicloud-core/src/packs/obs/tools.ts +7 -2
- package/plugins/huaweicloud-core/src/packs/registry.ts +43 -1
- package/plugins/huaweicloud-core/src/packs/sandbox/approval.ts +296 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/expose-task.ts +105 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-account.ts +195 -23
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-credentials.ts +11 -1
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-hwexec.ts +228 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-session.ts +11 -1
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-tunnel.ts +41 -14
- package/plugins/huaweicloud-core/src/packs/sandbox/schemas.ts +120 -8
- package/plugins/huaweicloud-core/src/packs/sandbox/tools.ts +42 -9
- package/plugins/huaweicloud-core/src/packs/secrets/approval.ts +50 -0
- package/plugins/huaweicloud-core/src/packs/secrets/tools.ts +4 -1
- package/plugins/huaweicloud-core/src/packs/update/approval.ts +87 -0
- package/plugins/huaweicloud-core/src/packs/update/tools.ts +8 -1
- package/plugins/huaweicloud-core/src/packs/voucher/tools.ts +1 -1
- package/plugins/huaweicloud-core/src/packs-configure.ts +75 -0
- package/plugins/huaweicloud-core/src/risk-rule-engine.ts +20 -7
- package/plugins/huaweicloud-core/src/safety/classify-hcloud.ts +28 -16
- package/plugins/huaweicloud-core/src/safety/classify-text.ts +40 -0
- package/plugins/huaweicloud-core/src/safety/policy.ts +7 -0
- package/plugins/huaweicloud-core/src/safety/redact.ts +24 -6
- package/plugins/huaweicloud-core/src/safety/risk-merge.ts +26 -5
- package/plugins/huaweicloud-core/src/sandbox/deploy-check.ts +1 -1
- package/plugins/huaweicloud-core/src/sandbox/devbridge-auth.ts +74 -14
- package/plugins/huaweicloud-core/src/sandbox/devbridge-cleanup.ts +511 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-expose-flow.ts +70 -18
- package/plugins/huaweicloud-core/src/sandbox/devbridge-expose.ts +26 -10
- package/plugins/huaweicloud-core/src/sandbox/devbridge-keepalive.ts +41 -2
- package/plugins/huaweicloud-core/src/sandbox/devbridge-key.ts +9 -3
- package/plugins/huaweicloud-core/src/sandbox/devbridge-tunnel.ts +24 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-validation.ts +11 -1
- package/plugins/huaweicloud-core/src/sandbox/hwexec-task.ts +304 -0
- package/plugins/huaweicloud-core/src/setup-cli.ts +39 -1
- package/plugins/huaweicloud-core/src/tool-definitions.ts +13 -1
- package/plugins/huaweicloud-core/src/tool-schemas.ts +39 -6
- package/plugins/huaweicloud-core/src/tools.ts +124 -10
- package/plugins/huaweicloud-core/src/update-registry.ts +340 -5
- package/plugins/huaweicloud-core/src/update-upgrade.ts +1130 -14
- package/plugins/huaweicloud-core/src/vendor-gate.ts +2 -2
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
// directly — NOT only behind connect — but every e2e flow reaches them
|
|
25
25
|
// through gated connect or a user-supplied id); the obs faces
|
|
26
26
|
// (setup_obs_config, obs_set_website_config), auth_sync/auth_confirm,
|
|
27
|
-
// sandbox check_user/sign_agreement/credentials/expose_tunnel,
|
|
28
|
-
// voucher_status (account-state probes and writers that no measured
|
|
27
|
+
// sandbox check_user/sign_agreement/credentials/expose_tunnel/shutdown,
|
|
28
|
+
// and voucher_status (account-state probes and writers that no measured
|
|
29
29
|
// vendor-neutral first move has landed on); and the devkit meta tools
|
|
30
30
|
// (check_update, list_skills, ...) the rule exempts.
|
|
31
31
|
export const VENDOR_GATED_TOOLS = new Set([
|
|
@@ -60,6 +60,30 @@ function deny(reason) {
|
|
|
60
60
|
// (The deny() placement above is cosmetic, not semantic: function
|
|
61
61
|
// declarations hoist, so the import could sit anywhere; it reads best here.)
|
|
62
62
|
let classifyTextCommand;
|
|
63
|
+
// The approval-gate roster, imported from the same place the policy came
|
|
64
|
+
// from (compiled dist/ preferred, TypeScript source fallback — the roster
|
|
65
|
+
// is a pure string-array module, so the fallback needs no build). The
|
|
66
|
+
// roster is NOT load-bearing for the classifier: an unresolvable roster
|
|
67
|
+
// falls back to EMPTY, which narrows to trunk behavior — every
|
|
68
|
+
// write/execution deny stands, no exemption fires — so no safety
|
|
69
|
+
// property is lost and the staleness contract keeps holding. Round 9,
|
|
70
|
+
// finding 2: this import used to share the policy's try block, so a
|
|
71
|
+
// dist built before approval-roster.js existed (a stale checkout — dist
|
|
72
|
+
// is gitignored, a pull does not rebuild) threw, the catch denied EVERY
|
|
73
|
+
// Bash payload as "the safety policy failed to load" (wrong cause: the
|
|
74
|
+
// policy loaded fine), and the hook's own staleness contract ("an
|
|
75
|
+
// older dist silently runs the old classifier") inverted into
|
|
76
|
+
// "classifier unavailable". The empty-roster fallback is the fail-closed
|
|
77
|
+
// posture FOR THE EXEMPTION; only a policy load failure fails the
|
|
78
|
+
// classifier.
|
|
79
|
+
//
|
|
80
|
+
// Round 10, finding 3: the roster leaf also carries each member's
|
|
81
|
+
// payload-shape row (APPROVAL_TOOL_INPUT_SHAPES — the run face an args
|
|
82
|
+
// array, PR-3a's exec faces a command string). An older leaf (no such
|
|
83
|
+
// export) degrades to an empty table, and the per-tool fallback below
|
|
84
|
+
// covers the transition.
|
|
85
|
+
let rosterApprovalTools;
|
|
86
|
+
let rosterInputShapes;
|
|
63
87
|
try {
|
|
64
88
|
const policyModule = existsSync(join(__dirname, '..', 'dist', 'safety-policy.js'))
|
|
65
89
|
? await import('../dist/safety-policy.js')
|
|
@@ -78,6 +102,19 @@ try {
|
|
|
78
102
|
);
|
|
79
103
|
process.exit(0);
|
|
80
104
|
}
|
|
105
|
+
try {
|
|
106
|
+
const rosterModule = existsSync(join(__dirname, '..', 'dist', 'approval-roster.js'))
|
|
107
|
+
? await import('../dist/approval-roster.js')
|
|
108
|
+
: await import('../src/approval-roster.ts');
|
|
109
|
+
({ APPROVAL_TOOLS: rosterApprovalTools, APPROVAL_TOOL_INPUT_SHAPES: rosterInputShapes } = rosterModule);
|
|
110
|
+
} catch {
|
|
111
|
+
// A dist predating the roster (stale checkout) or any other resolution
|
|
112
|
+
// failure: run with the empty roster — no exemption fires, every deny
|
|
113
|
+
// stands. Strictly safer than the total block this replaced, and the
|
|
114
|
+
// deny message is not misattributed to the policy.
|
|
115
|
+
rosterApprovalTools = [];
|
|
116
|
+
rosterInputShapes = [];
|
|
117
|
+
}
|
|
81
118
|
|
|
82
119
|
function readStdin() {
|
|
83
120
|
try {
|
|
@@ -87,6 +124,100 @@ function readStdin() {
|
|
|
87
124
|
}
|
|
88
125
|
}
|
|
89
126
|
|
|
127
|
+
// The roster exemption (the approval-chain core PR): a call attributable
|
|
128
|
+
// to the devkit server's roster tool skips ONLY the deny classes the
|
|
129
|
+
// dispatch-layer approval gate owns, and the skip set is
|
|
130
|
+
// payload-shape-scoped (round 10, finding 3):
|
|
131
|
+
// - args-array tools (the hcloud run face): write/execution — the spec
|
|
132
|
+
// binds a token, a human grant, and a pin view before anything
|
|
133
|
+
// executes. The hook's destructive class KEEPS denying for them: an
|
|
134
|
+
// argv payload never carries shell text the server classifies, and
|
|
135
|
+
// the r1/r2 batteries pinned exactly this split.
|
|
136
|
+
// - command-string tools (PR-3a's exec faces): write/execution AND
|
|
137
|
+
// destructive — the command IS the payload, and the server gate's
|
|
138
|
+
// classified flow (token mint → confirm → strict classification,
|
|
139
|
+
// the plan's PR-3a lanes) owns the whole command content; without
|
|
140
|
+
// the destructive skip the plan's own lane-2 command (rm -rf) could
|
|
141
|
+
// never reach the server gate the plan bets on.
|
|
142
|
+
// - structured tools (PR-3a's lifecycle faces, PR-3b's auth pair,
|
|
143
|
+
// PR-3c's registrations): NO exemption, by their shape row's
|
|
144
|
+
// declaration — a present row the hook does not exempt returns no
|
|
145
|
+
// class, and full classification stands, so a stuffed command string
|
|
146
|
+
// or args array on those names can never borrow an exempt class. The
|
|
147
|
+
// auth pair rides the same class: its named credential fields are a
|
|
148
|
+
// no-command-surface payload, and the server gate does not classify
|
|
149
|
+
// that payload text, so the hook's text deny stays as a belt. PR-3c's
|
|
150
|
+
// payloads (obs config, upgrade, secret_delete, packs_configure)
|
|
151
|
+
// classify allow as real text (measured), so their calls reach the
|
|
152
|
+
// server gate with every deny class still armed.
|
|
153
|
+
// Every other deny — credential-file reads, secret reveals, invalid
|
|
154
|
+
// input — stays in force for roster calls too, because the server gate
|
|
155
|
+
// does not replicate them at the hook's breadth (interrogate round 1:
|
|
156
|
+
// the argv classifier never consults credentialFilePatterns).
|
|
157
|
+
//
|
|
158
|
+
// Attribution is shape-scoped (interrogate rounds 1-2) and PER-TOOL
|
|
159
|
+
// (round 10, finding 3): each roster member's payload shape row lives in
|
|
160
|
+
// the roster leaf's APPROVAL_TOOL_INPUT_SHAPES, and a payload is exempt
|
|
161
|
+
// only when it matches ITS tool's row. The run face's row is the args
|
|
162
|
+
// array with none of the other text keys present — a command string
|
|
163
|
+
// riding its name (the round-1/round-2 foreign-suffix smuggle) still
|
|
164
|
+
// fails, whatever server sent it. The exec faces' row (PR-3a's
|
|
165
|
+
// registrations) is the command string their pinned schema actually
|
|
166
|
+
// carries — without a row for them, their real payload shape could never
|
|
167
|
+
// satisfy the test, so PR-3a's registrations could never reach the
|
|
168
|
+
// server gate on hook-bearing harnesses. A roster member with NO row
|
|
169
|
+
// (an older roster leaf, or the transition window while PR-3 lands)
|
|
170
|
+
// admits only the two known devkit payload shapes — and the
|
|
171
|
+
// command-bearing class only on the tool's EXACT name, so a foreign
|
|
172
|
+
// suffixed name cannot reach the command shape through the fallback; a
|
|
173
|
+
// present commandString row matches like any other row (the devkit's
|
|
174
|
+
// own prefixed calls must reach it). The residual is unchanged: a
|
|
175
|
+
// foreign tool that copies both the name and the shape is
|
|
176
|
+
// indistinguishable from the devkit at the hook layer; a hostile MCP
|
|
177
|
+
// server was always outside the hook's trust boundary.
|
|
178
|
+
const TEXT_KEYS_COMMAND_TEXT_READS = ['command', 'cmd', 'script', 'arguments'];
|
|
179
|
+
|
|
180
|
+
function matchesArgsArrayShape(args) {
|
|
181
|
+
return Array.isArray(args.args) && TEXT_KEYS_COMMAND_TEXT_READS.every((key) => args[key] === undefined);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function matchesCommandStringShape(args) {
|
|
185
|
+
return (
|
|
186
|
+
typeof args.command === 'string' &&
|
|
187
|
+
args.args === undefined &&
|
|
188
|
+
TEXT_KEYS_COMMAND_TEXT_READS.every((key) => key === 'command' || args[key] === undefined)
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// The payload-shape class a roster-attributed call matched, or undefined
|
|
193
|
+
// when the call is not exempt: 'argsArray' or 'commandString' (the skip
|
|
194
|
+
// set differs between them, so the caller needs the class, not a
|
|
195
|
+
// boolean).
|
|
196
|
+
function rosterExemptionShape(toolName, toolInput) {
|
|
197
|
+
if (typeof toolName !== 'string' || !Array.isArray(rosterApprovalTools)) return undefined;
|
|
198
|
+
const args = (toolInput ?? {}) || {};
|
|
199
|
+
const exact = rosterApprovalTools.find((tool) => toolName === tool);
|
|
200
|
+
const matched = exact !== undefined ? exact : rosterApprovalTools.find((tool) => toolName.endsWith('_' + tool));
|
|
201
|
+
if (matched === undefined) return undefined;
|
|
202
|
+
const shape = (rosterInputShapes ?? {})[matched];
|
|
203
|
+
if (shape === 'commandString') return matchesCommandStringShape(args) ? 'commandString' : undefined;
|
|
204
|
+
if (shape === 'argsArray') return matchesArgsArrayShape(args) ? 'argsArray' : undefined;
|
|
205
|
+
// A PRESENT row the hook does not exempt ('structured': a payload with
|
|
206
|
+
// no command surface — PR-3a's lifecycle faces, PR-3b's auth pair,
|
|
207
|
+
// PR-3c's registrations) never falls through to the transition fallback
|
|
208
|
+
// — the fallback admits the two devkit shapes on the exact name, so a
|
|
209
|
+
// structured tool with a stuffed `command` string or `args` array must
|
|
210
|
+
// not be able to borrow an exempt class. Full classification stands.
|
|
211
|
+
if (shape !== undefined) return undefined;
|
|
212
|
+
// No shape row (an older roster leaf, or the transition window while
|
|
213
|
+
// PR-3 lands): the two known devkit payload shapes, with the
|
|
214
|
+
// command-bearing class restricted to the exact tool name (a foreign
|
|
215
|
+
// suffixed impostor cannot reach it).
|
|
216
|
+
if (matchesArgsArrayShape(args)) return 'argsArray';
|
|
217
|
+
if (exact !== undefined && matchesCommandStringShape(args)) return 'commandString';
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
|
|
90
221
|
function main() {
|
|
91
222
|
const input = readStdin();
|
|
92
223
|
let data;
|
|
@@ -109,7 +240,25 @@ function main() {
|
|
|
109
240
|
deny(CLASSIFY_FAILED_REASON);
|
|
110
241
|
return;
|
|
111
242
|
}
|
|
112
|
-
if (result.decision
|
|
243
|
+
if (result.decision !== 'deny') return;
|
|
244
|
+
// The exemption skips only the approval-gated classes for attributable
|
|
245
|
+
// roster calls, scoped by the payload's shape class (the skip sets are
|
|
246
|
+
// documented at rosterExemptionShape): args-array payloads skip
|
|
247
|
+
// write/execution, command-string payloads — the exec faces whose
|
|
248
|
+
// whole payload the server gate's classified flow owns — skip
|
|
249
|
+
// write/execution/destructive. Every other deny stands, and nothing is
|
|
250
|
+
// skipped before the classifier has produced a verdict.
|
|
251
|
+
const exemptShape = rosterExemptionShape(data.tool_name, data.tool_input);
|
|
252
|
+
if (exemptShape === 'argsArray' && (result.risk === 'write' || result.risk === 'execution')) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (
|
|
256
|
+
exemptShape === 'commandString' &&
|
|
257
|
+
(result.risk === 'write' || result.risk === 'execution' || result.risk === 'destructive')
|
|
258
|
+
) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
deny(result.reason);
|
|
113
262
|
}
|
|
114
263
|
|
|
115
264
|
main();
|
|
@@ -35,6 +35,8 @@ CONFIG_FILE_RE = None
|
|
|
35
35
|
SECRET_READ_RE = None
|
|
36
36
|
SECRET_CLI_RE = None
|
|
37
37
|
APPROVAL_CLI_RE = None
|
|
38
|
+
ACCOUNT_SWITCH_CLI_RE = None
|
|
39
|
+
GATED_CLI_RE = None
|
|
38
40
|
WRITE_OPERATION_RE = None
|
|
39
41
|
WRITE_VOCAB_RE = None
|
|
40
42
|
READ_OPERATION_RE = None
|
|
@@ -74,7 +76,7 @@ OBS_MARKER_RE = re.compile(r"\bOBS\b", re.I)
|
|
|
74
76
|
|
|
75
77
|
|
|
76
78
|
def load_policy():
|
|
77
|
-
global CONFIG_FILE_RE, SECRET_READ_RE, SECRET_CLI_RE, APPROVAL_CLI_RE, WRITE_OPERATION_RE, WRITE_VOCAB_RE, READ_OPERATION_RE, READ_OPERATION_EXCEPTIONS
|
|
79
|
+
global CONFIG_FILE_RE, SECRET_READ_RE, SECRET_CLI_RE, APPROVAL_CLI_RE, ACCOUNT_SWITCH_CLI_RE, GATED_CLI_RE, WRITE_OPERATION_RE, WRITE_VOCAB_RE, READ_OPERATION_RE, READ_OPERATION_EXCEPTIONS
|
|
78
80
|
try:
|
|
79
81
|
with POLICY_PATH.open("r", encoding="utf-8") as file_obj:
|
|
80
82
|
policy = json.load(file_obj)
|
|
@@ -205,6 +207,33 @@ def load_policy():
|
|
|
205
207
|
# leaves APPROVAL_CLI_RE None instead of aborting the
|
|
206
208
|
# whole policy load.
|
|
207
209
|
APPROVAL_CLI_RE = None
|
|
210
|
+
# The account-switch CLI verbs (interrogate round 1, finding 1): the
|
|
211
|
+
# devkit's own auth init / auth sync write S1, OBS, and the KooCLI
|
|
212
|
+
# profile — the account switch the MCP tools gate behind a human
|
|
213
|
+
# present. Same anchoring doctrine as the approval patterns: a devkit
|
|
214
|
+
# binary spelling is required, so plain text or an hcloud operation
|
|
215
|
+
# never trips, and the read-only auth status stays allowed.
|
|
216
|
+
blocked_switch_cli = policy.get("blockedAccountSwitchCliPatterns", [])
|
|
217
|
+
if isinstance(blocked_switch_cli, list):
|
|
218
|
+
blocked_switch_cli = [p for p in blocked_switch_cli if isinstance(p, str)]
|
|
219
|
+
if blocked_switch_cli:
|
|
220
|
+
try:
|
|
221
|
+
ACCOUNT_SWITCH_CLI_RE = re.compile("|".join(blocked_switch_cli), re.I)
|
|
222
|
+
except re.error:
|
|
223
|
+
ACCOUNT_SWITCH_CLI_RE = None
|
|
224
|
+
# The gated-mutation CLI twins (update/upgrade, secret rm, packs
|
|
225
|
+
# enable/disable/all): the same mutations the MCP approval gate
|
|
226
|
+
# mediates, with no gate on this path. Same degradation posture as
|
|
227
|
+
# the approval family above — a malformed pattern list leaves
|
|
228
|
+
# GATED_CLI_RE None, never aborts the load.
|
|
229
|
+
blocked_gated_cli = policy.get("blockedGatedCliPatterns", [])
|
|
230
|
+
if isinstance(blocked_gated_cli, list):
|
|
231
|
+
blocked_gated_cli = [p for p in blocked_gated_cli if isinstance(p, str)]
|
|
232
|
+
if blocked_gated_cli:
|
|
233
|
+
try:
|
|
234
|
+
GATED_CLI_RE = re.compile("|".join(blocked_gated_cli), re.I)
|
|
235
|
+
except re.error:
|
|
236
|
+
GATED_CLI_RE = None
|
|
208
237
|
except Exception:
|
|
209
238
|
pass
|
|
210
239
|
|
|
@@ -444,11 +473,26 @@ def load_cloud_risk_rules():
|
|
|
444
473
|
catalog = json.load(file_obj)
|
|
445
474
|
return catalog.get("rules", [])
|
|
446
475
|
except Exception:
|
|
447
|
-
|
|
476
|
+
# Unreadable rules are not "no rules": the .mjs twin denies
|
|
477
|
+
# fail-closed on the same condition (hook-node.test.ts pin).
|
|
478
|
+
return None
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
def normalize_rule_text(text):
|
|
482
|
+
# Twin of risk-rule-engine.normalizeRuleText: shell-transcribed commands
|
|
483
|
+
# and nested JSON carry \"key\": spellings the catalog's JSON-shaped
|
|
484
|
+
# rules were not authored against — a backslash between the key and the
|
|
485
|
+
# quote silently defeated the deny rules. Match the raw text AND its
|
|
486
|
+
# quote-unescaped shadow; the displayed reason keeps the raw command.
|
|
487
|
+
return re.sub(r'\\+(["\'])', r"\1", text)
|
|
448
488
|
|
|
449
489
|
|
|
450
490
|
def condition_matches(condition, text):
|
|
451
|
-
|
|
491
|
+
regex = re.compile(condition.get("regex", r"a^"), re.I | re.M | re.S)
|
|
492
|
+
if regex.search(text) is not None:
|
|
493
|
+
return True
|
|
494
|
+
normalized = normalize_rule_text(text)
|
|
495
|
+
return normalized != text and regex.search(normalized) is not None
|
|
452
496
|
|
|
453
497
|
|
|
454
498
|
def rule_matches(rule, text):
|
|
@@ -471,7 +515,13 @@ def rule_matches(rule, text):
|
|
|
471
515
|
|
|
472
516
|
|
|
473
517
|
def first_denied_command_rule(text):
|
|
474
|
-
|
|
518
|
+
rules = load_cloud_risk_rules()
|
|
519
|
+
if rules is None:
|
|
520
|
+
return {
|
|
521
|
+
"message": "the cloud risk rules failed to load; commands are denied fail-closed",
|
|
522
|
+
"remediation": "Reinstall the huaweicloud-devkit plugin.",
|
|
523
|
+
}
|
|
524
|
+
for rule in rules:
|
|
475
525
|
if "command" not in rule.get("stages", []):
|
|
476
526
|
continue
|
|
477
527
|
if rule.get("severity") != "deny":
|
|
@@ -2620,6 +2670,19 @@ def evaluate(tool_name, tool_input):
|
|
|
2620
2670
|
return "printing vault secrets into the agent context is blocked. Use secret exec so the value reaches only the child process environment."
|
|
2621
2671
|
if APPROVAL_CLI_RE and any(APPROVAL_CLI_RE.search(candidate) for candidate in candidates):
|
|
2622
2672
|
return "running the approval CLI from the agent Bash face is blocked: the confirmation must come from the user's own interactive terminal, where the PIN is checked. Ask the user to run the printed npx huaweicloud-devkit approve <token> line themselves (first use: npx huaweicloud-devkit pin, once), then retry the same call."
|
|
2673
|
+
# The account-switch CLI verbs (interrogate round 1, finding 1): the
|
|
2674
|
+
# devkit's own auth init / auth sync write S1, OBS, and the KooCLI
|
|
2675
|
+
# profile — the account switch the MCP tools gate behind a human
|
|
2676
|
+
# present. A devkit binary spelling is required, so plain text or an
|
|
2677
|
+
# hcloud operation never trips, and the read-only auth status stays
|
|
2678
|
+
# allowed.
|
|
2679
|
+
if ACCOUNT_SWITCH_CLI_RE and any(ACCOUNT_SWITCH_CLI_RE.search(candidate) for candidate in candidates):
|
|
2680
|
+
return "running the account-switch CLI from the agent Bash face is blocked: switching the Huawei Cloud account is approval-gated, and the devkit's own confirmation must come from the user's own interactive terminal. Ask the user to run the auth init / auth sync command themselves, or use the gated MCP tools (huaweicloud_auth_init / huaweicloud_auth_switch), which confirm the target account with the user before switching."
|
|
2681
|
+
# The gated-mutation CLI twins (interrogate round 1, finding 1): the
|
|
2682
|
+
# same mutations the MCP approval gate mediates, with no gate on this
|
|
2683
|
+
# path.
|
|
2684
|
+
if GATED_CLI_RE and any(GATED_CLI_RE.search(candidate) for candidate in candidates):
|
|
2685
|
+
return "running the devkit update/upgrade, secret rm, and packs enable/disable CLI verbs from the agent Bash face is blocked: they perform the same mutations the MCP approval gate mediates (huaweicloud_upgrade, huaweicloud_secret_delete, huaweicloud_packs_configure), with no confirmation on this path. Call the MCP tool instead, or let the user run the CLI command in their own terminal."
|
|
2623
2686
|
# Order-independent reveal pair: xargs reorders the argv while every word
|
|
2624
2687
|
# stays literal — a devkit bin plus a `secret get` pair anywhere is a
|
|
2625
2688
|
# reveal regardless of order (both shadow candidates — the decoded one
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"name": "huaweicloud-devkit",
|
|
3
3
|
"id": "huaweicloud-devkit",
|
|
4
4
|
"displayName": "HuaweiCloud DevKit",
|
|
5
|
-
"version": "2.0.0-next.
|
|
5
|
+
"version": "2.0.0-next.5",
|
|
6
6
|
"family": "bundle-plugin",
|
|
7
7
|
"bundleFormat": "codex",
|
|
8
|
-
"description": "Guide coding agents to use Huawei Cloud safely
|
|
8
|
+
"description": "Guide coding agents to use Huawei Cloud safely �?KooCLI, APIs, SDKs, 40 MCP tools, skills, and safety guardrails.",
|
|
9
9
|
"author": {
|
|
10
10
|
"name": "HuaweiCloud Mate",
|
|
11
11
|
"url": "https://github.com/huaweicloud"
|
|
@@ -53,6 +53,22 @@
|
|
|
53
53
|
"setup-cli\\.(js|mjs|ts)(\\s+--)?\\s+pin\\b",
|
|
54
54
|
"setup\\.cjs(\\s+--)?\\s+pin\\b"
|
|
55
55
|
],
|
|
56
|
+
"blockedAccountSwitchCliPatterns": [
|
|
57
|
+
"huaweicloud-devkit(@[\\w.+-]+)?(\\.(js|cjs|mjs|exe|ts))?(\\s+--)?\\s+auth\\s+(init|setup|sync|refresh|reconcile)\\b",
|
|
58
|
+
"setup-cli\\.(js|mjs|ts)(\\s+--)?\\s+auth\\s+(init|setup|sync|refresh|reconcile)\\b",
|
|
59
|
+
"setup\\.cjs(\\s+--)?\\s+auth\\s+(init|setup|sync|refresh|reconcile)\\b"
|
|
60
|
+
],
|
|
61
|
+
"blockedGatedCliPatterns": [
|
|
62
|
+
"huaweicloud-devkit(@[\\w.+-]+)?(\\.(js|cjs|mjs|exe|ts))?(\\s+--)?\\s+(update|upgrade)\\b",
|
|
63
|
+
"setup-cli\\.(js|mjs|ts)(\\s+--)?\\s+(update|upgrade)\\b",
|
|
64
|
+
"setup\\.cjs(\\s+--)?\\s+(update|upgrade)\\b",
|
|
65
|
+
"huaweicloud-devkit(@[\\w.+-]+)?(\\.(js|cjs|mjs|exe|ts))?(\\s+--)?\\s+secret\\s+rm\\b",
|
|
66
|
+
"setup-cli\\.(js|mjs|ts)(\\s+--)?\\s+secret\\s+rm\\b",
|
|
67
|
+
"setup\\.cjs(\\s+--)?\\s+secret\\s+rm\\b",
|
|
68
|
+
"huaweicloud-devkit(@[\\w.+-]+)?(\\.(js|cjs|mjs|exe|ts))?(\\s+--)?\\s+packs\\s+(enable|disable|all)\\b",
|
|
69
|
+
"setup-cli\\.(js|mjs|ts)(\\s+--)?\\s+packs\\s+(enable|disable|all)\\b",
|
|
70
|
+
"setup\\.cjs(\\s+--)?\\s+packs\\s+(enable|disable|all)\\b"
|
|
71
|
+
],
|
|
56
72
|
"writeOperationPrefixes": [
|
|
57
73
|
"Create",
|
|
58
74
|
"BatchCreate",
|
|
@@ -110,19 +126,10 @@
|
|
|
110
126
|
"CheckMigrateLogicDb"
|
|
111
127
|
],
|
|
112
128
|
"safeTextReadCommands": ["rg", "grep", "findstr", "git", "ls", "dir", "Get-ChildItem"],
|
|
113
|
-
"blockedSandboxCommands": [
|
|
114
|
-
"rm\\s+-rf\\s+/",
|
|
115
|
-
"mkfs",
|
|
116
|
-
"dd\\s+if=",
|
|
117
|
-
":\\(\\)\\{:\\|:&\\};:",
|
|
118
|
-
"shutdown",
|
|
119
|
-
"reboot",
|
|
120
|
-
"init\\s+[06]",
|
|
121
|
-
"fdisk"
|
|
122
|
-
],
|
|
123
129
|
"sandboxWriteTools": [
|
|
124
130
|
"huaweicloud_sandbox_connect",
|
|
125
131
|
"huaweicloud_sandbox_credentials",
|
|
126
|
-
"huaweicloud_sandbox_upload_file"
|
|
132
|
+
"huaweicloud_sandbox_upload_file",
|
|
133
|
+
"huaweicloud_sandbox_shutdown"
|
|
127
134
|
]
|
|
128
135
|
}
|
|
@@ -496,7 +496,7 @@
|
|
|
496
496
|
},
|
|
497
497
|
{
|
|
498
498
|
"field": "text",
|
|
499
|
-
"regex": "--(?:[A-Za-z0-9_.-]*[._-])?(?:admin(?:Pass|[_-]pass)|passwd|password|secret(?:[_-]?key
|
|
499
|
+
"regex": "--(?:[A-Za-z0-9_.-]*[._-])?(?:admin(?:Pass|[_-]pass)|passwd|password|secret[_-]?(?:key|text|string|binary)|secret|api[_-]?key|access[_-]?key|token|ak|sk)\\b\\s*[=:]\\s*[^\\s<][^\\s<>\"']"
|
|
500
500
|
}
|
|
501
501
|
]
|
|
502
502
|
},
|
|
@@ -505,7 +505,7 @@
|
|
|
505
505
|
},
|
|
506
506
|
{
|
|
507
507
|
"id": "hwc-sandbox-destructive-command",
|
|
508
|
-
"title": "Destructive command in
|
|
508
|
+
"title": "Destructive command in terminal",
|
|
509
509
|
"category": "destructive",
|
|
510
510
|
"severity": "deny",
|
|
511
511
|
"stages": ["command"],
|
|
@@ -517,36 +517,140 @@
|
|
|
517
517
|
},
|
|
518
518
|
{
|
|
519
519
|
"field": "text",
|
|
520
|
-
"regex": "
|
|
520
|
+
"regex": "dd\\s+if="
|
|
521
521
|
},
|
|
522
522
|
{
|
|
523
523
|
"field": "text",
|
|
524
|
-
"regex": "
|
|
524
|
+
"regex": ":\\s*\\(\\s*\\)\\s*\\{[^}|]{0,64}\\|[^}|&]{0,64}&[^}|]{0,64}\\}[^;]{0,64};\\s*:"
|
|
525
525
|
},
|
|
526
526
|
{
|
|
527
527
|
"field": "text",
|
|
528
|
-
"regex": "
|
|
528
|
+
"regex": "(?:(?:^|[\\n\\r;&|]|\\$\\()\\s*|\\b(?:sudo|doas)\\s+(?:(?:-u|--user|-g|-p|-C|-U|-r|-t|-D)\\s+(?!-)\\S+\\s+|-(?:n|E|v|k|K|i|s|l|A|b|e)\\s+)*)(?:(?:(?:sudo|doas)\\s+(?:(?:-u|--user|-g|-p|-C|-U|-r|-t|-D)\\s+(?!-)\\S+\\s+|-(?:n|E|v|k|K|i|s|l|A|b|e)\\s+)*|nohup\\s+|env\\s+|nice\\s+|stdbuf\\s+|setsid\\s+|ionice\\s+|time\\s+|exec\\s+|command\\s+|busybox\\s+|watch\\s+|xargs(?:\\s+-\\S+)*\\s+|timeout\\s+\\S+\\s+){0,3})(?:/(?:usr/)?s?bin/)?(?:systemctl\\s+(?:--\\w[\\w-]*\\s+){0,2})?(?:shutdown|reboot|halt|poweroff|fdisk)(?![\\w.\\-=])"
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
"field": "text",
|
|
532
|
+
"regex": "(?:(?:^|[\\n\\r;&|]|\\$\\()\\s*|\\b(?:sudo|doas)\\s+(?:(?:-u|--user|-g|-p|-C|-U|-r|-t|-D)\\s+(?!-)\\S+\\s+|-(?:n|E|v|k|K|i|s|l|A|b|e)\\s+)*)(?:(?:(?:sudo|doas)\\s+(?:(?:-u|--user|-g|-p|-C|-U|-r|-t|-D)\\s+(?!-)\\S+\\s+|-(?:n|E|v|k|K|i|s|l|A|b|e)\\s+)*|nohup\\s+|env\\s+|nice\\s+|stdbuf\\s+|setsid\\s+|ionice\\s+|time\\s+|exec\\s+|command\\s+|busybox\\s+|watch\\s+|xargs(?:\\s+-\\S+)*\\s+|timeout\\s+\\S+\\s+){0,3})(?:/(?:usr/)?s?bin/)?(?:tel)?init\\s+[06]\\b"
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
"field": "text",
|
|
536
|
+
"regex": "(?:(?:^|[\\n\\r;&|]|\\$\\()\\s*|\\b(?:sudo|doas)\\s+(?:(?:-u|--user|-g|-p|-C|-U|-r|-t|-D)\\s+(?!-)\\S+\\s+|-(?:n|E|v|k|K|i|s|l|A|b|e)\\s+)*)(?:(?:(?:sudo|doas)\\s+(?:(?:-u|--user|-g|-p|-C|-U|-r|-t|-D)\\s+(?!-)\\S+\\s+|-(?:n|E|v|k|K|i|s|l|A|b|e)\\s+)*|nohup\\s+|env\\s+|nice\\s+|stdbuf\\s+|setsid\\s+|ionice\\s+|time\\s+|exec\\s+|command\\s+|busybox\\s+|watch\\s+|xargs(?:\\s+-\\S+)*\\s+|timeout\\s+\\S+\\s+){0,3})mkfs(?![\\w-])"
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
"field": "text",
|
|
540
|
+
"regex": "\\b(?:ba|da|z|k)?sh(?:\\.exe)?\\b(?:\\s+-{1,2}[\\w-]+(?=\\s)){0,4}\\s+-\\w*c\\b\\s*[\\x22\\u0027\\x60]{0,2}\\s*(?:(?:sudo|doas)\\s+(?:(?:-u|--user|-g|-p|-C|-U|-r|-t|-D)\\s+(?!-)\\S+\\s+|-(?:n|E|v|k|K|i|s|l|A|b|e)\\s+)*)?(?:systemctl\\s+)?(?:(?:shutdown|reboot|halt|poweroff|fdisk)(?![\\w.\\-=])|mkfs(?![\\w-])|init\\s+[06]\\b)"
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
"field": "text",
|
|
544
|
+
"regex": "\\beval\\s+[\\x22\\u0027\\x60]{0,2}\\s*(?:(?:sudo|doas)\\s+(?:(?:-u|--user|-g|-p|-C|-U|-r|-t|-D)\\s+(?!-)\\S+\\s+|-(?:n|E|v|k|K|i|s|l|A|b|e)\\s+)*)?(?:(?:shutdown|reboot|halt|poweroff|fdisk)(?![\\w.\\-=])|mkfs(?![\\w-])|init\\s+[06]\\b)"
|
|
545
|
+
}
|
|
546
|
+
]
|
|
547
|
+
},
|
|
548
|
+
"message": "This terminal command is destructively dangerous (root deletion, disk wipe or format, fork bomb, or system shutdown/reboot) and could destroy the workspace or host.",
|
|
549
|
+
"remediation": "Use targeted deletions instead of recursive root removal, and keep disk format and shutdown/reboot operations out of agent-run terminals; use the approved cloud API path for intentional restarts."
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
"id": "hwc-sandbox-destructive-unanchored-rm",
|
|
553
|
+
"title": "Recursive forced rm against a non-named target",
|
|
554
|
+
"category": "destructive",
|
|
555
|
+
"severity": "deny",
|
|
556
|
+
"stages": ["command"],
|
|
557
|
+
"match": {
|
|
558
|
+
"any": [
|
|
559
|
+
{
|
|
560
|
+
"field": "text",
|
|
561
|
+
"regex": "\\brm\\s+-(?:r[\\w]*f|f[\\w]*r)[\\w]*\\s+\\*(?:\\s|$)"
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
"field": "text",
|
|
565
|
+
"regex": "\\brm\\s+-(?:r[\\w]*f|f[\\w]*r)[\\w]*\\s+\\.(?:/|\\s|$)"
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
"field": "text",
|
|
569
|
+
"regex": "\\brm\\s+-(?:r[\\w]*f|f[\\w]*r)[\\w]*\\s+\\.\\.(?:/|\\s|$)"
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
"field": "text",
|
|
573
|
+
"regex": "\\brm\\s+-(?:r[\\w]*f|f[\\w]*r)[\\w]*\\s+~"
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
"field": "text",
|
|
577
|
+
"regex": "\\brm\\s+-(?:r[\\w]*f|f[\\w]*r)[\\w]*\\s+[\"']?\\$\\{?HOME\\}?[\"']?"
|
|
529
578
|
},
|
|
530
579
|
{
|
|
531
580
|
"field": "text",
|
|
532
|
-
"regex": "\\
|
|
581
|
+
"regex": "\\brm\\s+-(?:r[\\w]*f|f[\\w]*r)[\\w]*\\s+[A-Za-z_][\\w./-]*(?:\\s|$)"
|
|
533
582
|
},
|
|
534
583
|
{
|
|
535
584
|
"field": "text",
|
|
536
|
-
"regex": "
|
|
585
|
+
"regex": "--no-preserve-root"
|
|
537
586
|
},
|
|
538
587
|
{
|
|
539
588
|
"field": "text",
|
|
540
|
-
"regex": "\\
|
|
589
|
+
"regex": "\\brm\\s+(?:--?[\\w-]*\\s+)*-(?:r[\\w]*f|f[\\w]*r)[\\w-]*(?=[\\s;|&)#>]|$)"
|
|
590
|
+
}
|
|
591
|
+
]
|
|
592
|
+
},
|
|
593
|
+
"message": "A recursive forced rm in any combined-flag spelling — rm -rf, -fr, flags interposed or after the target, quoted, glob, $VAR, or dot-prefixed targets, --no-preserve-root.",
|
|
594
|
+
"remediation": "Recursive forced rm is refused in every combined-flag spelling, whatever the target. Delete files by exact name (rm with the file names, no combined -rf/-fr flags), or use targeted deletions; list what will be removed first."
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
"id": "hwc-sandbox-destructive-find-delete",
|
|
598
|
+
"title": "find with -delete",
|
|
599
|
+
"category": "destructive",
|
|
600
|
+
"severity": "deny",
|
|
601
|
+
"stages": ["command"],
|
|
602
|
+
"match": {
|
|
603
|
+
"all": [
|
|
604
|
+
{
|
|
605
|
+
"field": "text",
|
|
606
|
+
"regex": "\\bfind\\b"
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
"field": "text",
|
|
610
|
+
"regex": "-delete\\b"
|
|
611
|
+
}
|
|
612
|
+
]
|
|
613
|
+
},
|
|
614
|
+
"message": "find with -delete walks and removes everything it matches, from whatever start point it is given.",
|
|
615
|
+
"remediation": "Test the match set with -print first; remove files by exact name instead of a find -delete sweep."
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
"id": "hwc-sandbox-pipe-to-xargs-rm",
|
|
619
|
+
"title": "Pipeline sweeping files into rm",
|
|
620
|
+
"category": "destructive",
|
|
621
|
+
"severity": "deny",
|
|
622
|
+
"stages": ["command"],
|
|
623
|
+
"match": {
|
|
624
|
+
"all": [
|
|
625
|
+
{
|
|
626
|
+
"field": "text",
|
|
627
|
+
"regex": "\\|\\s*xargs\\s+rm\\b"
|
|
628
|
+
}
|
|
629
|
+
]
|
|
630
|
+
},
|
|
631
|
+
"message": "A pipeline sweeps its matches into rm through xargs, deleting whatever the left side prints.",
|
|
632
|
+
"remediation": "Print the match set first and remove files by exact name; never pipe a listing straight into rm."
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
"id": "hwc-sandbox-pipe-to-shell",
|
|
636
|
+
"title": "Downloaded content piped straight into a shell",
|
|
637
|
+
"category": "destructive",
|
|
638
|
+
"severity": "deny",
|
|
639
|
+
"stages": ["command"],
|
|
640
|
+
"match": {
|
|
641
|
+
"all": [
|
|
642
|
+
{
|
|
643
|
+
"field": "text",
|
|
644
|
+
"regex": "\\b(?:curl|wget)\\b"
|
|
541
645
|
},
|
|
542
646
|
{
|
|
543
647
|
"field": "text",
|
|
544
|
-
"regex": "\\
|
|
648
|
+
"regex": "\\|\\s*[\"']?(?:sudo\\s+)?(?:ba|z|da)?sh\\b"
|
|
545
649
|
}
|
|
546
650
|
]
|
|
547
651
|
},
|
|
548
|
-
"message": "
|
|
549
|
-
"remediation": "
|
|
652
|
+
"message": "A curl or wget download is piped directly into a shell, executing unreviewed remote content.",
|
|
653
|
+
"remediation": "Download the script first, read it, then run it from the file. Never execute remote content sight-unseen through a pipe."
|
|
550
654
|
}
|
|
551
655
|
]
|
|
552
656
|
}
|