正式なドキュメントは英語版であり、この日本語訳はAI支援翻訳により作成された参考用のものです。日本語訳の一部の内容は人間によるレビューがまだ行われていないため、翻訳のタイミングにより英語版との間に差異が生じることがあります。最新かつ正確な情報については、英語版をご参照ください。

脆弱性API

  • プラン: Ultimate
  • 提供形態: GitLab.com、GitLab Self-Managed、GitLab Dedicated

以前の脆弱性APIは、Vulnerability Findings APIに名前が変更され、そのドキュメントは別の場所に移動されました。このドキュメントでは、脆弱性へのアクセスを提供する新しい脆弱性APIについて説明します。

脆弱性へのすべてのAPIコールは、認証されている必要があります。

認証済みユーザーに脆弱性レポートを表示する権限がない場合、このリクエストは403 Forbiddenステータスコードを返します。

このAPIは非推奨となる過程にあり、不安定と見なされています。レスポンスペイロードは、GitLabのリリース間で変更または破損する可能性があります。代わりにGraphQL APIを使用します。詳細については、GraphQLの例を参照してください。

脆弱性を取得する

指定された脆弱性を取得します。

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
}

脆弱性REST APIをGraphQLに置き換える

脆弱性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": []
    }
  }
}