{{< details >}}

  • Tier: 旗舰版
  • Offering: JihuLab.com, 私有化部署

{{< /details >}}

每次调用项目安全设置的 API 都必须进行身份验证

如果项目是私有的,并且用户不是该项目的成员,请求将返回 404 Not Found 状态码。

列出项目安全设置

列出项目的所有安全设置。

前提条件:

  • 您必须至少具有项目的开发者角色。
GET /projects/:id/security_settings
属性 类型 必须 描述
id integer 或 string 项目的 ID 或URL 编码路径
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/7/security_settings"

示例响应:

{
    "project_id": 7,
    "created_at": "2024-08-27T15:30:33.075Z",
    "updated_at": "2024-10-16T05:09:22.233Z",
    "auto_fix_container_scanning": true,
    "auto_fix_dast": true,
    "auto_fix_dependency_scanning": true,
    "auto_fix_sast": true,
    "continuous_vulnerability_scans_enabled": true,
    "container_scanning_for_registry_enabled": false,
    "secret_push_protection_enabled": true
}

更新 secret_push_protection_enabled 设置

将项目的 secret_push_protection_enabled 设置更新为提供的值。

设置为 true 以启用项目的密钥推送保护

前提条件:

  • 您必须至少具有项目的维护者角色。
属性 类型 必须 描述
id integer 或 string 经过身份验证的用户所属于的项目的 ID 或URL 编码路径
secret_push_protection_enabled boolean 更新 secret_push_protection_enabled 的值
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/7/security_settings?secret_push_protection_enabled=false"

示例响应:

{
    "project_id": 7,
    "created_at": "2024-08-27T15:30:33.075Z",
    "updated_at": "2024-10-16T05:09:22.233Z",
    "auto_fix_container_scanning": true,
    "auto_fix_dast": true,
    "auto_fix_dependency_scanning": true,
    "auto_fix_sast": true,
    "continuous_vulnerability_scans_enabled": true,
    "container_scanning_for_registry_enabled": false,
    "secret_push_protection_enabled": false
}