#18: Audit-log Gitea MCP mutating actions with execution profile metadata #29
Reference in New Issue
Block a user
Delete Branch "feat/issue-18-audit-log-mutating-actions"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #18. Roadmap #10.
What
Durable, opt-in audit logging for every mutating Gitea MCP action — so an operator can see which execution profile and authenticated Gitea user performed (or was blocked from / failed) each mutation.
How
gitea_audit.py(pure, no network):token/password/secret/authorization/auth, and string value runs startingtoken/Basic/Bearer→[REDACTED].build_event(...)→ record withtimestamp(ISO-8601 UTC),action,action_type,result,remote,server,repository,issue_number,pr_number,profile_name,audit_label,authenticated_username,target_branch,head_sha,reason, redactedrequest_metadata.write_event(...)→ append-only JSON Lines sink; never raises.mcp_server.pywiring:_auditedcontext manager for simple mutations;_audit_pr_resultdecorator for the gated review/merge tools (reads their own result dict — no extra API calls).create_issue,create_pr,edit_pr,close_issue,commit_files,delete_branch,create_label,set_issue_labels,mark_issue(label/unlabel),gitea_submit_pr_review,gitea_merge_pr.allowed/blocked/failed/succeeded. Blocked and failed actions are logged, not just successes.Safety / behavior
GITEA_AUDIT_LOGis set. Unset ⇒ every audit path short-circuits: no records, no extra API calls → existing tool behavior and API call sequences unchanged.Tests / checks
tests/test_audit.py— 19 cases: redaction, event build (injected clock), sink append/no-op/bad-path, per-tool success/failure/blocked records, secret-free output, off-by-default no-op (asserts single API call), audit-failure-never-breaks-action.py_compileclean; no linters configured in repo.Docs
README env table + audit note (#18),
.env.exampleplaceholder forGITEA_AUDIT_LOG.Intentionally untouched
⚠️ Authored by me — do not self-merge. Needs review by another author.