감사 이벤트 스키마 및 예시

감사 이벤트 스키마

  • 감사 이벤트 스트리밍 스키마에 대한 문서가 GitLab 15.3에 소개되었습니다.

감사 이벤트는 응답 본문의 예측 가능한 스키마를 갖고 있습니다.

필드 설명 참고 스트리밍 전용 필드
author_id 이벤트를 트리거한 사용자의 ID   아니요
author_name 이벤트를 트리거한 작성자의 사람이 읽을 수 있는 이름 작성자가 더 이상 존재하지 않을 때 유용합니다
created_at 이벤트가 트리거된 타임스탬프   아니요
details 추가 메타데이터를 포함하는 JSON 객체 정의된 스키마는 없지만 종종 이벤트에 대한 추가 정보를 포함합니다 아니요
entity_id 감사 이벤트의 엔티티의 ID   아니요
entity_path 감사 이벤트에 영향을 받은 엔티티의 전체 경로  
entity_type 엔티티의 유형에 대한 문자열 표현 User, Group, 및 Key와 같은 허용 가능한 값이 포함됩니다. 이 디렉터리은 전체가 아닙니다 아니요
event_type 감사 이벤트의 유형에 대한 문자열 표현  
id 감사 이벤트의 고유 식별자 필요한 경우 중복을 방지하는 데 사용할 수 있습니다 아니요
ip_address 이벤트를 트리거한 호스트의 IP 주소  
target_details 대상에 대한 추가 세부 정보  
target_id 감사 이벤트의 대상의 ID  
target_type 대상의 유형에 대한 문자열 표현  

감사 이벤트 JSON 스키마

{
  "properties": {
    "id": {
      "type": "string"
    },
    "author_id": {
      "type": "integer"
    },
    "author_name": {
      "type": "string"
    },
    "details": {},
    "ip_address": {
      "type": "string"
    },
    "entity_id": {
      "type": "integer"
    },
    "entity_path": {
      "type": "string"
    },
    "entity_type": {
      "type": "string"
    },
    "event_type": {
      "type": "string"
    },
    "target_id": {
      "type": "integer"
    },
    "target_type": {
      "type": "string"
    },
    "target_details": {
      "type": "string"
    },
  },
  "type": "object"
}

헤더

  • X-Gitlab-Audit-Event-Type이 GitLab 15.0에서 소개되었습니다.

헤더는 다음과 같이 형식화됩니다:

POST /logs HTTP/1.1
Host: <DESTINATION_HOST>
Content-Type: application/x-www-form-urlencoded
X-Gitlab-Event-Streaming-Token: <DESTINATION_TOKEN>
X-Gitlab-Audit-Event-Type: repository_git_operation

예시: Git 조작에 대한 감사 이벤트 스트리밍

인증된 사용자가 프로젝트의 원격 Git 리포지터리를 푸시, 풀 또는 복제할 때 감사 이벤트를 스트리밍할 수 있습니다:

  • SSH 사용.
  • HTTP 또는 HTTPS 사용.
  • GitLab UI에서 다운로드() 사용.

사용자가 로그인하지 않은 경우 감사 이벤트가 캡처되지 않습니다. 예를 들어, 공개 프로젝트를 다운로드할 때입니다.

예시: 배포 키를 사용한 SSH를 통한 Git 이벤트에 대한 감사 이벤트 페이로드

검색:

{
  "id": "1",
  "author_id": -3,
  "entity_id": 29,
  "entity_type": "Project",
  "details": {
    "author_name": "deploy-key-name",
    "author_class": "DeployKey",
    "target_id": 29,
    "target_type": "Project",
    "target_details": "example-project",
    "custom_message": {
      "protocol": "ssh",
      "action": "git-upload-pack"
    },
    "ip_address": "127.0.0.1",
    "entity_path": "example-group/example-project"
  },
  "ip_address": "127.0.0.1",
  "author_name": "deploy-key-name",
  "entity_path": "example-group/example-project",
  "target_details": "example-project",
  "created_at": "2022-07-26T05:43:53.662Z",
  "target_type": "Project",
  "target_id": 29,
  "event_type": "repository_git_operation"
}