huaweicloud-devkit 1.0.2-dev.9 → 1.0.2-next.10
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/.agents/plugins/marketplace.json +20 -20
- package/LICENSE +201 -201
- package/README.md +178 -138
- package/README.zh-CN.md +176 -138
- package/bin/setup.cjs +10 -8
- package/integrations/opencode/commands/huaweicloud-doctor.md +14 -14
- package/integrations/opencode/opencode.json +11 -14
- package/integrations/opencode/skills/huaweicloud-core/SKILL.md +32 -32
- package/package.json +60 -44
- package/plugins/huaweicloud-core/.claude-plugin/plugin.json +31 -44
- package/plugins/huaweicloud-core/.codex-plugin/plugin.json +30 -43
- package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +31 -44
- package/plugins/huaweicloud-core/.mcp.json +13 -15
- package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +31 -44
- package/plugins/huaweicloud-core/hooks/hooks.json +26 -26
- package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +136 -136
- package/plugins/huaweicloud-core/safety/policy.json +76 -100
- package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +227 -199
- package/plugins/huaweicloud-core/skills/huawei-apig/SKILL.md +164 -164
- package/plugins/huaweicloud-core/skills/huawei-billing/SKILL.md +48 -48
- package/plugins/huaweicloud-core/skills/huawei-cbr/SKILL.md +50 -50
- package/plugins/huaweicloud-core/skills/huawei-cce/SKILL.md +103 -101
- package/plugins/huaweicloud-core/skills/huawei-cloud-eye/SKILL.md +90 -90
- package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/SKILL.md +191 -190
- package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/scripts/search-skills.mjs +171 -124
- package/plugins/huaweicloud-core/skills/huawei-cts/SKILL.md +55 -55
- package/plugins/huaweicloud-core/skills/huawei-dds-dcs/SKILL.md +70 -70
- package/plugins/huaweicloud-core/skills/huawei-deployment/SKILL.md +57 -56
- package/plugins/huaweicloud-core/skills/huawei-dew/SKILL.md +106 -97
- package/plugins/huaweicloud-core/skills/huawei-dew/references/csms-usage.md +36 -29
- package/plugins/huaweicloud-core/skills/huawei-dew/references/kms-usage.md +29 -23
- package/plugins/huaweicloud-core/skills/huawei-ecs/SKILL.md +188 -185
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/create-instance.md +144 -133
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/evs.md +31 -31
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/flavors.md +57 -55
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/troubleshooting.md +52 -52
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/SKILL.md +132 -131
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/apig-event-format.md +60 -58
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/create-function.md +72 -71
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/deploy-workflow.md +119 -119
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/triggers.md +142 -142
- package/plugins/huaweicloud-core/skills/huawei-gaussdb/SKILL.md +56 -56
- package/plugins/huaweicloud-core/skills/huawei-getting-started/SKILL.md +69 -65
- package/plugins/huaweicloud-core/skills/huawei-iam/SKILL.md +111 -111
- package/plugins/huaweicloud-core/skills/huawei-iam/references/policy-examples.md +148 -122
- package/plugins/huaweicloud-core/skills/huawei-iam/references/quick-ref.md +56 -56
- package/plugins/huaweicloud-core/skills/huawei-modelarts/SKILL.md +65 -65
- package/plugins/huaweicloud-core/skills/huawei-obs/SKILL.md +134 -127
- package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-create.md +49 -49
- package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-lifecycle.md +31 -26
- package/plugins/huaweicloud-core/skills/huawei-obs/references/common-pitfalls.md +101 -100
- package/plugins/huaweicloud-core/skills/huawei-obs/references/single-file-share.md +40 -40
- package/plugins/huaweicloud-core/skills/huawei-obs/references/static-website.md +56 -56
- package/plugins/huaweicloud-core/skills/huawei-rds/SKILL.md +229 -224
- package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +173 -134
- package/plugins/huaweicloud-core/skills/huawei-smn-dms/SKILL.md +69 -69
- package/plugins/huaweicloud-core/skills/huawei-vpc/SKILL.md +84 -84
- package/plugins/huaweicloud-core/skills/huawei-vpc/references/network.md +77 -76
- package/plugins/huaweicloud-core/skills/huawei-vpc/references/security-group.md +60 -59
- package/plugins/huaweicloud-core/skills/huawei-vpc/references/subnet.md +50 -50
- package/plugins/huaweicloud-core/skills/huawei-waf-aad/SKILL.md +63 -63
- package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/SKILL.md +56 -56
- package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/SKILL.md +56 -47
- package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +138 -128
- package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-core/SKILL.md +111 -96
- package/plugins/huaweicloud-core/skills/huaweicloud-core/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-core/references/report-issue.md +20 -20
- package/plugins/huaweicloud-core/skills/huaweicloud-core/references/select.md +30 -28
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +59 -60
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +83 -83
- package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/src/auth/agent-registration.mjs +54 -1
- package/plugins/huaweicloud-core/src/auth/credentials.mjs +103 -95
- package/plugins/huaweicloud-core/src/auth/service.mjs +63 -63
- package/plugins/huaweicloud-core/src/data/icons-manifest.v1.json +3517 -0
- package/plugins/huaweicloud-core/src/hcloud-cli.mjs +283 -265
- package/plugins/huaweicloud-core/src/icon-library.mjs +171 -0
- package/plugins/huaweicloud-core/src/mcp-server.mjs +130 -129
- package/plugins/huaweicloud-core/src/proxy/proxy-agent.mjs +68 -0
- package/plugins/huaweicloud-core/src/proxy/proxy-config.mjs +94 -0
- package/plugins/huaweicloud-core/src/risk-rule-engine.mjs +140 -137
- package/plugins/huaweicloud-core/src/safety-policy.mjs +356 -302
- package/plugins/huaweicloud-core/src/sandbox/hdkitservice-api.mjs +86 -87
- package/plugins/huaweicloud-core/src/sandbox/hwlink-api.mjs +150 -153
- package/plugins/huaweicloud-core/src/sandbox/session-manager.mjs +196 -105
- package/plugins/huaweicloud-core/src/search-market.mjs +208 -169
- package/plugins/huaweicloud-core/src/setup-cli.mjs +2622 -1594
- package/plugins/huaweicloud-core/src/tools.mjs +463 -111
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-client.js +447 -427
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-fair-queue.js +128 -132
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-multiplexer.js +215 -227
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-packet.js +189 -202
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-terminal-channel.js +164 -158
- package/plugins/huaweicloud-core/src/ws-exec/index.js +19 -19
- package/plugins/huaweicloud-core/src/ws-exec/ws-exec-client.js +338 -338
|
@@ -1,137 +1,140 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
-
import { dirname, join } from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
|
|
5
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
const defaultRulesPath = join(__dirname, '..', 'safety', 'rules', 'cloud-risk-rules.json');
|
|
7
|
-
|
|
8
|
-
const SEVERITY_RANK = {
|
|
9
|
-
deny: 3,
|
|
10
|
-
warn: 2,
|
|
11
|
-
info: 1,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export function loadRiskRules(options = {}) {
|
|
15
|
-
const path = options.path || defaultRulesPath;
|
|
16
|
-
return JSON.parse(readFileSync(path, 'utf8'));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function redactEvidence(text) {
|
|
20
|
-
return String(text)
|
|
21
|
-
.replace(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (Array.isArray(
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
if (Array.isArray(
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const defaultRulesPath = join(__dirname, '..', 'safety', 'rules', 'cloud-risk-rules.json');
|
|
7
|
+
|
|
8
|
+
const SEVERITY_RANK = {
|
|
9
|
+
deny: 3,
|
|
10
|
+
warn: 2,
|
|
11
|
+
info: 1,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function loadRiskRules(options = {}) {
|
|
15
|
+
const path = options.path || defaultRulesPath;
|
|
16
|
+
return JSON.parse(readFileSync(path, 'utf8'));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function redactEvidence(text) {
|
|
20
|
+
return String(text)
|
|
21
|
+
.replace(
|
|
22
|
+
/((?:access[_-]?key|secret[_-]?key|security[_-]?token|x[_-]?auth[_-]?token|authorization|password|passwd|adminPass|credential)\s*[:=]\s*)("[^"]*"|'[^']*'|[^\s,;]+)/gi,
|
|
23
|
+
'$1<redacted>',
|
|
24
|
+
)
|
|
25
|
+
.replace(/(AK|SK)\s*[:=]\s*("[^"]*"|'[^']*'|[^\s,;]+)/g, '$1=<redacted>');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function normalizeText(value) {
|
|
29
|
+
if (typeof value === 'string') return value;
|
|
30
|
+
return JSON.stringify(value, null, 2);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function evaluationContext(stage, input) {
|
|
34
|
+
if (stage === 'command') {
|
|
35
|
+
const command = normalizeText(input.command || input.text || '');
|
|
36
|
+
return { text: command, command };
|
|
37
|
+
}
|
|
38
|
+
if (stage === 'artifact') {
|
|
39
|
+
const path = String(input.path || '');
|
|
40
|
+
const content = normalizeText(input.content || '');
|
|
41
|
+
return { text: `${path}\n${content}`, path, content };
|
|
42
|
+
}
|
|
43
|
+
if (stage === 'deploy_plan') {
|
|
44
|
+
const plan = normalizeText(input.plan || input.text || input);
|
|
45
|
+
return { text: plan, plan };
|
|
46
|
+
}
|
|
47
|
+
return { text: normalizeText(input) };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function conditionMatches(condition, context) {
|
|
51
|
+
const field = condition.field || 'text';
|
|
52
|
+
const value = Object.hasOwn(context, field) ? context[field] : context.text;
|
|
53
|
+
return new RegExp(condition.regex, 'ims').test(String(value || ''));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function ruleMatches(rule, context) {
|
|
57
|
+
const match = rule.match || {};
|
|
58
|
+
const all = match.all;
|
|
59
|
+
const any = match.any;
|
|
60
|
+
const none = match.none;
|
|
61
|
+
if (Array.isArray(all) && !all.every((condition) => conditionMatches(condition, context))) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
if (Array.isArray(any) && !any.some((condition) => conditionMatches(condition, context))) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (Array.isArray(none) && none.some((condition) => conditionMatches(condition, context))) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return Array.isArray(all) || Array.isArray(any);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function excerpt(text) {
|
|
74
|
+
const compact = redactEvidence(String(text).replace(/\s+/g, ' ').trim());
|
|
75
|
+
if (compact.length <= 240) return compact;
|
|
76
|
+
return `${compact.slice(0, 237)}...`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function evaluate(stage, inputs, options = {}) {
|
|
80
|
+
const catalog = options.catalog || loadRiskRules(options);
|
|
81
|
+
const items = Array.isArray(inputs) ? inputs : [inputs];
|
|
82
|
+
const findings = [];
|
|
83
|
+
|
|
84
|
+
for (const input of items) {
|
|
85
|
+
const context = evaluationContext(stage, input || {});
|
|
86
|
+
for (const rule of catalog.rules) {
|
|
87
|
+
if (!rule.stages.includes(stage)) continue;
|
|
88
|
+
if (!ruleMatches(rule, context)) continue;
|
|
89
|
+
findings.push({
|
|
90
|
+
ruleId: rule.id,
|
|
91
|
+
title: rule.title,
|
|
92
|
+
category: rule.category,
|
|
93
|
+
severity: rule.severity,
|
|
94
|
+
message: rule.message,
|
|
95
|
+
remediation: rule.remediation,
|
|
96
|
+
source: input?.path || stage,
|
|
97
|
+
evidence: excerpt(context.text),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
findings.sort((a, b) => SEVERITY_RANK[b.severity] - SEVERITY_RANK[a.severity]);
|
|
103
|
+
const hasDeny = findings.some((finding) => finding.severity === 'deny');
|
|
104
|
+
const hasWarn = findings.some((finding) => finding.severity === 'warn');
|
|
105
|
+
return {
|
|
106
|
+
decision: hasDeny ? 'deny' : hasWarn ? 'warn' : 'allow',
|
|
107
|
+
findings,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function evaluateCommandRisk(command, options = {}) {
|
|
112
|
+
return evaluate('command', { command }, options);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function evaluateArtifacts(artifacts, options = {}) {
|
|
116
|
+
return evaluate('artifact', Array.isArray(artifacts) ? artifacts : [], options);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function evaluateDeployPlan(plan, options = {}) {
|
|
120
|
+
return evaluate('deploy_plan', { plan }, options);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function mergeRiskDecision(base, risk) {
|
|
124
|
+
if (!risk || !risk.findings?.length) return base;
|
|
125
|
+
if (risk.decision === 'deny') {
|
|
126
|
+
const topFinding = risk.findings[0];
|
|
127
|
+
return {
|
|
128
|
+
...base,
|
|
129
|
+
decision: 'deny',
|
|
130
|
+
risk: topFinding.category,
|
|
131
|
+
reason: topFinding.message,
|
|
132
|
+
blockedByRiskRule: true,
|
|
133
|
+
findings: risk.findings,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
...base,
|
|
138
|
+
warnings: [...(base.warnings || []), ...risk.findings],
|
|
139
|
+
};
|
|
140
|
+
}
|