feat(security): record audit metadata on guest token issuance#41305
feat(security): record audit metadata on guest token issuance#41305rusackas wants to merge 2 commits into
Conversation
The guest-token issuance endpoint logged only the coarse action via @event_logger.log_this, without the metadata needed to investigate a misissued or over-scoped token. Emit an explicit issuance event capturing the issuer user id, source IP, granted resources, dataset allowlist, RLS dataset scope, and a SHA-256 hash of the issued token (never the raw token; RLS clause text is omitted since it can carry data values). The payload is built by a pure helper (build_guest_token_audit_payload) with unit tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Code Review Agent Run #dcfe6cActionable Suggestions - 0Filtered by Review RulesBito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
The suggestion to add explicit return type annotations ( def test_build_guest_token_audit_payload_captures_issuance_metadata() -> None:
def test_build_guest_token_audit_payload_hashes_token_and_omits_raw() -> None:
def test_build_guest_token_audit_payload_omits_rls_clause_text() -> None:There are no other review comments in this pull request. Would you like me to apply these changes to the test file? tests/unit_tests/security/guest_token_audit_test.py |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41305 +/- ##
==========================================
- Coverage 64.34% 64.34% -0.01%
==========================================
Files 2653 2653
Lines 144952 144959 +7
Branches 33433 33433
==========================================
+ Hits 93273 93275 +2
- Misses 49995 49998 +3
- Partials 1684 1686 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…types Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
SUMMARY
The guest-token issuance endpoint recorded only the coarse action name via
@event_logger.log_this, without the metadata needed to scope an investigation if a misissued or over-scoped token were later abused.This emits an explicit issuance event on successful guest-token creation capturing:
type:id)RLS clause text is intentionally omitted since it can carry data values. The metadata is assembled by a small pure helper,
build_guest_token_audit_payload, so it is easy to test.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — audit logging.
TESTING INSTRUCTIONS
Unit tests in
tests/unit_tests/security/guest_token_audit_test.py:Run:
pytest tests/unit_tests/security/guest_token_audit_test.pyADDITIONAL INFORMATION