Skip to content

Add event type in audit event streaming

What does this MR do and why?

Adds event_type in JSON payload of streaming audit event

How to set up and validate locally

  1. Run rails console and execute the below code to enter destination url

      group = Group.find 1 # id of group you want to test
      destination_url = 'https://hsandhu.requestcatcher.com/events'
      AuditEvents::ExternalAuditEventDestination.create(namespace_id: group.id, destination_url: destination_url)

    OR use this api to create destination url https://docs.gitlab.com/ee/administration/audit_event_streaming.html#add-a-new-event-streaming-destination

  2. Produce a streaming audit event, for example: clone a repo.

  3. Check streamed request body contains correct event type

Example Request body

{
  "id": 1653461355,
  "author_id": 1,
  "entity_id": 6,
  "entity_type": "Project",
  "details": {
    "author_name": "Administrator",
    "target_id": 6,
    "target_type": "Project",
    "target_details": "Flight",
    "custom_message": {
      "protocol": "ssh",
      "action": "git-upload-pack"
    },
    "ip_address": "127.0.0.1",
    "entity_path": "flightjs/Flight"
  },
  "ip_address": "127.0.0.1",
  "author_name": "Administrator",
  "entity_path": "flightjs/Flight",
  "target_details": "Flight",
  "created_at": "2022-05-25T06:49:15.213Z",
  "target_type": "Project",
  "target_id": 6,
  "event_type": "repository_git_operation"
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #362297 (closed)

Edited by Harsimar Sandhu

Merge request reports

Loading