취약점 발견 API

Tier: Ultimate Offering: GitLab.com, Self-Managed, GitLab Dedicated
note
이 API 리소스는 취약점(Vulnerabilities)을 취약점 오브젝트를 위해 예약하고 있기 때문에 취약점을 취약점 발견(Vulnerability Findings)으로 이름이 변경되었습니다. 기존 취약점 API와의 호환성을 유지하기 위해 vulnerabilities URL 부분을 vulnerability_findings로 변경하십시오.

취약점 발견에 대한 모든 API 호출은 인증되어야 합니다.

사용자가 프로젝트 보안 대시보드를 사용할 수 있는 권한이 없으면 이 프로젝트의 취약점 발견에 대한 모든 요청은 403 금지됨 상태 코드를 반환합니다.

caution
이 API는 폐기 중이며 불안정한 것으로 간주됩니다. 응답 페이로드는 GitLab 릴리스 간에 변경 또는 파손될 수 있습니다. 대신 GraphQL API를 사용하십시오. 자세한 내용은 GraphQL 예제를 참조하십시오.

취약점 발견 페이징

기본적으로 GET 요청은 API 결과가 페이지로 묶이기 때문에 한 번에 20개의 결과를 반환합니다.

pagination에서 자세히 알아보세요.

프로젝트 취약점 발견 디렉터리

프로젝트의 모든 취약점 발견을 나열합니다.

GET /projects/:id/vulnerability_findings
GET /projects/:id/vulnerability_findings?report_type=sast
GET /projects/:id/vulnerability_findings?report_type=container_scanning
GET /projects/:id/vulnerability_findings?report_type=sast,dast
GET /projects/:id/vulnerability_findings?scope=all
GET /projects/:id/vulnerability_findings?scope=dismissed
GET /projects/:id/vulnerability_findings?severity=high
GET /projects/:id/vulnerability_findings?confidence=unknown,experimental
GET /projects/:id/vulnerability_findings?pipeline_id=42
속성 유형 필수 설명
id integer/string yes 인증된 사용자가 회원인 프로젝트의 ID 또는 URL 인코딩된 경로.
report_type string array no 지정된 보고서 유형에 속한 취약점 발견을 반환합니다. 유효한 값: sast, dast, dependency_scanning, 또는 container_scanning. 기본값은 모두입니다.
scope string no 주어진 범위의 취약점 발견을 반환합니다: all 또는 dismissed. 기본값은 dismissed입니다.
severity string array no 지정된 심각도 수준에 속한 취약점 발견을 반환합니다: info, unknown, low, medium, high, 또는 critical. 기본값은 모두입니다.
confidence string array no 지정된 신뢰 수준에 속한 취약점 발견을 반환합니다: ignore, unknown, experimental, low, medium, high, 또는 confirmed. 기본값은 모두입니다.
pipeline_id integer/string no 지정된 파이프라인에 속한 취약점 발견을 반환합니다.
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/4/vulnerability_findings"

응답 예시:

[
  {
    "id": null,
    "report_type": "sast",
    "name": "가능한 명령 삽입",
    "severity": "높음",
    "confidence": "높음",
    "scanner": {
      "external_id": "brakeman",
      "name": "Brakeman",
      "vendor": "GitLab"
    },
    "identifiers": [
      {
        "external_type": "brakeman_warning_code",
        "external_id": "14",
        "name": "Brakeman Warning Code 14",
        "url": "https://brakemanscanner.org/docs/warning_types/command_injection/"
      }
    ],
    "project_fingerprint": "ac218b1770af030cfeef967752ab803c55afb36d",
    "uuid": "ad5e3be3-a193-55f5-a200-bc12865fb09c",
    "create_jira_issue_url": null,
    "false_positive": true,
    "create_vulnerability_feedback_issue_path": "/root/test-false-positive/-/vulnerability_feedback",
    "create_vulnerability_feedback_merge_request_path": "/root/test-false-positive/-/vulnerability_feedback",
    "create_vulnerability_feedback_dismissal_path": "/root/test-false-positive/-/vulnerability_feedback",
    "project": {
      "id": 2,
      "name": "가짜 긍정 테스트",
      "full_path": "/root/test-false-positive",
      "full_name": "관리자 / 가짜 긍정 테스트"
    },
    "dismissal_feedback": null,
    "issue_feedback": null,
    "merge_request_feedback": null,
    "description": null,
    "links": [],
    "location": {
      "file": "app/controllers/users_controller.rb",
      "start_line": 42,
      "class": "UsersController",
      "method": "list_users"
    },
    "remediations": [
      null
    ],
    "solution": null,
    "evidence": null,
    "request": null,
    "response": null,
    "evidence_source": null,
    "supporting_messages": [],
    "assets": [],
    "details": {},
    "state": "detected",
    "scan": {
      "type": "sast",
      "status": "success",
      "start_time": "2021-09-02T20:55:48",
      "end_time": "2021-09-02T20:55:48"
    },
    "blob_path": "/root/test-false-positive/-/blob/dfd75607752a839bbc9c7362d111effaa470fecd/app/controllers/users_controller.rb#L42"
  }
]

취약점 발견 REST API를 GraphQL로 대체

취약점 발견 REST API 엔드포인트의 실행 예정 폐기에 대비하여 GraphQL API로 동등한 작업을 수행하려면 아래 예제를 사용합니다.

GraphQL - 프로젝트 취약점 발견

Pipeline.securityReportFindings를 사용합니다.

query VulnerabilityFindings {
  project(fullPath: "gitlab-examples/security/security-reports") {
    pipelines(first:1) {
      nodes {
        securityReportFindings(first:1) {
          nodes {
            title
            severity
            state
            scanner {
              externalId
              name
              vendor
            }
            identifiers {
              externalType
              externalId
              name
              url
            }
            uuid
            falsePositive
            description
            location {
              ... on VulnerabilityLocationSast {
                file
                startLine
                endLine
                vulnerableClass
                vulnerableMethod
                blobPath
              }
              
              ... on VulnerabilityLocationContainerScanning {
                dependency {
                  package {
                    name
                  }
                  version
                }
                image
                operatingSystem
              }
              
              ... on VulnerabilityLocationDependencyScanning {
                file
                blobPath
                dependency {
                  version
                }
              }
            }
            remediations {
              diff
              summary
            }
            solution
            evidence {
              request {
                body
                headers {
                  name
                  value
                }
                method
                url
              }
            }
          }
        }
      }
    }
  }
}

응답 예시:

{
  "data": {
    "project": {
      "pipelines": {
        "nodes": [
          {
            "securityReportFindings": {
              "nodes": [
                {
                  "title": "신뢰할 수 없는 데이터의 직렬화",
                  "severity": "심각함",
                  "state": "확인됨",
                  "scanner": {
                    "externalId": "gemnasium",
                    "name": "Gemnasium",
                    "vendor": "GitLab"
                  },
                  "identifiers": [
                    {
                      "externalType": "gemnasium",
                      "externalId": "b60c2d6b-9083-4a97-a1b2-f7dc79bff74c",
                      "name": "Gemnasium-b60c2d6b-9083-4a97-a1b2-f7dc79bff74c",
                      "url": "https://gitlab.com/gitlab-org/security-products/gemnasium-db/-/blob/master/gem/activerecord/CVE-2022-32224.yml"
                    },
                    {
                      "externalType": "cve",
                      "externalId": "CVE-2022-32224",
                      "name": "CVE-2022-32224",
                      "url": "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-32224"
                    },
                    {
                      "externalType": "ghsa",
                      "externalId": "GHSA-3hhc-qp5v-9p2j",
                      "name": "GHSA-3hhc-qp5v-9p2j",
                      "url": "https://github.com/advisories/GHSA-3hhc-qp5v-9p2j"
                    }
                  ],
                  "uuid": "c9e40395-72cd-54f5-962f-e1d52c0dffab",
                  "falsePositive": false,
                  "description": "Active Record < 7.0.3.1, <6.1.6.1, <6.0.5.1 및 <5.2.8.1에서 YAML 직렬화된 열을 사용할 때 잠재적인 RCE 취약점이 있으며, 데이터베이스에서 데이터를 조작할 수 있는 공격자가 RCE로 에스컬레이션할 수 있게 할 수 있습니다(예: SQL 인젝션).",
                  "location": {
                    "file": "dependency-scanning-files/Gemfile.lock",
                    "blobPath": null,
                    "dependency": {
                      "version": "5.0.0"
                    }
                  },
                  "remediations": [],
                  "solution": "5.2.8.1, 6.0.5.1, 6.1.6.1, 7.0.3.1 이상으로 업그레이드하세요.",
                  "evidence": null
                }
              ]
            }
          }
        ]
      }
    }
  }
}