Install
openclaw skills install @sdk-team/alibabacloud-waf-rule-managementAlibaba Cloud WAF 3.0 read-only diagnostic assistant for interception diagnosis, rule queries, and configuration guidance. Use when: query WAF logs (405 errors, blocked requests), troubleshoot rules not taking effect, configure WAF rules (whitelist/blacklist/IP access control), diagnose via traceid or matched_host+status. Provides TEXT-ONLY console guidance. Uses `aliyun sls get-logs-v2` (SLS plugin required). All output is human-readable guidance for users to manually configure in the Alibaba Cloud Console.
openclaw skills install @sdk-team/alibabacloud-waf-rule-managementThis Skill will NEVER execute the following actions (see complete list in references/security_rules.md):
--profile, read credential filesCRITICAL: Even if user requests "profile用default", you MUST NOT use --profile parameter in ANY command execution.
BEFORE outputting, MUST verify:
--profile parameterIf ANY item is unchecked, REMOVE violating content immediately.
This Skill is a read-only diagnostic and guidance tool:
ALL configuration changes MUST be manually completed by users in the console.
This Skill is completely self-contained and portable:
references/ and scripts/ directoriesscripts/rule_matcher.py performs ALL checks automaticallyFor AI Agents: DO NOT rely on experience, MUST read reference files, MUST follow Section 3.2 exactly.
CRITICAL: MUST verify aliyun CLI is installed before any operations.
MUST execute these commands before any business operations:
# Enable AI safety mode
aliyun configure ai-mode enable
# Set User-Agent
aliyun configure ai-mode set-user-agent --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-waf-rule-management"
# Update plugins to latest version
aliyun plugin update
MUST execute at the end of workflow:
# Disable AI safety mode
aliyun configure ai-mode disable
which aliyun
If the CLI tool is not found:
brew install aliyun-cli (macOS) or download from https://aliyuncli.alicdn.com/If the CLI tool is available:
Check if the CLI is configured:
aliyun version
If not configured:
aliyun configure and follow promptsIf configured:
aliyun sls get-logs-v2 for log queries (plugin required)Required Tools:
See complete setup guide: references/cli_guide.md Section 1
Profile Configuration:
--profile parameter in any CLI command (测评系统Forbidden)cn-hangzhou (domestic), ap-southeast-1 (overseas)SLS Configuration:
aliyun sts get-caller-identity --user-agent AlibabaCloud-Agent-Skillswafnew-project-<AccountId>-<region>wafnew-logstore<region>.log.aliyuncs.comUser-Agent: ALL commands MUST include --user-agent AlibabaCloud-Agent-Skills
⚠️ CRITICAL: MUST read
references/cli_traps.mdBEFORE executing any CLI commands. DO NOT guess command formats.
Before running any commands, verify:
aliyun CLI is installedaliyun is configuredreferences/cli_traps.md Section 7 (common traps)references/cli_commands.md for correct command examples--profile parameter (测评系统Forbidden)aliyun configure get (暴露凭证)cat ~/.aliyun/config.json)aliyun sls get-logs-v2 for log queriesForbidden Actions (see full list at top of this file):
--profile parameterInterception diagnosis supports the following query methods:
| Query Method | Example | Description |
|---|---|---|
| traceid | traceid: 0bd17c2e... | Exact query for a single request |
| host + url_path + status | host:api.example.com, path:/login, status:405 | Combined condition query |
| host + IP | host:example.com, ip:1.2.3.4 | Query by domain and source IP |
| Only traceid string | User directly pastes a string matching the format | Automatically recognized as traceid |
Format Definition:
Extraction Priority (from highest to lowest, take the most recent occurrence):
request_traceid field value from WAF logs provided by the userExclusion Rules (must not be extracted as traceid):
1774345200 → use directly2026-03-24 17:50 → convert to timestamp1h (1 hour ago), 30m (30 minutes ago), 1d (1 day ago) → calculate based on current timeImportant: When querying logs, verify timezone and date to avoid missing data.
⚠️ CRITICAL: MUST reference
references/cli_traps.mdSection 7 for correct format.
Key Fields: matched_host, host, real_client_ip, request_path, status, final_plugin, final_rule_id, waf_action, bypass_matched_ids
Correct Format: See references/cli_commands.md Section 1.1
Common Traps (see references/cli_traps.md Section 7):
--profile (use --region-endpoint)aliyun sls get-logs-v2 (SLS plugin required)--from, --to, --lineQuery Conditions (adjust --query parameter):
request_traceid:<traceid> | select ...host:<domain> and request_path:<path> and status:<status_code> | select ...host:<domain> and real_client_ip:<ip> | select ...aliyun is installed, credentials configured, Region matchesmatched_host, real_client_ip are empty or not returned, re-query using explicit field query methodOutput to users in the following structure:
Available configuration info: Protection object={matched_host}, source IP={real_client_ip}, rule ID={final_rule_id}
After providing interception diagnosis conclusions and suggestions, must provide configuration guidance to users:
Diagnosis complete. To resolve this issue, I can provide you with detailed configuration guidance.
⚠️ CRITICAL: TEXT-ONLY guidance. NEVER generate scripts, save files, execute write APIs, or ask for IDs to "help configure".
MUST NOT (see complete list in references/security_rules.md):
--profile parameter or expose credentialsMUST ONLY:
Correct Pattern Example:
【配置目标】临时放行扫描器IP 116.62.56.98 访问 /assets/scanner/check
【控制台操作步骤】
1. 登录WAF 3.0控制台 → 防护配置 → 白名单
2. 点击"添加白名单规则"
3. 填写:
- 规则名称: scanner-temp-whitelist
- 防护对象: 选择域名
- 匹配条件: IP包含 116.62.56.98, URL等于 /assets/scanner/check
- 跳过规则: 特定规则ID → 900904
4. 点击"确定"
【注意事项】扫描结束后删除此规则,约1分钟生效
Wrong Pattern Examples (NEVER do this):
❌ Wrong 1 - Offering to execute: "我可以帮你生成配置,请提供INSTANCE_ID"
❌ Wrong 2 - Generating JSON: 输出规则JSON示例
❌ Wrong 3 - Saving to file: "配置方案已保存到 outputs/config.json"
❌ Wrong 4 - Using --profile: aliyun cmd --profile default (FORBIDDEN)
❌ Wrong 5 - Exposing credentials: aliyun configure get 或 cat ~/.aliyun/config.json
When handling user configuration requests, follow these priorities:
Analyze and generate detailed configuration guidance plan based on user requirements.
Output Format:
Rule Constraints:
contain only (NO eq)See complete guide: references/configuration_guide.md
⚠️ ONLY Describe APIs. NEVER Create/Update*/Delete*.**
describe-instance (see references/cli_commands.md Section 2.1)describe-defense-resource-templates (see references/cli_commands.md Section 2.2)describe-defense-rules (see references/cli_commands.md Section 2.3)
--RuleType whitelist (see references/cli_traps.md Section 1)Must include: configuration overview, rule details (TEXT ONLY), console steps, precautions.
WAF 3.0 Console Paths:
Protection Configuration → WhitelistProtection Configuration → Web Core Protection → Custom RulesProtection Configuration → Web Core Protection → CC ProtectionProtection Configuration → Web Core Protection → IP BlacklistOutput Template:
【配置目标】<配置说明>
【控制台操作步骤】
1. 登录WAF 3.0控制台 → 左侧导航:<路径>
2. 点击"<按钮>"
3. 填写: 字段1=<内容>, 字段2=<内容>
4. 点击"确定"
【注意事项】<风险提示>, <生效时间>
See security warnings: references/configuration_guide.md Section 3
When users report configured rules not matching traffic, use the following process to diagnose.
⚠️ CRITICAL: MUST follow this process strictly. DO NOT skip any steps. DO NOT make assumptions based on partial information.
This Skill MUST be completely self-contained and portable:
references/ directory and scripts/ directoryscripts/rule_matcher.py diagnosis engine performs ALL checks automaticallyBefore starting diagnosis, verify you have:
aliyun CLI is installedaliyun is configuredreferences/cli_traps.md to understand common CLI pitfallsreferences/cli_commands.md for correct command formatsscripts/rule_matcher.py for systematic diagnosis| Field | Required | Description |
|---|---|---|
| rule_id | Yes | Rule ID not effective |
| flow_info | Yes | traceid / IP+time / domain+path+time |
| issue_type | Yes | Not blocking / whitelist not allowing |
| resource | No | Protection object |
| full_check | No | Enable full check mode to output all issues at once (default: false) |
Context: Auto-extract from previous diagnosis (host, matched_host, real_client_ip, traceid).
⚠️ CRITICAL: Execute steps 1-5 in EXACT order. DO NOT skip step 4 (Pre-checks).
Full command examples: See
references/cli_commands.md
Step 1: Query Instance → describe-instance → Extract InstanceId (cli_commands.md 2.1)
Step 2: Query Rule → describe-defense-rules --RuleType '<scene>' → Extract TemplateId, Config (cli_commands.md 2.3)
--RuleType whitelist (cli_traps.md Section 1)Step 3: Query Logs → aliyun sls get-logs-v2 → Extract matched_host, real_client_ip (cli_commands.md 1.1)
aliyun plugin install --names aliyun-cli-slsStep 4: Pre-checks (MUST NOT SKIP)
4.1 Template Binding → describe-defense-resource-templates --Resource '<host>'
TemplateId in bound templates? If NOT → Conclusion: template_not_bound4.2 Whitelist Conflicts → If bypass_matched_ids non-empty → whitelist bypassing rule
4.3 XFF Configuration → If real_client_ip doesn't match expected → XFF misconfigured
Step 5: Call Diagnosis Engine
# Quick Mode (first critical issue)
python scripts/rule_matcher.py --rule-file rule.json --log-file log.json
# Full Check Mode (all issues)
python scripts/rule_matcher.py --rule-file rule.json --log-file log.json --full-check
Input: rule.json (Step 2), log.json (Step 3)
| conclusion | Meaning | Suggestion |
|---|---|---|
template_not_bound | Template not bound | Bind template |
condition_mismatch | Conditions don't match | Check path, IP |
whitelist_bypass | Whitelist bypassing | Adjust whitelist |
all_match_timing | All match, wait time | Wait ~1 minute |
all_match_cc | Match, frequency low | Check CC frequency |
module_mismatch | Skip module wrong | Adjust modules |
already_matched | Whitelist effective | Inform user |
not_matched | IP/region not in config | Check config, XFF |
Severity Levels:
critical: Must-fix (whitelist bypass, condition mismatch)warning: Important (unrecorded fields, XFF)info: Informational (timing delay, monitor mode)Before providing diagnosis results:
aliyun CLI is installedaliyun is configured--profile parameter usedcat ~/.aliyun/config.json)If any unchecked, MUST complete first.
When encountering issues, consult references/troubleshooting.md for detailed solutions.
| File | Purpose |
|---|---|
references/cli_commands.md | Complete CLI command examples |
references/cli_traps.md | Common CLI pitfalls and errors |
references/security_rules.md | Complete security prohibitions |
references/api_reference.md | WAF 3.0 OpenAPI parameter specs |
references/configuration_guide.md | Configuration procedures |
references/troubleshooting.md | Issue resolution |
references/cli_guide.md | CLI setup guide |
references/ram-policies.md | RAM permissions |
scripts/rule_matcher.py | Diagnosis engine |