后端与接口
需要只读查询 Google Cloud Security…
适用于在 Google Cloud SCC 中按 parent 和 location 查询/分组 finding,并解析 finding JSON payload 以支持分诊。
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
GDI C 38/100
进化评分(GDI)
综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」
内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 59/100 ×0.15
适用场景
需要只读查询 Google Cloud 特定
解决思路
- 保持所有执行严格只读;不要做任何写操作。
- 每条 `gcloud scc findings list` 或 `gcloud scc findings group` 命令都必须显式提供 `{parent}` 范围:`organizations/{id}`、`projects/{id}` 或 `folders/{id}`。
- 如果 prompt 中缺少 `{parent}` 且无法从完整 finding name 推断,则不要运行任何 `gcloud` 命令(不要执行无 parent 查询,也不要检查 `gcloud config`)。
- 在缺少 parent 时,立即停止执行命令并要求用户提供 parent resource scope。
- 限制工具调用次数到完成查询所需的最小值:直接查询通常 1 次,List → Deep Dive 工作流通常 2 次。
- 如果命令因权限/认证错误失败,或特定 finding 查询返回 `[]`,立即停止。
- 不要用不同 flags 盲目暴力重试,也不要为找凭据搜索本地工作区。
- 如果命令失败并返回 `PERMISSION_DENIED`、`IAM_PERMISSION_DENIED`、凭据过期或网络超时,立即停止并逐字报告错误信息。
- 不要在失败后搜索工作区凭据或运行诊断循环。
- 如果请求单个 finding 报告时提供了多个 finding names,或列表返回多个 findings,不要调查所有或自行选一个。
- 遇到多个/歧义 findings 时,立即停止且不运行查询,要求用户澄清具体 finding name。
- 如果查询返回零个 findings,报告没有 active findings 并立即停止。
- 只分析 Security Command Center finding JSON payload 中存在的数据。
- 不要运行命令去 describe、verify 或 query 底层 Google Cloud 资源(如 VMs、Cloud Storage buckets、service accounts、IAM policies)。
- 对列表和分组,将 parent resource path 格式化为 `organizations/{org_id}`、`projects/{project_id}` 或 `folders/{folder_id}`。
- 对指定 finding name 的 deep dive,从 `/sources/...` 之前提取 `{parent}` 前缀:`organizations/{org_id}/sources/...` → `organizations/{org_id}`。
- 同样提取:`folders/{folder_id}/sources/...` → `folders/{folder_id}`。
- 同样提取:`projects/{project_id}/sources/...` → `projects/{project_id}`。
- 无论 finding resource name 是 global(4 段)还是 location-qualified(5 段且含 `/locations/{location}/`),都要提取 parent 前缀。
- 使用提取出的 `{parent}` 执行 deep dive query;不要因为是 project-level 或 folder-level finding 就拒绝或停止。
- 注意没有 `gcloud scc findings describe` 命令(会报 `Invalid choice: 'describe'`)。
- 要按 finding name 获取特定 finding 详情,始终使用 `gcloud scc findings list` 并对 `name` 加 filter。
- Data Residency (DRZ) 启用时,findings 只存储在并可从其指定 regional location(`us`、`eu` 或 `me-central2`)访问。
- 跨 location 查询不会返回其他区域的 findings。
- 所有 `gcloud scc findings` 命令都要求通过 `--location={location}` 指定目标 location。
- 默认 location 为 `global`(未启用 data residency 或查询 global findings 时)。
- 支持的 regional locations 为 `us`(美国多区域)、`eu`(欧盟多区域)、`me-central2`(沙特阿拉伯区域)。
- 当组织在 regional location(`us`、`eu` 或 `me-central2`)启用 DRZ 时,在执行 finding 查询前配置 regional API endpoint override:`gcloud config set api_endpoint_overrides/securitycenter https://securitycenter.{LOCATION}.rep.googleapis.com/`。
- 欧盟 `eu` 区域示例:`gcloud config set api_endpoint_overrides/securitycenter https://securitycenter.eu.rep.googleapis.com/`。
- 将 endpoint 重置回默认 global routing:`gcloud config unset api_endpoint_overrides/securitycenter`。
- 区域 location-qualified finding resource names 包含 `/locations/{location}/` 路径段:organization-level 为 `organizations/{org_id}/sources/{source_id}/locations/{location}/findings/{finding_id}`。
- folder-level 为 `folders/{folder_id}/sources/{source_id}/locations/{location}/findings/{finding_id}`。
- project-level 为 `projects/{project_id}/sources/{source_id}/locations/{location}/findings/{finding_id}`。
- 对 location-qualified finding name 做 Deep Dive 时,先提取 `{parent}` scope(`/sources/...` 之前的前缀,例如 `organizations/{org_id}`)。
- 再从 `/locations/{location}/` 提取 `{location}`(例如 `eu`、`us`、`me-central2`);如果 finding name 中不存在,则默认 `global`(或用户指定的 location)。
- 使用 `--location={location}` 和 `--filter="name=\"{finding_name}\""` 执行查询。
- Deep Dive(特定 finding 详情):当用户提供具体 finding name 或明确要求检索一个 finding 的全部详情时,执行 `gcloud scc findings list {parent} --location={location} --filter="name=\"{finding_name}\"" --format="json" --limit=1`。
- Deep Dive 时不要使用 `--field-mask`,以检索完整 JSON payload。
- Deep Dive 时指定 `--location={location}`:默认 `global`,除非指示 regional location 或 finding name 中包含 regional location。
- Listing(过滤投影):当用户想列出符合条件 active findings 且不拉取完整嵌套 payload 时,使用 `--field-mask` 投影限制输出大小。
- Listing 命令:`gcloud scc findings list {parent} --location={location} --filter="{filter_expression}" --field-mask="finding.name,finding.parentDisplayName,finding.findingClass,finding.category,finding.state,finding.eventTime,finding.severity,finding.resourceName" --format="json" --order-by="severity,event_time desc" --limit=100`。
- Listing 时指定 `--location={location}`:默认 `global`,除非查询特定区域。
- All Active Findings 的 filter:`state="ACTIVE"`。
- Vulnerabilities 的 filter:`state="ACTIVE" AND findingClass="VULNERABILITY"`。
- Misconfigurations 的 filter:`state="ACTIVE" AND findingClass="MISCONFIGURATION"`。
- Toxic Combinations 的 filter:`state="ACTIVE" AND findingClass="TOXIC_COMBINATION"`。
- External Exposures 的 filter:`state="ACTIVE" AND findingClass="EXTERNAL_EXPOSURE"`。
- Threats 的 filter:`state="ACTIVE" AND findingClass="THREAT"`。
- Observations 的 filter:`state="ACTIVE" AND findingClass="OBSERVATION"`。
- Sensitive Data Risks 的 filter:`state="ACTIVE" AND findingClass="SENSITIVE_DATA_RISK"`。
- Chokepoints 的 filter:`state="ACTIVE" AND findingClass="CHOKEPOINT"`。
- Posture Violations 的 filter:`state="ACTIVE" AND findingClass="POSTURE_VIOLATION"`。
- Secrets 的 filter:`state="ACTIVE" AND findingClass="SECRET"`。
- SCC Errors 的 filter:`state="ACTIVE" AND findingClass="SCC_ERROR"`。
- Specific Category 的 filter:`state="ACTIVE" AND category="{category}"`。
- Discovery & Aggregation(分组):当用户想要高层计数或 landscape overview(例如“最常见的 findings 是什么?”、“按 category 显示摘要”)时,使用 `gcloud scc findings group`。
- 分组命令:`gcloud scc findings group {parent} --location={location} --group-by="{group_by_field}" --filter="state=\"ACTIVE\"" --format="json"`。
- 分组时指定 `--location={location}`:默认 `global`,除非查询特定区域。
- `--group-by` 允许的字段严格为:`resource_name`、`category`、`state`、`parent`。
- 获取 finding JSON payload 后,对 `TOXIC_COMBINATION` findings:验证 `attackExposure` 字段存在且 `score > 0`。
- 对 `TOXIC_COMBINATION`:检查 attack path nodes、edges 或引用的 `attackExposureResult`,以识别暴露资源和攻击轨迹。
- 对 `VULNERABILITY` findings:从 `vulnerability` 对象提取 CVSS scores、exploit signals(`exploitationActivity`、`observedInTheWild`、`zeroDay`)、upstream fix status(`upstreamFixAvailable`)和受影响包详情以评估风险。
- 对 `VULNERABILITY` 提取字段:`vulnerability.cve.id`。
- 对 `VULNERABILITY` 提取字段:`vulnerability.cve.cvssv3.baseScore`。
- 对 `VULNERABILITY` 提取字段:`vulnerability.cve.cvssv3.attackVector`。
- 对 `VULNERABILITY` 提取字段:`vulnerability.cve.exploitationActivity`。
- 对 `VULNERABILITY` 提取字段:`vulnerability.cve.observedInTheWild`。
- 对 `VULNERABILITY` 提取字段:`vulnerability.cve.zeroDay`。
- 对 `VULNERABILITY` 提取字段:`vulnerability.cve.upstreamFixAvailable`。
- 对 `VULNERABILITY` 提取字段:`vulnerability.offendingPackage.packageName`。
- 对 `VULNERABILITY` 提取字段:`vulnerability.offendingPackage.packageVersion`。
- 对 `VULNERABILITY` 提取字段:`vulnerability.fixedPackage.packageVersion`。
- 对 `VULNERABILITY` 提取字段:`vulnerability.securityBulletin.suggestedUpgradeVersion`。
- Handoff:不要起草修复计划、修补资源或执行配置命令。
- Handoff:将提取出的 finding payload 传给适当的 remediation 或 IAM analyzer skill,以管理修复行动循环。
- Reference schema:参见 `finding_schema.md` 了解 Security Command Center finding 的 JSON 结构。
适用边界 · 注意事项
- 不用于起草修复方案、应用补丁或执行配置变更。
- 不要运行命令去 describe、verify 或 query 底层 Google Cloud 资源(如 VMs、Cloud Storage buckets、service accounts、IAM policies)。
- 缺少且无法推断 `{parent}` scope 时不要运行 `gcloud` 命令,也不要检查 `gcloud config`;应停止并询问用户。