审计事件格式和示例
审计事件模式
History
- 极狐 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 模式
json1{ 2 "properties": { 3 "id": { 4 "type": "string" 5 }, 6 "author_id": { 7 "type": "integer" 8 }, 9 "author_name": { 10 "type": "string" 11 }, 12 "details": {}, 13 "ip_address": { 14 "type": "string" 15 }, 16 "entity_id": { 17 "type": "integer" 18 }, 19 "entity_path": { 20 "type": "string" 21 }, 22 "entity_type": { 23 "type": "string" 24 }, 25 "event_type": { 26 "type": "string" 27 }, 28 "target_id": { 29 "type": "integer" 30 }, 31 "target_type": { 32 "type": "string" 33 }, 34 "target_details": { 35 "type": "string" 36 }, 37 }, 38 "type": "object" 39}
标头
History
- X-Gitlab-Audit-Event-Type 在极狐 GitLab 15.0 中引入。
标头格式如下:
plaintextPOST /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 事件的审计事件负载
Fetch:
json1{ 2 "id": "1", 3 "author_id": -3, 4 "entity_id": 29, 5 "entity_type": "Project", 6 "details": { 7 "author_name": "deploy-key-name", 8 "author_class": "DeployKey", 9 "target_id": 29, 10 "target_type": "Project", 11 "target_details": "example-project", 12 "custom_message": { 13 "protocol": "ssh", 14 "action": "git-upload-pack" 15 }, 16 "ip_address": "127.0.0.1", 17 "entity_path": "example-group/example-project" 18 }, 19 "ip_address": "127.0.0.1", 20 "author_name": "deploy-key-name", 21 "entity_path": "example-group/example-project", 22 "target_details": "example-project", 23 "created_at": "2022-07-26T05:43:53.662Z", 24 "target_type": "Project", 25 "target_id": 29, 26 "event_type": "repository_git_operation" 27}