TestConnectivity - AI Red Teaming 连通性测试

更新时间:
复制 MD 格式

AI Red Teaming,测试目标的网络连通性和认证有效性

接口说明

测试指定攻击目标(Target)的网络连通性与认证有效性。

调用模式为异步轮询:

  • 首次调用(不传 CheckId):立即返回 CheckId 和 VerifyStatus=checking,后台异步执行真实测试,最长 60 秒。

  • 后续调用(传入首次返回的 CheckId):查询该 CheckId 对应的最新状态,可能为 checking、verified 或 failed。

  • 建议以 2 秒间隔轮询,最长轮询 60 秒;CheckId 过期后返回 failed,VerifyMessage 为 "check expired, please retry"。

参数使用二选一:

  • 方式 A:仅传 TargetId,从已保存的目标配置中读取 Endpoint、ApiKey、ModelName、ConnectionMethod、ConnectionConfig,忽略请求中同名参数。

  • 方式 B:不传 TargetId,直接在请求中提供上述五个连接参数。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

当前API暂无授权信息透出。

请求语法

POST  HTTP/1.1

请求参数

名称

类型

必填

描述

示例值

TargetId

string

否

攻击目标的唯一标识。传入后系统从目标配置中读取 Endpoint、ApiKey、ModelName、ConnectionMethod、ConnectionConfig,忽略请求中同名参数;不传时需在请求中直接提供连接参数。

target-abc123def4567

Endpoint

string

否

目标模型服务的 HTTP/HTTPS 端点地址。TargetId 为空时必填。

https://dashscope.aliyuncs.com/compatible-mode/v1

ApiKey

string

否

目标模型服务的 API 密钥,用于向 Endpoint 认证。传入 TargetId 时系统从已加密保存的目标配置读取。TargetId 为空时必填。请通过 HTTPS 传输,避免在日志、URL 或客户端代码中明文暴露。

sk-abcd1234****

ModelName

string

否

目标模型的名称。ConnectionMethod=openai 时填 OpenAI 兼容协议下的模型 ID;ConnectionMethod=anthropic 时填 Anthropic Messages API 的模型 ID。 如果扫描对象为模型,且 TargetId 为空时必填。

qwen-flash

ConnectionMethod

string

否

目标服务的连接协议类型。系统按此选择对应的协议适配器发起测试。默认 openai。

枚举值:

  • enterprise_relay :

    企业内网 Agent 接入(轮询拉取模式)

  • openai :

    OpenAI 兼容协议

  • anthropic :

    Anthropic Messages API 协议

openai

ConnectionConfig

string

否

连接高级配置,JSON 字符串格式。常见字段:authType(认证类型,custom_header=自定义请求头认证、none=无认证)、customAuthHeaderName(自定义认证请求头名称,如 X-API-Key)、requestHeaders(附加的 HTTP 请求头键值对)。

常见 provider 配置模板({{prompt}} 为提问占位符,按实际服务替换;authType=bearer 时 token 由 ApiKey 注入,模板中不含凭据):

  • Bailian:{"httpMethod":"POST","authType":"bearer","timeoutMs":30000,"requestTemplate":"{"input":{"prompt":"{{prompt}}"},"parameters":{"incremental_output":true},"debug":{}}","messageJsonPath":"$.output.text","requestHeaders":"{"X-DashScope-SSE": "enable" }","stream":true,"customAuthHeaderName":""}

  • PAI:{"httpMethod":"POST","authType":"bearer","timeoutMs":60000,"requestTemplate":"{"inputs":{"question":"{{prompt}}","chat_history":[]},"stream":true}","messageJsonPath":"$.outputs.answer","requestHeaders":"","stream":true,"customAuthHeaderName":""}

  • Dify:{"httpMethod":"POST","authType":"bearer","timeoutMs":30000,"requestTemplate":"{"inputs":{},"query":"{{prompt}}","response_mode":"streaming","conversation_id":"","user":"scanner"}","messageJsonPath":"$.answer","requestHeaders":"","stream":true,"customAuthHeaderName":""}

  • AgentRun:{"httpMethod":"POST","authType":"custom_header","timeoutMs":30000,"requestTemplate":"{"messages":[{"role":"user","content":"{{prompt}}"}],"stream":true}","messageJsonPath":"$.choices[0].delta.content","requestHeaders":"","customAuthHeaderName":"X-API-Key","stream":true}

  • AgentKit:{"httpMethod":"POST","authType":"bearer","timeoutMs":30000,"requestTemplate":"{"messages":[{"role":"user","content":"{{prompt}}"}]}","messageJsonPath":"$.content.parts[0].text","requestHeaders":"","stream":true,"customAuthHeaderName":""}

{\"httpMethod\":\"POST\",\"authType\":\"bearer\",\"timeoutMs\":30000,\"requestTemplate\":\"{\\\"input\\\":{\\\"prompt\\\":\\\"{{prompt}}\\\"},\\\"parameters\\\":{\\\"incremental_output\\\":true},\\\"debug\\\":{}}\",\"messageJsonPath\":\"$.output.text\",\"requestHeaders\":\"{\\\"X-DashScope-SSE\\\": \\\"enable\\\" }\",\"stream\":true,\"customAuthHeaderName\":\"\"}

CheckId

string

否

连通性测试的追踪标识。首次调用不传,由系统生成并在响应中返回;后续调用传入该值查询对应测试的最新状态。

conn-a1b2c3d4e5f67890

返回参数

名称

类型

描述

示例值

object

Data

object

连通性测试的结果详情。

CheckId

string

本次连通性测试的追踪标识。首次调用由系统生成;轮询调用时与请求中的 CheckId 一致。

conn-a1b2c3d4e5f67890

LatencyMs

integer

目标服务响应的端到端延迟,单位毫秒。VerifyStatus=checking 时可能为 0 或不返回。

1200

VerifyMessage

string

验证结果的详细信息。VerifyStatus=verified 时为目标服务返回的响应内容片段;failed 时为错误原因描述(如认证失败、超时、空响应等)。

连通性验证成功

VerifyStatus

string

连通性验证的当前状态。

枚举值:

  • checking :

    测试进行中

  • verified :

    连通性验证通过

  • failed :

    连通性验证失败

verified

RequestId

string

本次请求的唯一标识,用于问题排查与日志追踪。

1EBD0C05-6C1F-4C95-9C63-B7AB7B5A9C8E

示例

正常返回示例

JSON格式

{
  "Data": {
    "CheckId": "conn-a1b2c3d4e5f67890",
    "LatencyMs": 1200,
    "VerifyMessage": "连通性验证成功",
    "VerifyStatus": "verified"
  },
  "RequestId": "1EBD0C05-6C1F-4C95-9C63-B7AB7B5A9C8E"
}

错误码

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情。