Audit Event 스키마 및 예시

Audit Event 스키마

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

필드 설명 참고 스트리밍 전용 필드
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 대상 유형의 문자열 표현  

Audit Event 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 저장소를 push, pull 또는 clone할 때, 감사 이벤트를 스트리밍할 수 있습니다:

  • SSH 사용.
  • HTTP 또는 HTTPS를 사용합니다.
  • GitLab UI의 다운로드를 사용합니다 ().

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

예시: Deploy Key가 있는 Git over 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"
}