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-management⚠️ THIS IS A READ-ONLY DIAGNOSIS ASSISTANT. STRICTLY PROHIBITED:
run_in_terminal for ANY write operations (create/modify/delete)--profile, read credential filesCRITICAL: Even if user requests "profile as default", you MUST NOT use --profile parameter in ANY command execution.
All diagnosis reports MUST start with:
⚠️ Disclaimer: This tool is a read-only diagnostic assistant, only providing analysis and configuration suggestions, and will NOT execute any configuration changes.
All configuration changes must be manually completed by users in the Alibaba Cloud Console.
aliyun waf-openapi describe-* (query WAF info)aliyun sls get-logs-v2 (query logs)BEFORE outputting, MUST verify:
--profile parameterIf ANY item is unchecked, REMOVE violating content immediately.
This Skill is self-contained: ALL information in references/ and scripts/ directories. NO external experience required. scripts/rule_matcher.py performs ALL checks automatically. For AI Agents: MUST read reference files, MUST follow Section 3.2 exactly.
CRITICAL: MUST verify aliyun CLI is installed before any operations.
All Alibaba Cloud service CLI commands within this Skill MUST include the following User-Agent header:
AlibabaCloud-Agent-Skills/alibabacloud-waf-rule-management/{{SESSION_ID}}
Usage in CLI commands:
--user-agent "AlibabaCloud-Agent-Skills/alibabacloud-waf-rule-management/{{SESSION_ID}}"
a1b2c3d4e5f67890abcdef1234567890).{{SESSION_ID}} placeholder in every command example with the generated value before execution.python3 -c "import uuid; print(uuid.uuid4().hex)" or openssl rand -hex 16.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 (Evaluation system forbidden rule)cn-hangzhou (domestic), ap-southeast-1 (overseas)SLS Configuration (PayType-driven naming):
aliyun sts get-caller-identity --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-waf-rule-management/{{SESSION_ID}}"describe-instance → check PayType fieldwafnew-project-<AccountId>-<SLSRegion>wafnew-logstorewafng-project-<AccountId>-<SLSRegion>wafng-logstoreProjectNotExist or LogStoreNotExist error occurs, try other regions (e.g., cn-hangzhou, cn-shenzhen, cn-beijing).--region <SLSRegion> to ALL aliyun sls get-logs-v2 commands, otherwise CLI uses default region and returns 404.User-Agent: ALL commands MUST include --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-waf-rule-management/{{SESSION_ID}}"
⚠️ CRITICAL: MUST read
references/cli_traps.mdBEFORE executing any CLI commands. DO NOT guess command formats.
Before running any commands, verify:
references/cli_traps.md (common traps, especially Section 7 & 8)references/cli_commands.md for correct command examples--profile, NO aliyun configure get, NO reading credential filesInterception 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:
[Configuration Target] Temporarily allow scanner IP 116.62.56.98 to access /assets/scanner/check
[Console Operation Steps]
1. Log in to WAF 3.0 Console → Protection Configuration → Whitelist
2. Click "Add Whitelist Rule"
3. Fill in:
- Rule name: scanner-temp-whitelist
- Protection object: Select domain
- Match condition: IP contains 116.62.56.98, URL equals /assets/scanner/check
- Skip rule: Specific Rule ID → 900904
4. Click "OK"
[Precautions] Delete this rule after scanning is complete, takes effect in about 1 minute
Wrong Pattern Examples (NEVER do this):
❌ Wrong 1 - Offering to execute: "I can generate the config for you, please provide INSTANCE_ID"
❌ Wrong 2 - Generating JSON: outputting rule JSON examples
❌ Wrong 3 - Saving to file: "Configuration saved to outputs/config.json"
❌ Wrong 4 - Using --profile: aliyun cmd --profile default (FORBIDDEN)
❌ Wrong 5 - Exposing credentials: aliyun configure get or 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 (Default - All paths are for WAF 3.0):
Protection Configuration → WhitelistProtection Configuration → Web Core Protection → Custom RulesProtection Configuration → Web Core Protection → CC ProtectionProtection Configuration → IP BlacklistOutput Template:
[Configuration Target] <configuration description>
[Console Operation Steps]
1. Log in to WAF 3.0 Console → left navigation: <path>
2. Click "<button>"
3. Fill in: field1=<content>, field2=<content>
4. Click "OK"
[Precautions] <risk warning>, <effective time>
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.
Before starting diagnosis, verify:
references/cli_traps.md and references/cli_commands.mdscripts/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:
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 |