감사 이벤트 스키마 및 예시

감사 이벤트 스키마

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

필드 설명 주의 사항 스트리밍 전용 필드
author_id 이벤트를 트리거한 사용자의 사용자 ID   아니요
author_name 이벤트를 트리거한 작성자의 읽기 쉬운 이름 작성자가 더 이상 존재하지 않을 때 유용합니다
created_at 이벤트가 트리거된 시간의 타임스탬프   아니요
details 추가 메타데이터를 포함하는 JSON 객체 정의된 스키마가 없지만 종종 이벤트에 대한 추가 정보를 포함합니다 아니요
entity_id 감사 이벤트의 엔터티 ID   아니요
entity_path 감사 가능한 이벤트에 의해 영향을 받은 엔터티의 전체 경로  
entity_type 엔터티 유형의 문자열 표현 허용 가능한 값에는 User, GroupKey가 포함됩니다. 이 목록은 완전하지 않습니다 아니요
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"
}

헤더

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

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 이벤트에 대한 감사 이벤트 페이로드

Fetch:

{
  "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"
}