Skip to content

Feat/security commands - #196

Open
cxy01313369 wants to merge 2 commits into
modelstudioai:mainfrom
cxy01313369:feat/security-commands
Open

Feat/security commands#196
cxy01313369 wants to merge 2 commits into
modelstudioai:mainfrom
cxy01313369:feat/security-commands

Conversation

@cxy01313369

Copy link
Copy Markdown

What

Adds two read-only Agent Security Center (AgentStudio) commands:

  • bl security overview — protection overview (last 24h): capabilities, protection toggles (+ asset counts), detection cards (content safety / file scan / skill scan).
  • bl security alerts — alert list with risk-level / asset-type / status / vendor / pagination / sorting filters.

Why

Brings the Agent security posture to the terminal and AI agents, alongside the existing knowledge / managed-agent AgentStudio command families.

How it fits the repo

  • Host: reuses the per-workspace AgentStudio scheme (agentStudioHost, same shape as ragEndpoint). Derived from --workspace-id, or overridden when --base-url / auth login --base-url points at a non-DashScope origin — mirrors the managed-agent login flow. Absolute URL + Client Bearer injection, so the model-domain base_url never leaks in.
  • Envelope: parseSecurityBody tolerates the shapes the backend serves today — bare payload (REST), legacy {success,data}, and the console-gateway Zelda DataV2 double-envelope; detection cards accept snake_case and camelCase. 12000092 → AUTH; unrecognized shapes surface a truncated body for diagnosis.
  • Conventions: auth:"apiKey"; shared text/json/--quiet/--dry-run contract; enum flags via choices (fast-fail, exit 2, zero requests); reuses resolveWorkspaceId; bilingual en-US/zh-CN help; no single-letter identifiers.

Files

  • core: client/security.ts, client/endpoints.ts, types/security.ts
  • commands: commands/security/{overview,alerts,shared}.ts + registration (commands/src/index.ts, cli/src/commands.ts)
  • tests: core/tests/security-envelope.test.ts, commands/tests/e2e/security.e2e.test.ts (+ topic-routes.ts)
  • skills: regenerated bailian-cli reference for the new security group

Testing

  • pnpm check clean. Unit security-envelope.test.ts: 7 passed. E2E security.e2e.test.ts: 10 passed / 2 skipped (live-gated).
  • Verified live on pre-release (trial.cn-beijing.pre-maas.aliyuncs.com): overview renders banner / toggles (with counts) / detection cards; alerts returns stats + list.

- 重构security模块,新增parseSecurityBody函数用于解析双层DataV2信封格式
- 支持legacy平面信封和裸数据直接返回,统一错误抛出处理
- securityGet调用parseSecurityBody解析响应体,保证兼容性和错误提示准确
- securityOverview中检测卡片支持REST接口snake_case及console-gateway camelCase字段
- SCAN_CARDS数据结构更新,支持多个字段键以适配不同来源
- SecurityToggle新增count字段,支持展示对应资产数量
- 完善安全响应体测试用例,涵盖多种信封格式及异常场景
- 优化展示安全检测开关状态时,增加对应数量显示信息
- 移除不再需要的SecurityEnvelope接口定义,精简代码逻辑
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant