huaweicloud-devkit 1.0.2-next.7 → 1.0.2-next.8

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.
Files changed (91) hide show
  1. package/.agents/plugins/marketplace.json +18 -18
  2. package/LICENSE +201 -201
  3. package/README.md +16 -1
  4. package/README.zh-CN.md +16 -1
  5. package/bin/setup.cjs +5 -3
  6. package/integrations/opencode/opencode.json +1 -4
  7. package/package.json +15 -3
  8. package/plugins/huaweicloud-core/.claude-plugin/plugin.json +3 -16
  9. package/plugins/huaweicloud-core/.codex-plugin/plugin.json +3 -16
  10. package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +3 -16
  11. package/plugins/huaweicloud-core/.mcp.json +1 -3
  12. package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +3 -16
  13. package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +136 -136
  14. package/plugins/huaweicloud-core/safety/policy.json +75 -100
  15. package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +41 -13
  16. package/plugins/huaweicloud-core/skills/huawei-apig/SKILL.md +34 -34
  17. package/plugins/huaweicloud-core/skills/huawei-billing/SKILL.md +18 -18
  18. package/plugins/huaweicloud-core/skills/huawei-cbr/SKILL.md +19 -19
  19. package/plugins/huaweicloud-core/skills/huawei-cce/SKILL.md +32 -32
  20. package/plugins/huaweicloud-core/skills/huawei-cloud-eye/SKILL.md +30 -30
  21. package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/SKILL.md +12 -11
  22. package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/scripts/search-skills.mjs +64 -17
  23. package/plugins/huaweicloud-core/skills/huawei-cts/SKILL.md +20 -20
  24. package/plugins/huaweicloud-core/skills/huawei-dds-dcs/SKILL.md +31 -31
  25. package/plugins/huaweicloud-core/skills/huawei-deployment/SKILL.md +20 -20
  26. package/plugins/huaweicloud-core/skills/huawei-dew/SKILL.md +39 -30
  27. package/plugins/huaweicloud-core/skills/huawei-dew/references/csms-usage.md +8 -1
  28. package/plugins/huaweicloud-core/skills/huawei-dew/references/kms-usage.md +6 -0
  29. package/plugins/huaweicloud-core/skills/huawei-ecs/SKILL.md +39 -36
  30. package/plugins/huaweicloud-core/skills/huawei-ecs/references/create-instance.md +15 -4
  31. package/plugins/huaweicloud-core/skills/huawei-ecs/references/flavors.md +11 -9
  32. package/plugins/huaweicloud-core/skills/huawei-ecs/references/troubleshooting.md +13 -13
  33. package/plugins/huaweicloud-core/skills/huawei-functiongraph/SKILL.md +40 -39
  34. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/apig-event-format.md +12 -10
  35. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/create-function.md +21 -20
  36. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/triggers.md +19 -19
  37. package/plugins/huaweicloud-core/skills/huawei-gaussdb/SKILL.md +20 -20
  38. package/plugins/huaweicloud-core/skills/huawei-getting-started/SKILL.md +27 -23
  39. package/plugins/huaweicloud-core/skills/huawei-iam/SKILL.md +27 -27
  40. package/plugins/huaweicloud-core/skills/huawei-iam/references/policy-examples.md +65 -39
  41. package/plugins/huaweicloud-core/skills/huawei-iam/references/quick-ref.md +9 -9
  42. package/plugins/huaweicloud-core/skills/huawei-modelarts/SKILL.md +25 -25
  43. package/plugins/huaweicloud-core/skills/huawei-obs/SKILL.md +44 -44
  44. package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-create.md +19 -19
  45. package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-lifecycle.md +12 -7
  46. package/plugins/huaweicloud-core/skills/huawei-obs/references/common-pitfalls.md +13 -12
  47. package/plugins/huaweicloud-core/skills/huawei-obs/references/single-file-share.md +4 -4
  48. package/plugins/huaweicloud-core/skills/huawei-rds/SKILL.md +63 -58
  49. package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +39 -39
  50. package/plugins/huaweicloud-core/skills/huawei-smn-dms/SKILL.md +26 -26
  51. package/plugins/huaweicloud-core/skills/huawei-vpc/SKILL.md +39 -39
  52. package/plugins/huaweicloud-core/skills/huawei-vpc/references/network.md +13 -12
  53. package/plugins/huaweicloud-core/skills/huawei-vpc/references/security-group.md +20 -19
  54. package/plugins/huaweicloud-core/skills/huawei-vpc/references/subnet.md +15 -15
  55. package/plugins/huaweicloud-core/skills/huawei-waf-aad/SKILL.md +18 -18
  56. package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/SKILL.md +13 -13
  57. package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/agents/openai.yaml +3 -3
  58. package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/SKILL.md +6 -1
  59. package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/agents/openai.yaml +3 -3
  60. package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +11 -1
  61. package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/agents/openai.yaml +3 -3
  62. package/plugins/huaweicloud-core/skills/huaweicloud-core/SKILL.md +53 -53
  63. package/plugins/huaweicloud-core/skills/huaweicloud-core/agents/openai.yaml +3 -3
  64. package/plugins/huaweicloud-core/skills/huaweicloud-core/references/report-issue.md +6 -6
  65. package/plugins/huaweicloud-core/skills/huaweicloud-core/references/select.md +3 -1
  66. package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +0 -1
  67. package/plugins/huaweicloud-core/skills/huaweicloud-safety/agents/openai.yaml +3 -3
  68. package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +33 -33
  69. package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/agents/openai.yaml +3 -3
  70. package/plugins/huaweicloud-core/src/auth/agent-registration.mjs +39 -4
  71. package/plugins/huaweicloud-core/src/auth/credentials.mjs +12 -4
  72. package/plugins/huaweicloud-core/src/auth/service.mjs +1 -1
  73. package/plugins/huaweicloud-core/src/data/icons-manifest.v1.json +3517 -0
  74. package/plugins/huaweicloud-core/src/hcloud-cli.mjs +16 -7
  75. package/plugins/huaweicloud-core/src/icon-library.mjs +171 -0
  76. package/plugins/huaweicloud-core/src/mcp-server.mjs +0 -1
  77. package/plugins/huaweicloud-core/src/proxy/proxy-agent.mjs +1 -2
  78. package/plugins/huaweicloud-core/src/proxy/proxy-config.mjs +4 -1
  79. package/plugins/huaweicloud-core/src/risk-rule-engine.mjs +4 -1
  80. package/plugins/huaweicloud-core/src/safety-policy.mjs +122 -68
  81. package/plugins/huaweicloud-core/src/sandbox/hdkitservice-api.mjs +2 -7
  82. package/plugins/huaweicloud-core/src/sandbox/hwlink-api.mjs +10 -22
  83. package/plugins/huaweicloud-core/src/sandbox/session-manager.mjs +30 -9
  84. package/plugins/huaweicloud-core/src/search-market.mjs +46 -12
  85. package/plugins/huaweicloud-core/src/setup-cli.mjs +743 -168
  86. package/plugins/huaweicloud-core/src/tools.mjs +427 -114
  87. package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-client.js +54 -34
  88. package/plugins/huaweicloud-core/src/ws-exec/hwlink-fair-queue.js +1 -5
  89. package/plugins/huaweicloud-core/src/ws-exec/hwlink-multiplexer.js +3 -15
  90. package/plugins/huaweicloud-core/src/ws-exec/hwlink-packet.js +3 -16
  91. package/plugins/huaweicloud-core/src/ws-exec/hwlink-terminal-channel.js +37 -31
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-core",
3
- "version": "1.0.2-next.7",
3
+ "version": "1.0.2-next.8",
4
4
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
5
5
  "author": {
6
6
  "name": "HuaweiCloud Mate",
@@ -9,17 +9,7 @@
9
9
  "homepage": "https://github.com/huaweicloud/HuaweiCloud-Devkit",
10
10
  "repository": "https://github.com/huaweicloud/HuaweiCloud-Devkit",
11
11
  "license": "Apache-2.0",
12
- "keywords": [
13
- "huaweicloud",
14
- "huawei-cloud",
15
- "koocli",
16
- "hcloud",
17
- "agent",
18
- "mcp",
19
- "api",
20
- "sdk",
21
- "skills"
22
- ],
12
+ "keywords": ["huaweicloud", "huawei-cloud", "koocli", "hcloud", "agent", "mcp", "api", "sdk", "skills"],
23
13
  "skills": "./skills/",
24
14
  "mcpServers": "./.mcp.json",
25
15
  "interface": {
@@ -28,10 +18,7 @@
28
18
  "longDescription": "HuaweiCloud Devkit helps coding agents choose and use Huawei Cloud Skills, KooCLI, APIs, SDKs, and MCP tools with less context, safer command execution, and more accurate cloud implementation decisions.",
29
19
  "developerName": "HuaweiCloud Mate",
30
20
  "category": "Cloud",
31
- "capabilities": [
32
- "Read",
33
- "Interactive"
34
- ],
21
+ "capabilities": ["Read", "Interactive"],
35
22
  "websiteURL": "https://github.com/huaweicloud/HuaweiCloud-Devkit",
36
23
  "brandColor": "#C7000B",
37
24
  "defaultPrompt": [
@@ -5,10 +5,7 @@
5
5
  "longDescription": "HuaweiCloud Devkit helps coding agents choose and use Huawei Cloud Skills, KooCLI, APIs, SDKs, and MCP tools with less context, safer command execution, and more accurate cloud implementation decisions.",
6
6
  "developerName": "HuaweiCloud Mate",
7
7
  "category": "Cloud",
8
- "capabilities": [
9
- "Read",
10
- "Interactive"
11
- ],
8
+ "capabilities": ["Read", "Interactive"],
12
9
  "websiteURL": "https://github.com/huaweicloud/HuaweiCloud-Devkit",
13
10
  "brandColor": "#C7000B",
14
11
  "defaultPrompt": [
@@ -20,7 +17,7 @@
20
17
  "mcpServers": "./.mcp.json",
21
18
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
22
19
  "skills": "./skills/",
23
- "version": "1.0.2-next.7",
20
+ "version": "1.0.2-next.8",
24
21
  "author": {
25
22
  "name": "HuaweiCloud Mate",
26
23
  "url": "https://github.com/huaweicloud"
@@ -30,15 +27,5 @@
30
27
  "homepage": "https://github.com/huaweicloud/HuaweiCloud-Devkit",
31
28
  "repository": "https://github.com/huaweicloud/HuaweiCloud-Devkit",
32
29
  "license": "Apache-2.0",
33
- "keywords": [
34
- "huaweicloud",
35
- "huawei-cloud",
36
- "koocli",
37
- "hcloud",
38
- "agent",
39
- "mcp",
40
- "api",
41
- "sdk",
42
- "skills"
43
- ]
30
+ "keywords": ["huaweicloud", "huawei-cloud", "koocli", "hcloud", "agent", "mcp", "api", "sdk", "skills"]
44
31
  }
@@ -2,9 +2,7 @@
2
2
  "mcpServers": {
3
3
  "huaweicloud-devkit": {
4
4
  "command": "node",
5
- "args": [
6
- "./src/mcp-server.mjs"
7
- ],
5
+ "args": ["./src/mcp-server.mjs"],
8
6
  "cwd": ".",
9
7
  "env": {
10
8
  "HUAWEICLOUD_AGENT_TOOLKIT_MODE": "local",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-core",
3
- "version": "1.0.2-next.7",
3
+ "version": "1.0.2-next.8",
4
4
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
5
5
  "author": {
6
6
  "name": "HuaweiCloud Mate",
@@ -9,17 +9,7 @@
9
9
  "homepage": "https://github.com/huaweicloud/HuaweiCloud-Devkit",
10
10
  "repository": "https://github.com/huaweicloud/HuaweiCloud-Devkit",
11
11
  "license": "Apache-2.0",
12
- "keywords": [
13
- "huaweicloud",
14
- "huawei-cloud",
15
- "koocli",
16
- "hcloud",
17
- "agent",
18
- "mcp",
19
- "api",
20
- "sdk",
21
- "skills"
22
- ],
12
+ "keywords": ["huaweicloud", "huawei-cloud", "koocli", "hcloud", "agent", "mcp", "api", "sdk", "skills"],
23
13
  "skills": "./skills/",
24
14
  "mcpServers": "./.mcp.json",
25
15
  "hooks": "./hooks/",
@@ -29,10 +19,7 @@
29
19
  "longDescription": "HuaweiCloud Devkit helps coding agents choose and use Huawei Cloud Skills, KooCLI, APIs, SDKs, and MCP tools with less context, safer command execution, and more accurate cloud implementation decisions.",
30
20
  "developerName": "HuaweiCloud Mate",
31
21
  "category": "Cloud",
32
- "capabilities": [
33
- "Read",
34
- "Interactive"
35
- ],
22
+ "capabilities": ["Read", "Interactive"],
36
23
  "websiteURL": "https://github.com/huaweicloud/HuaweiCloud-Devkit",
37
24
  "brandColor": "#C7000B",
38
25
  "defaultPrompt": [
@@ -1,136 +1,136 @@
1
- #!/usr/bin/env python3
2
- """PreToolUse hook for Huawei Cloud agent safety.
3
-
4
- Blocks the highest-risk leakage paths before an agent tool runs:
5
- - reading local Huawei Cloud credential files
6
- - dumping cloud credential environment variables
7
- - directly retrieving cloud secret values
8
- - running unapproved write operations through hcloud
9
-
10
- The MCP server carries the same policy in Node for platforms that do not support
11
- plugin hooks.
12
- """
13
-
14
- import json
15
- import re
16
- import sys
17
- from pathlib import Path
18
-
19
- DENY_PREFIX = "Huawei Cloud safety hook blocked this action: "
20
- RULES_PATH = Path(__file__).resolve().parents[1] / "safety" / "rules" / "cloud-risk-rules.json"
21
-
22
- CONFIG_FILE_RE = re.compile(r"(\.hcloud|\.huaweicloud|hcloud[/\\](config|credentials)|huaweicloud[/\\](config|credentials))", re.I)
23
- ENV_DUMP_RE = re.compile(r"(env|printenv|Get-ChildItem\s+Env:|gci\s+Env:|dir\s+Env:).*(HUAWEICLOUD|HWC_|HCLOUD|OS_)", re.I)
24
- SECRET_READ_RE = re.compile(r"(ShowSecretVersion|GetSecretValue|secret_string|secret_binary)", re.I)
25
- HCLOUD_RE = re.compile(r"(^|\s)hcloud(\.exe)?\s+", re.I)
26
- WRITE_OPERATION_RE = re.compile(
27
- r"\b(BatchCreate|BatchDelete|Create|Delete|Update|Modify|Resize|Reboot|Stop|Start|Restart|Authorize|Revoke|Add|Remove|Associate|Disassociate|Attach|Detach|Enable|Disable)\w*",
28
- re.I,
29
- )
30
- READ_OPERATION_RE = re.compile(r"\b(List|Show|Get|Describe|NovaList|NovaShow)\w*", re.I)
31
-
32
-
33
- def deny(reason):
34
- json.dump(
35
- {
36
- "hookSpecificOutput": {
37
- "hookEventName": "PreToolUse",
38
- "permissionDecision": "deny",
39
- "permissionDecisionReason": DENY_PREFIX + reason,
40
- }
41
- },
42
- sys.stdout,
43
- )
44
- sys.exit(0)
45
-
46
-
47
- def allow():
48
- sys.exit(0)
49
-
50
-
51
- def command_text(tool_input):
52
- if isinstance(tool_input, str):
53
- return tool_input
54
- if isinstance(tool_input, dict):
55
- values = []
56
- for key in ("command", "cmd", "script", "args", "arguments"):
57
- value = tool_input.get(key)
58
- if isinstance(value, list):
59
- values.append(" ".join(str(item) for item in value))
60
- elif value is not None:
61
- values.append(str(value))
62
- if values:
63
- return "\n".join(values)
64
- return json.dumps(tool_input)
65
- return json.dumps(tool_input)
66
-
67
-
68
- def load_cloud_risk_rules():
69
- try:
70
- with RULES_PATH.open("r", encoding="utf-8") as file_obj:
71
- catalog = json.load(file_obj)
72
- return catalog.get("rules", [])
73
- except Exception:
74
- return []
75
-
76
-
77
- def condition_matches(condition, text):
78
- return re.search(condition.get("regex", r"a^"), text, re.I | re.M | re.S) is not None
79
-
80
-
81
- def rule_matches(rule, text):
82
- match = rule.get("match") or {}
83
- all_conditions = match.get("all")
84
- any_conditions = match.get("any")
85
- none_conditions = match.get("none")
86
-
87
- if isinstance(all_conditions, list):
88
- for condition in all_conditions:
89
- if not condition_matches(condition, text):
90
- return False
91
- if isinstance(any_conditions, list):
92
- if not any(condition_matches(condition, text) for condition in any_conditions):
93
- return False
94
- if isinstance(none_conditions, list):
95
- if any(condition_matches(condition, text) for condition in none_conditions):
96
- return False
97
- return isinstance(all_conditions, list) or isinstance(any_conditions, list)
98
-
99
-
100
- def first_denied_command_rule(text):
101
- for rule in load_cloud_risk_rules():
102
- if "command" not in rule.get("stages", []):
103
- continue
104
- if rule.get("severity") != "deny":
105
- continue
106
- if rule_matches(rule, text):
107
- return rule
108
- return None
109
-
110
-
111
- def main():
112
- try:
113
- data = json.load(sys.stdin)
114
- except Exception:
115
- allow()
116
-
117
- tool_name = data.get("tool_name", "")
118
- text = command_text(data.get("tool_input", {}))
119
-
120
- if CONFIG_FILE_RE.search(text):
121
- deny("reading Huawei Cloud credential/profile files can expose AK/SK or tokens. Use redacted toolkit tools.")
122
- if ENV_DUMP_RE.search(text):
123
- deny("dumping cloud credential environment variables is not allowed.")
124
- if SECRET_READ_RE.search(text):
125
- deny("direct secret value retrieval would put plaintext secrets into the agent context.")
126
- denied_rule = first_denied_command_rule(text)
127
- if denied_rule:
128
- deny(f"{denied_rule.get('message')} Remediation: {denied_rule.get('remediation')}")
129
- if tool_name == "Bash" and HCLOUD_RE.search(text) and WRITE_OPERATION_RE.search(text) and not READ_OPERATION_RE.search(text):
130
- deny("unapproved Huawei Cloud write operations must be planned first and explicitly approved by the user.")
131
-
132
- allow()
133
-
134
-
135
- if __name__ == "__main__":
136
- main()
1
+ #!/usr/bin/env python3
2
+ """PreToolUse hook for Huawei Cloud agent safety.
3
+
4
+ Blocks the highest-risk leakage paths before an agent tool runs:
5
+ - reading local Huawei Cloud credential files
6
+ - dumping cloud credential environment variables
7
+ - directly retrieving cloud secret values
8
+ - running unapproved write operations through hcloud
9
+
10
+ The MCP server carries the same policy in Node for platforms that do not support
11
+ plugin hooks.
12
+ """
13
+
14
+ import json
15
+ import re
16
+ import sys
17
+ from pathlib import Path
18
+
19
+ DENY_PREFIX = "Huawei Cloud safety hook blocked this action: "
20
+ RULES_PATH = Path(__file__).resolve().parents[1] / "safety" / "rules" / "cloud-risk-rules.json"
21
+
22
+ CONFIG_FILE_RE = re.compile(r"(\.hcloud|\.huaweicloud|hcloud[/\\](config|credentials)|huaweicloud[/\\](config|credentials))", re.I)
23
+ ENV_DUMP_RE = re.compile(r"(env|printenv|Get-ChildItem\s+Env:|gci\s+Env:|dir\s+Env:).*(HUAWEICLOUD|HWC_|HCLOUD|OS_)", re.I)
24
+ SECRET_READ_RE = re.compile(r"(ShowSecretVersion|GetSecretValue|secret_string|secret_binary)", re.I)
25
+ HCLOUD_RE = re.compile(r"(^|\s)hcloud(\.exe)?\s+", re.I)
26
+ WRITE_OPERATION_RE = re.compile(
27
+ r"\b(BatchCreate|BatchDelete|Create|Delete|Update|Modify|Resize|Reboot|Stop|Start|Restart|Authorize|Revoke|Add|Remove|Associate|Disassociate|Attach|Detach|Enable|Disable)\w*",
28
+ re.I,
29
+ )
30
+ READ_OPERATION_RE = re.compile(r"\b(List|Show|Get|Describe|NovaList|NovaShow)\w*", re.I)
31
+
32
+
33
+ def deny(reason):
34
+ json.dump(
35
+ {
36
+ "hookSpecificOutput": {
37
+ "hookEventName": "PreToolUse",
38
+ "permissionDecision": "deny",
39
+ "permissionDecisionReason": DENY_PREFIX + reason,
40
+ }
41
+ },
42
+ sys.stdout,
43
+ )
44
+ sys.exit(0)
45
+
46
+
47
+ def allow():
48
+ sys.exit(0)
49
+
50
+
51
+ def command_text(tool_input):
52
+ if isinstance(tool_input, str):
53
+ return tool_input
54
+ if isinstance(tool_input, dict):
55
+ values = []
56
+ for key in ("command", "cmd", "script", "args", "arguments"):
57
+ value = tool_input.get(key)
58
+ if isinstance(value, list):
59
+ values.append(" ".join(str(item) for item in value))
60
+ elif value is not None:
61
+ values.append(str(value))
62
+ if values:
63
+ return "\n".join(values)
64
+ return json.dumps(tool_input)
65
+ return json.dumps(tool_input)
66
+
67
+
68
+ def load_cloud_risk_rules():
69
+ try:
70
+ with RULES_PATH.open("r", encoding="utf-8") as file_obj:
71
+ catalog = json.load(file_obj)
72
+ return catalog.get("rules", [])
73
+ except Exception:
74
+ return []
75
+
76
+
77
+ def condition_matches(condition, text):
78
+ return re.search(condition.get("regex", r"a^"), text, re.I | re.M | re.S) is not None
79
+
80
+
81
+ def rule_matches(rule, text):
82
+ match = rule.get("match") or {}
83
+ all_conditions = match.get("all")
84
+ any_conditions = match.get("any")
85
+ none_conditions = match.get("none")
86
+
87
+ if isinstance(all_conditions, list):
88
+ for condition in all_conditions:
89
+ if not condition_matches(condition, text):
90
+ return False
91
+ if isinstance(any_conditions, list):
92
+ if not any(condition_matches(condition, text) for condition in any_conditions):
93
+ return False
94
+ if isinstance(none_conditions, list):
95
+ if any(condition_matches(condition, text) for condition in none_conditions):
96
+ return False
97
+ return isinstance(all_conditions, list) or isinstance(any_conditions, list)
98
+
99
+
100
+ def first_denied_command_rule(text):
101
+ for rule in load_cloud_risk_rules():
102
+ if "command" not in rule.get("stages", []):
103
+ continue
104
+ if rule.get("severity") != "deny":
105
+ continue
106
+ if rule_matches(rule, text):
107
+ return rule
108
+ return None
109
+
110
+
111
+ def main():
112
+ try:
113
+ data = json.load(sys.stdin)
114
+ except Exception:
115
+ allow()
116
+
117
+ tool_name = data.get("tool_name", "")
118
+ text = command_text(data.get("tool_input", {}))
119
+
120
+ if CONFIG_FILE_RE.search(text):
121
+ deny("reading Huawei Cloud credential/profile files can expose AK/SK or tokens. Use redacted toolkit tools.")
122
+ if ENV_DUMP_RE.search(text):
123
+ deny("dumping cloud credential environment variables is not allowed.")
124
+ if SECRET_READ_RE.search(text):
125
+ deny("direct secret value retrieval would put plaintext secrets into the agent context.")
126
+ denied_rule = first_denied_command_rule(text)
127
+ if denied_rule:
128
+ deny(f"{denied_rule.get('message')} Remediation: {denied_rule.get('remediation')}")
129
+ if tool_name == "Bash" and HCLOUD_RE.search(text) and WRITE_OPERATION_RE.search(text) and not READ_OPERATION_RE.search(text):
130
+ deny("unapproved Huawei Cloud write operations must be planned first and explicitly approved by the user.")
131
+
132
+ allow()
133
+
134
+
135
+ if __name__ == "__main__":
136
+ main()
@@ -1,101 +1,76 @@
1
1
  {
2
- "version": "0.1.0",
3
- "secretKeyNamePatterns": [
4
- "access[_-]?key",
5
- "secret[_-]?key",
6
- "security[_-]?token",
7
- "x[_-]?auth[_-]?token",
8
- "authorization",
9
- "password",
10
- "passwd",
11
- "token",
12
- "credential",
13
- "private[_-]?key",
14
- "ak",
15
- "sk"
16
- ],
17
- "credentialFilePatterns": [
18
- "\\.hcloud",
19
- "\\.huaweicloud",
20
- "hcloud[/\\\\](config|credentials)",
21
- "huaweicloud[/\\\\](config|credentials)"
22
- ],
23
- "blockedConfigureSubcommands": [
24
- "show",
25
- "get",
26
- "list",
27
- "export",
28
- "init"
29
- ],
30
- "blockedSecretOperations": [
31
- "ShowSecretVersion",
32
- "DownloadSecret",
33
- "GetSecretValue"
34
- ],
35
- "writeOperationPrefixes": [
36
- "Create",
37
- "BatchCreate",
38
- "Delete",
39
- "BatchDelete",
40
- "Update",
41
- "Modify",
42
- "Resize",
43
- "Reboot",
44
- "Stop",
45
- "Start",
46
- "Restart",
47
- "Authorize",
48
- "Revoke",
49
- "Add",
50
- "Remove",
51
- "Associate",
52
- "Disassociate",
53
- "Attach",
54
- "Detach",
55
- "Enable",
56
- "Disable",
57
- "Set",
58
- "Put",
59
- "Upload",
60
- "Install",
61
- "Publish",
62
- "Bind",
63
- "Unbind",
64
- "Invoke",
65
- "Execute",
66
- "Trigger",
67
- "Deploy"
68
- ],
69
- "readOperationPrefixes": [
70
- "List",
71
- "Show",
72
- "Get",
73
- "Describe",
74
- "NovaList",
75
- "NovaShow"
76
- ],
77
- "safeTextReadCommands": [
78
- "rg",
79
- "grep",
80
- "findstr",
81
- "git",
82
- "ls",
83
- "dir",
84
- "Get-ChildItem"
85
- ],
86
- "blockedSandboxCommands": [
87
- "rm\\s+-rf\\s+/",
88
- "mkfs",
89
- "dd\\s+if=",
90
- ":\\(\\)\\{:\\|:&\\};:",
91
- "shutdown",
92
- "reboot",
93
- "init\\s+[06]",
94
- "fdisk"
95
- ],
96
- "sandboxWriteTools": [
97
- "huaweicloud_sandbox_connect",
98
- "huaweicloud_sandbox_credentials",
99
- "huaweicloud_sandbox_upload_file"
100
- ]
101
- }
2
+ "version": "0.1.0",
3
+ "secretKeyNamePatterns": [
4
+ "access[_-]?key",
5
+ "secret[_-]?key",
6
+ "security[_-]?token",
7
+ "x[_-]?auth[_-]?token",
8
+ "authorization",
9
+ "password",
10
+ "passwd",
11
+ "token",
12
+ "credential",
13
+ "private[_-]?key",
14
+ "ak",
15
+ "sk"
16
+ ],
17
+ "credentialFilePatterns": [
18
+ "\\.hcloud",
19
+ "\\.huaweicloud",
20
+ "hcloud[/\\\\](config|credentials)",
21
+ "huaweicloud[/\\\\](config|credentials)"
22
+ ],
23
+ "blockedConfigureSubcommands": ["show", "get", "list", "export", "init"],
24
+ "blockedSecretOperations": ["ShowSecretVersion", "DownloadSecret", "GetSecretValue"],
25
+ "writeOperationPrefixes": [
26
+ "Create",
27
+ "BatchCreate",
28
+ "Delete",
29
+ "BatchDelete",
30
+ "Update",
31
+ "Modify",
32
+ "Resize",
33
+ "Reboot",
34
+ "Stop",
35
+ "Start",
36
+ "Restart",
37
+ "Authorize",
38
+ "Revoke",
39
+ "Add",
40
+ "Remove",
41
+ "Associate",
42
+ "Disassociate",
43
+ "Attach",
44
+ "Detach",
45
+ "Enable",
46
+ "Disable",
47
+ "Set",
48
+ "Put",
49
+ "Upload",
50
+ "Install",
51
+ "Publish",
52
+ "Bind",
53
+ "Unbind",
54
+ "Invoke",
55
+ "Execute",
56
+ "Trigger",
57
+ "Deploy"
58
+ ],
59
+ "readOperationPrefixes": ["List", "Show", "Get", "Describe", "NovaList", "NovaShow"],
60
+ "safeTextReadCommands": ["rg", "grep", "findstr", "git", "ls", "dir", "Get-ChildItem"],
61
+ "blockedSandboxCommands": [
62
+ "rm\\s+-rf\\s+/",
63
+ "mkfs",
64
+ "dd\\s+if=",
65
+ ":\\(\\)\\{:\\|:&\\};:",
66
+ "shutdown",
67
+ "reboot",
68
+ "init\\s+[06]",
69
+ "fdisk"
70
+ ],
71
+ "sandboxWriteTools": [
72
+ "huaweicloud_sandbox_connect",
73
+ "huaweicloud_sandbox_credentials",
74
+ "huaweicloud_sandbox_upload_file"
75
+ ]
76
+ }