SAS Overview Data Query
Retrieves the 5 core modules of the Security Center (SAS) overview dashboard:
- 1. Security Overview — score, fixed vulns, baseline risk, handled alerts
- Usage Info — service days, asset scale, uninstalled clients
- Security Operations — risk governance (AI risk, CSPM, key config, system vulns), security protection (WAF blocks), security response
- Asset Risk Trend — host/container/cloud product risk ratios + trend chart
- Billing & Subscription — post-pay switches, subscription validity, bills
Execution Scope: Each module and data item can be queried independently.
Match the scope to the user's request:
- - Single data item — e.g., "What is my security score?" → only command 1a
- Single module — e.g., "Show asset risk trend" → all of Module 4
- Full overview — e.g., "SAS overview" → all 5 modules
Architecture: INLINECODE0
Prerequisites
Pre-check: Aliyun CLI >= 3.3.1 required
Run aliyun version to verify >= 3.3.1. If not installed or version too low,
see references/cli-installation-guide.md for installation instructions.
Then run aliyun configure set --auto-plugin-install true to enable automatic plugin installation.
Install required CLI plugins:
CODEBLOCK0
Pre-check: Alibaba Cloud Credentials Required
Security Rules:
- - NEVER read, echo, or print AK/SK values (e.g.,
echo $ALIBABA_CLOUD_ACCESS_KEY_ID is FORBIDDEN) - NEVER ask the user to input AK/SK directly in the conversation or command line
- NEVER use
aliyun configure set with literal credential values - ONLY use
aliyun configure list to check credential status
> aliyun configure list
>
Check the output for a valid profile (AK, STS, or OAuth identity).
If no valid profile exists, STOP here.
- 1. Obtain credentials from Alibaba Cloud Console
- Configure credentials outside of this session (via
aliyun configure in terminal or environment variables in shell profile) - Return and re-run after
aliyun configure list shows a valid profile
Parameters
IMPORTANT: Parameter Confirmation — Before executing any command or API call,
ALL user-customizable parameters (e.g., RegionId, WAF InstanceId, BillingCycle, etc.)
MUST be confirmed with the user. Do NOT assume or use default values without explicit user approval.
| Parameter | Required | Description | Default |
|---|
| Regions | Yes | SAS regions to aggregate data from | INLINECODE9 , INLINECODE10 |
| WAF Instance ID |
Auto-fetched | Auto-fetched via WAF
DescribeInstance for
DescribeFlowChart | Auto |
| Billing Cycle | Only for billing | Billing month in
YYYY-MM format | Current month |
| Time Range | No | Days of history for score/trend queries |
7 (last 7 days) |
RAM Permissions
See references/ram-policies.md for the full RAM policy JSON.
Required: AliyunYundunSASReadOnlyAccess, AliyunWAFReadOnlyAccess, AliyunBSSReadOnlyAccess.
Core Workflow
Based on the user's query, execute the relevant module(s) below. Each module — and each data item within a module — can be executed independently. For APIs marked multi-region, always query both cn-shanghai and ap-southeast-1, then sum the results.
Module 1: Security Overview
CODEBLOCK2
Module 2: Usage Info
CODEBLOCK3
Module 3: Security Operations
3a. Risk Governance (region-agnostic, single API call)
CODEBLOCK4
3b. Security Protection — WAF Blocks (multi-region, two-step)
CODEBLOCK5
3c. Security Response
CODEBLOCK6
Module 4: Asset Risk Trend
CODEBLOCK7
Module 5: Billing & Subscription
CODEBLOCK8
Product Code Mapping
| Product Name | Code | Status Values |
|---|
| Host and Container Security | INLINECODE20 | INLINECODE21 : Enabled, 0: Disabled |
| Vulnerability Fixing |
VUL |
1: Enabled,
0: Disabled |
| CSPM |
CSPM |
1: Enabled,
0: Disabled |
| Agentic SOC |
CTDR |
1: Enabled,
0: Disabled |
| Agentless Detection |
AGENTLESS |
1: Enabled,
0: Disabled |
| Serverless Asset Protection |
SERVERLESS |
1: Enabled,
0: Disabled |
| Application Protection |
RASP |
1: Enabled,
0: Disabled |
| Malicious File Detection |
SDK |
1: Enabled,
0: Disabled |
| Log Management |
CTDR_STORAGE |
1: Enabled,
0: Disabled |
| Anti-ransomware |
ANTI_RANSOMWARE |
1: Enabled,
0: Disabled |
Data Processing Rules
- 1. Multi-region aggregation: APIs requiring regions must query
cn-shanghai + ap-southeast-1 separately, then sum the numeric results. - Timestamps: SAS APIs use millisecond timestamps. WAF APIs use second timestamps.
- PostPayModuleSwitch: Is a JSON string — must
JSON.parse() / json.loads() before reading. - Score extraction: Use
Score field from DescribeSecureSuggestion response as current score. Note: DescribeScreenScoreThread is currently unavailable (CalType not supported); once supported, switch to using the last element of Data.SocreThread[] as current score and the full list as historical trend. - N/A fields: Security Response Events have no data — display "N/A".
- Timestamp formatting: Convert ms timestamps to
YYYY-MM-DD HH:mm:ss for display.
Success Verification
See references/verification-method.md for step-by-step verification commands.
Cleanup
This skill is read-only (query operations only). No resources are created, so no cleanup is needed.
Best Practices
- 1. Always query both
cn-shanghai and ap-southeast-1 for multi-region APIs before aggregating. - Cache the
DescribeVersionConfig response — it is used by both Module 2 and Module 5. - Use
--cli-query (JMESPath) to extract specific fields and reduce output noise. - Set
--page-size 1 when only TotalCount is needed (e.g., ListUninstallAegisMachines). - WAF
DescribeFlowChart requires a valid WAF instance ID — auto-fetch via DescribeInstance first; query both cn-shanghai and ap-southeast-1. - Billing queries (
QueryBill) require --region — try each region (cn-shanghai, ap-southeast-1) in turn; skip any region that returns a permission error. - All timestamps returned by SAS are in milliseconds — divide by 1000 for human-readable conversion.
Reference Links
Required RAM permissions and policies |
|
references/verification-method.md | Step-by-step verification commands |
|
references/acceptance-criteria.md | Correct/incorrect CLI patterns |
|
references/cli-installation-guide.md | CLI installation guide |
|
overview-sop.md | Original SOP document with full data mapping |
SAS概览数据查询
检索安全中心(SAS)概览仪表盘的5个核心模块:
- 1. 安全概览 — 评分、已修复漏洞、基线风险、已处理告警
- 使用信息 — 服务天数、资产规模、未安装客户端
- 安全运营 — 风险治理(AI风险、CSPM、关键配置、系统漏洞)、安全防护(WAF拦截)、安全响应
- 资产风险趋势 — 主机/容器/云产品风险比率 + 趋势图
- 计费与订阅 — 后付费开关、订阅有效期、账单
执行范围:每个模块和数据项均可独立查询。
根据用户请求匹配范围:
- - 单个数据项 — 例如“我的安全评分是多少?” → 仅执行命令1a
- 单个模块 — 例如“显示资产风险趋势” → 模块4的全部内容
- 完整概览 — 例如“SAS概览” → 全部5个模块
架构:SAS + WAF + BssOpenApi
前提条件
预检查:需要Aliyun CLI >= 3.3.1
运行 aliyun version 验证版本 >= 3.3.1。如果未安装或版本过低,
请参阅 references/cli-installation-guide.md 获取安装说明。
然后运行 aliyun configure set --auto-plugin-install true 启用自动插件安装。
安装所需的CLI插件:
bash
aliyun plugin install --names aliyun-cli-sas aliyun-cli-waf-openapi aliyun-cli-bssopenapi
预检查:需要阿里云凭证
安全规则:
- - 切勿读取、回显或打印AK/SK值(例如,echo $ALIBABACLOUDACCESSKEYID 是禁止的)
- 切勿要求用户在对话或命令行中直接输入AK/SK
- 切勿使用字面凭证值执行 aliyun configure set
- 仅使用 aliyun configure list 检查凭证状态
bash
aliyun configure list
检查输出中是否存在有效的配置文件(AK、STS或OAuth身份)。
如果没有有效的配置文件,请在此处停止。
- 1. 从阿里云控制台获取凭证
- 在此会话之外配置凭证(通过终端中的 aliyun configure 或shell配置文件中的环境变量)
- 在 aliyun configure list 显示有效配置文件后返回并重新运行
参数
重要提示:参数确认 — 在执行任何命令或API调用之前,
所有用户可自定义的参数(例如,RegionId、WAF InstanceId、BillingCycle等)
必须与用户确认。未经用户明确批准,不得假设或使用默认值。
| 参数 | 必需 | 描述 | 默认值 |
|---|
| 区域 | 是 | 要聚合数据的SAS区域 | cn-shanghai, ap-southeast-1 |
| WAF实例ID |
自动获取 | 通过WAF DescribeInstance 自动获取,用于 DescribeFlowChart | 自动 |
| 计费周期 | 仅用于计费 | 计费月份,格式为 YYYY-MM | 当前月份 |
| 时间范围 | 否 | 评分/趋势查询的历史天数 | 7(最近7天) |
RAM权限
请参阅 references/ram-policies.md 获取完整的RAM策略JSON。
所需权限:AliyunYundunSASReadOnlyAccess、AliyunWAFReadOnlyAccess、AliyunBSSReadOnlyAccess。
核心工作流
根据用户的查询,执行以下相关模块。每个模块——以及模块内的每个数据项——都可以独立执行。对于标记为多区域的API,始终查询 cn-shanghai 和 ap-southeast-1,然后对结果求和。
模块1:安全概览
bash
1a. 安全评分(区域无关)
aliyun sas describe-secure-suggestion --cal-type home
securityscore --user-agent AlibabaCloud-Agent-Skills
提取:响应中的Score字段作为当前安全评分
# 注意:DescribeScreenScoreThread当前不可用(不支持CalType)。
一旦支持,切换到以下命令获取评分 + 历史趋势:
START=$(python3 -c import time; print(int((time.time()-864007)1000)))
END=$(python3 -c import time; print(int(time.time()*1000)))
aliyun sas describe-screen-score-thread \
--cal-type homesecurityscore \
--start-time $START --end-time $END \
--user-agent AlibabaCloud-Agent-Skills
提取:Data.SocreThread[-1] = 当前评分,完整SocreThread列表 = 历史趋势
1b. 已修复漏洞(多区域:对FixTotal求和)
aliyun sas describe-vul-fix-statistics --region cn-shanghai --user-agent AlibabaCloud-Agent-Skills
aliyun sas describe-vul-fix-statistics --region ap-southeast-1 --user-agent AlibabaCloud-Agent-Skills
1c. 基线风险统计(多区域:对每个Summary字段求和)
aliyun sas get-check-risk-statistics --region cn-shanghai --user-agent AlibabaCloud-Agent-Skills
aliyun sas get-check-risk-statistics --region ap-southeast-1 --user-agent AlibabaCloud-Agent-Skills
提取:Summary.RiskCheckCnt, Summary.RiskWarningCnt,
Summary.HandledCheckTotal, Summary.HandledCheckToday
对每个字段跨区域求和
1d. 已处理告警(多区域:对SuspiciousDealtCount求和)
aliyun sas get-defence-count --region cn-shanghai --user-agent AlibabaCloud-Agent-Skills
aliyun sas get-defence-count --region ap-southeast-1 --user-agent AlibabaCloud-Agent-Skills
模块2:使用信息
bash
2a. 服务时长 + 订阅(区域无关)
aliyun sas describe-version-config --user-agent AlibabaCloud-Agent-Skills
首先检查IsPaidUser:
IsPaidUser == true → 提取CreateTime,计算(当前时间 - CreateTime)作为天数
IsPaidUser == false → 服务时长不适用,显示N/A
提取:ReleaseTime → 订阅到期时间(仅预付费)
2b. 主机资产信息(多区域:对TotalCount和Cores求和)
aliyun sas describe-cloud-center-instances \
--region cn-shanghai --machine-types ecs --current-page 1 --page-size 20 \
--user-agent AlibabaCloud-Agent-Skills
aliyun sas describe-cloud-center-instances \
--region ap-southeast-1 --machine-types ecs --current-page 1 --page-size 20 \
--user-agent AlibabaCloud-Agent-Skills
提取:PageInfo.TotalCount(跨区域求和)作为主机数量
提取:对所有实例的Cores字段求和作为总核心数
如果用户请求,可选择列出主机详情
2c. 未安装客户端(多区域:对TotalCount求和)
aliyun sas list-uninstall-aegis-machines --region cn-shanghai --current-page 1 --page-size 1 --user-agent AlibabaCloud-Agent-Skills
aliyun sas list-uninstall-aegis-machines --region ap-southeast-1 --current-page 1 --page-size 1 --user-agent AlibabaCloud-Agent-Skills
模块3:安全运营
3a. 风险治理(区域无关,单次API调用)
bash
aliyun sas describe-secure-suggestion --cal-type homesecurityscore --user-agent AlibabaCloud-Agent-Skills
按SuggestType处理Suggestions[]:
SSAIRISK → AI风险(SubType不固定,例如SSIAISPMRISK;对未知SubType分析Description)
按区域聚合riskCount
SSSASCLOUD_HC → CSPM风险(按高/中/低和区域聚合)
云:SSISASCLOUDHCHIGH / MEDIUM / LOW
主机:SSISASHOSTHCHIGH / MEDIUM / LOW
SSKEYCONFIG → 关键配置(SubType不固定;对未知SubType