취약점 API
- GitLab 12.6에서 소개됨.
 last_edited_at는 GitLab 16.7에서 사용 중지됨.start_date는 GitLab 16.7에서 사용 중지됨.updated_by_id는 GitLab 16.7에서 사용 중지됨.last_edited_by_id는 GitLab 16.7에서 사용 중지됨.due_date는 GitLab 16.7에서 사용 중지됨.
모든 취약점에 대한 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
}
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": []
    }
  }
}
도움말