feat: call git_autid_event when git operation
According to this [discussion]gitlab#384960 (comment 1384459575)
sequenceDiagram
User->>+GitLabShell: git clone or pull (SSH)
GitLabShell->>Rails: request /allowed
rect rgb(200, 150, 255)
Rails->>GitLabShell: authentication info (with NeedAudit)
end
GitLabShell->>Gitaly: UploadPackWithSidechannel
Gitaly->>GitLabShell: UploadPackWithSidechannelResponse(stats={Wants=9, Haves=0, ...})\
alt NeedAudit
rect rgb(200, 150, 255)
GitLabShell-->>Rails: Report audit
end
end
GitLabShell->>-User: Return
Gitlab-shell request /api/v4/internal/shellhorse/git_audit_event, it depends on:
Because request git-audit-event and request gitaly are handled by different systems (one is rails-web, another is Gitaly), so it's hard to guarantee that both requests will succeed or fail at the same time, we just ignore the git audit event error and just log an error log,like:
2023-06-12_07:47:06.80905 sshd : {"correlation_id":"01H2Q958E8EAFMBK7GNB00MRFQ","duration_ms":36,"error":null,"level":"error","method":"POST","msg":"Internal API error","status":404,"time":"2023-06-12T07:47:06Z","url":"http://127.0.0.1:3000/api/v4/internal/git_audit_events"}
Edited by Sword