Emit audit and SCIM log exports as CSV

JSONL was awkward in spreadsheets and SIEM imports. Write
tab-separated-friendly CSV with organization name on every row,
resolve audit actors to email or API key name, and enrich SCIM rows
with profile email and display name when available.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

Co-authored-by: Bryan FRIMIN <bryan@frimin.fr>
This commit is contained in:
Cursor Agent
2026-07-29 18:14:25 +00:00
parent 0448c25d8b
commit 5cd407bd86
11 changed files with 726 additions and 108 deletions

View File

@@ -301,3 +301,47 @@ WHERE
return nil
}
func (a *PersonalAPIKeys) LoadByIDs(
ctx context.Context,
conn pg.Querier,
apiKeyIDs []gid.GID,
) error {
if len(apiKeyIDs) == 0 {
*a = nil
return nil
}
q := `
SELECT
id,
identity_id,
name,
expires_at,
expire_reason,
last_used_at,
created_at,
updated_at
FROM
iam_personal_api_keys
WHERE
id = ANY(@api_key_ids::text[])
`
args := pgx.StrictNamedArgs{"api_key_ids": apiKeyIDs}
rows, err := conn.Query(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot query personal api keys: %w", err)
}
apiKeys, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[PersonalAPIKey])
if err != nil {
return fmt.Errorf("cannot collect personal api keys: %w", err)
}
*a = apiKeys
return nil
}