취약점 API

Tier: Ultimate Offering: GitLab.com, Self-managed, GitLab Dedicated
  • GitLab 12.6에서 도입되었습니다.
  • last_edited_atGitLab 16.7에서 사용이 중단되었습니다.
  • start_dateGitLab 16.7에서 사용이 중단되었습니다.
  • updated_by_idGitLab 16.7에서 사용이 중단되었습니다.
  • last_edited_by_idGitLab 16.7에서 사용이 중단되었습니다.
  • due_dateGitLab 16.7에서 사용이 중단되었습니다.
note
이전 취약점 API는 취약점 검색 API로 이름이 변경되었으며 그 문서는 다른 위치로 옮겼습니다. 이 문서는 이제 취약점에 액세스를 제공하는 새로운 취약점 API에 대해 설명합니다.
caution
이 API는 폐기되고 불안정한 것으로 간주됩니다. 응답 payload는 GitLab 릴리스 간에 변경되거나 손상될 수 있습니다. GraphQL API를 대신 사용하세요. 자세한 내용은 GraphQL 예제를 참조하세요.

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

권한이 없는 사용자가 취약점을 볼 수 없는 경우, 이 요청은 403 Forbidden 상태 코드를 반환합니다.

단일 취약점

단일 취약점을 가져옵니다.

GET /vulnerabilities/:id
속성 유형 필요 여부 설명
id 정수 또는 문자열 가져올 취약점의 ID
curl --header "PRIVATE-TOKEN: <your_access_token>" "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>" "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>" "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>" "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>" "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로 교체

Vulnerability 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": "railties의 부적절한 입력 유효성 검증",
      "description": "개발 모드 레일즈 beta3에서의 원격 코드 실행 취약점은 공격자가 자동으로 생성된 개발 모드 비밀 토큰을 추측할 수 있게 합니다. 이 비밀 토큰은 다른 레일즈 내부 기능과 결합하여 원격 코드 실행 익스플로잇으로 승격될 수 있습니다.",
      "state": "해결됨",
      "severity": "심각함",
      "reportType": "의존성 스캐닝",
      "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": "확인됨"
      },
      "errors": []
    }
  }
}

GraphQL - 취약점 해결

Mutation.vulnerabilityResolve을 사용하세요.

mutation {
  vulnerabilityResolve(input: { id: "gid://gitlab/Vulnerability/23577695"}) {
    vulnerability {
      state
    }
    errors
  }
}

예시 응답:

{
  "data": {
    "vulnerabilityConfirm": {
      "vulnerability": {
        "state": "해결됨"
      },
      "errors": []
    }
  }
}

GraphQL - 취약점 해제

Mutation.vulnerabilityDismiss을 사용하세요.

mutation {
  vulnerabilityDismiss(input: { id: "gid://gitlab/Vulnerability/23577695"}) {
    vulnerability {
      state
    }
    errors
  }
}

예시 응답:

{
  "data": {
    "vulnerabilityConfirm": {
      "vulnerability": {
        "state": "해제됨"
      },
      "errors": []
    }
  }
}

GraphQL - 취약점을 감지된 상태로 되돌리기

Mutation.vulnerabilityRevertToDetected을 사용하세요.

mutation {
  vulnerabilityRevertToDetected(input: { id: "gid://gitlab/Vulnerability/20345379"}) {
    vulnerability {
      state
    }
    errors
  }
}

예시 응답:

{
  "data": {
    "vulnerabilityConfirm": {
      "vulnerability": {
        "state": "감지됨"
      },
      "errors": []
    }
  }
}