脆弱性API
- プラン: Ultimate
- 提供形態: GitLab.com、GitLab Self-Managed、GitLab Dedicated
このAPIは、非推奨になる過程にあり、不安定であると見なされています。レスポンスペイロードは、GitLabのリリース全体で変更または破損する可能性があります。代わりにGraphQL APIを使用してください。詳細については、GraphQLの例を参照してください。
脆弱性に対するすべてのAPIコールは認証されている必要があります。
認証済みユーザーに脆弱性レポートを表示する権限がない場合、このリクエストは403 Forbiddenステータスコードを返します。
単一の脆弱性
単一の脆弱性を取得します
GET /vulnerabilities/:id| 属性 | 型 | 必須 | 説明 |
|---|---|---|---|
id | 整数または文字列 | はい | 取得する脆弱性のID |
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/vulnerabilities/1"レスポンス例:
{
"id": 1,
"title": "Predictable pseudorandom number generator",
"description": null,
"state": "opened",
"severity": "medium",
"confidence": "medium",
"report_type": "sast",
"project": {
"id": 32,
"name": "security-reports",
"full_path": "/gitlab-examples/security/security-reports",
"full_name": "gitlab-examples / security / security-reports"
},
"author_id": 1,
"closed_by_id": null,
"created_at": "2019-10-13T15:08:40.219Z",
"updated_at": "2019-10-13T15:09:40.382Z",
"closed_at": null
}脆弱性の確認
特定の脆弱性を確認します。脆弱性が既に確認されている場合は、ステータスコード304を返します。
認証済みユーザーに脆弱性ステータスを変更する権限がない場合、このリクエストは403ステータスコードになります。
POST /vulnerabilities/:id/confirm| 属性 | 型 | 必須 | 説明 |
|---|---|---|---|
id | 整数または文字列 | はい | 確認する脆弱性のID |
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/vulnerabilities/5/confirm"レスポンス例:
{
"id": 2,
"title": "Predictable pseudorandom number generator",
"description": null,
"state": "confirmed",
"severity": "medium",
"confidence": "medium",
"report_type": "sast",
"project": {
"id": 32,
"name": "security-reports",
"full_path": "/gitlab-examples/security/security-reports",
"full_name": "gitlab-examples / security / security-reports"
},
"author_id": 1,
"closed_by_id": null,
"created_at": "2019-10-13T15:08:40.219Z",
"updated_at": "2019-10-13T15:09:40.382Z",
"closed_at": null
}脆弱性の解決
特定の脆弱性を解決します。脆弱性が既に解決されている場合は、ステータスコード304を返します。
認証済みユーザーに脆弱性ステータスを変更する権限がない場合、このリクエストは403ステータスコードになります。
POST /vulnerabilities/:id/resolve| 属性 | 型 | 必須 | 説明 |
|---|---|---|---|
id | 整数または文字列 | はい | 解決する脆弱性のID |
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/vulnerabilities/5/resolve"レスポンス例:
{
"id": 2,
"title": "Predictable pseudorandom number generator",
"description": null,
"state": "resolved",
"severity": "medium",
"confidence": "medium",
"report_type": "sast",
"project": {
"id": 32,
"name": "security-reports",
"full_path": "/gitlab-examples/security/security-reports",
"full_name": "gitlab-examples / security / security-reports"
},
"author_id": 1,
"closed_by_id": null,
"created_at": "2019-10-13T15:08:40.219Z",
"updated_at": "2019-10-13T15:09:40.382Z",
"closed_at": null
}脆弱性の無視
特定の脆弱性を無視します。脆弱性が既に無視されている場合は、ステータスコード304を返します。
認証済みユーザーに脆弱性ステータスを変更する権限がない場合、このリクエストは403ステータスコードになります。
POST /vulnerabilities/:id/dismiss| 属性 | 型 | 必須 | 説明 |
|---|---|---|---|
id | 整数または文字列 | はい | 無視する脆弱性のID |
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/vulnerabilities/5/dismiss"レスポンス例:
{
"id": 2,
"title": "Predictable pseudorandom number generator",
"description": null,
"state": "closed",
"severity": "medium",
"confidence": "medium",
"report_type": "sast",
"project": {
"id": 32,
"name": "security-reports",
"full_path": "/gitlab-examples/security/security-reports",
"full_name": "gitlab-examples / security / security-reports"
},
"author_id": 1,
"closed_by_id": null,
"created_at": "2019-10-13T15:08:40.219Z",
"updated_at": "2019-10-13T15:09:40.382Z",
"closed_at": null
}検出された状態への脆弱性の復元
特定の脆弱性を検出された状態に戻します。脆弱性が既に検出された状態にある場合は、ステータスコード304を返します。
認証済みユーザーに脆弱性ステータスを変更する権限がない場合、このリクエストは403ステータスコードになります。
POST /vulnerabilities/:id/revert| 属性 | 型 | 必須 | 説明 |
|---|---|---|---|
id | 整数または文字列 | はい | 検出された状態に戻す脆弱性のID |
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/vulnerabilities/5/revert"レスポンス例:
{
"id": 2,
"title": "Predictable pseudorandom number generator",
"description": null,
"state": "detected",
"severity": "medium",
"confidence": "medium",
"report_type": "sast",
"project": {
"id": 32,
"name": "security-reports",
"full_path": "/gitlab-examples/security/security-reports",
"full_name": "gitlab-examples / security / security-reports"
},
"author_id": 1,
"closed_by_id": null,
"created_at": "2019-10-13T15:08:40.219Z",
"updated_at": "2019-10-13T15:09:40.382Z",
"closed_at": null
}GraphQLによる脆弱性REST APIの置き換え
脆弱性REST APIエンドポイントの今後の非推奨に備えて、以下の例を使用して、GraphQL APIで同等の操作を実行します。
GraphQL - 単一の脆弱性
Query.vulnerabilityを使用してください。
{
vulnerability(id: "gid://gitlab/Vulnerability/20345379") {
title
description
state
severity
reportType
project {
id
name
fullPath
}
detectedAt
confirmedAt
resolvedAt
resolvedBy {
id
username
}
}
}レスポンス例:
{
"data": {
"vulnerability": {
"title": "Improper Input Validation in railties",
"description": "A remote code execution vulnerability in development mode Rails beta3 can allow an attacker to guess the automatically generated development mode secret token. This secret token can be used in combination with other Rails internals to escalate to a remote code execution exploit.",
"state": "RESOLVED",
"severity": "CRITICAL",
"reportType": "DEPENDENCY_SCANNING",
"project": {
"id": "gid://gitlab/Project/6102100",
"name": "security-reports",
"fullPath": "gitlab-examples/security/security-reports"
},
"detectedAt": "2021-10-14T03:13:41Z",
"confirmedAt": "2021-12-14T01:45:56Z",
"resolvedAt": "2021-12-14T01:45:59Z",
"resolvedBy": {
"id": "gid://gitlab/User/480804",
"username": "thiagocsf"
}
}
}
}GraphQL - 脆弱性の確認
Mutation.vulnerabilityConfirmを使用してください。
mutation {
vulnerabilityConfirm(input: { id: "gid://gitlab/Vulnerability/23577695"}) {
vulnerability {
state
}
errors
}
}レスポンス例:
{
"data": {
"vulnerabilityConfirm": {
"vulnerability": {
"state": "CONFIRMED"
},
"errors": []
}
}
}GraphQL - 脆弱性の解決
Mutation.vulnerabilityResolveを使用してください。
mutation {
vulnerabilityResolve(input: { id: "gid://gitlab/Vulnerability/23577695"}) {
vulnerability {
state
}
errors
}
}レスポンス例:
{
"data": {
"vulnerabilityConfirm": {
"vulnerability": {
"state": "RESOLVED"
},
"errors": []
}
}
}GraphQL - 脆弱性の無視
Mutation.vulnerabilityDismissを使用してください。
mutation {
vulnerabilityDismiss(input: { id: "gid://gitlab/Vulnerability/23577695"}) {
vulnerability {
state
}
errors
}
}レスポンス例:
{
"data": {
"vulnerabilityConfirm": {
"vulnerability": {
"state": "DISMISSED"
},
"errors": []
}
}
}GraphQL - 検出された状態への脆弱性の復元
Mutation.vulnerabilityRevertToDetectedを使用してください。
mutation {
vulnerabilityRevertToDetected(input: { id: "gid://gitlab/Vulnerability/20345379"}) {
vulnerability {
state
}
errors
}
}レスポンス例:
{
"data": {
"vulnerabilityConfirm": {
"vulnerability": {
"state": "DETECTED"
},
"errors": []
}
}
}