feat: implement examination identity audit logs for GATEKEEPER#37
Open
Soldier224K wants to merge 1 commit into
Open
feat: implement examination identity audit logs for GATEKEEPER#37Soldier224K wants to merge 1 commit into
Soldier224K wants to merge 1 commit into
Conversation
- Add AuditLogService for comprehensive identity event logging - Log verification attempts, face matches/mismatches, suspicious events - Log admin override actions and examination access decisions - Add get_timeline() for roll-number or session filtered audit trails - Add search() for querying audit log content - Add 15 tests covering all audit logging functionality
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new backend audit logging service intended to capture identity/verification-related events for the GATEKEEPER domain, plus accompanying unit tests to validate event creation and querying APIs.
Changes:
- Added
AuditLogService/AuditEventto record identity events (verification attempts, matches/mismatches, suspicious events, admin overrides, exam access). - Added timeline and query helpers (
get_timeline,get_session_timeline,get_events_by_type,search,count,clear). - Added a new pytest suite (
test_audit_log.py) covering the audit log API end-to-end.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
backend/src/services/audit_log.py |
Adds the audit log service + event model and querying helpers. |
backend/tests/test_audit_log.py |
Adds unit tests covering event logging, filtering, searching, and determinism checks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,201 @@ | |||
| from typing import Optional, List, Dict, Any | |||
| from dataclasses import dataclass, field | |||
Comment on lines
+46
to
+49
| event = AuditEvent( | ||
| event_id=self._generate_event_id(roll_number, "verification_attempt", datetime.now(timezone.utc)), | ||
| timestamp=datetime.now(timezone.utc), | ||
| event_type="verification_attempt", |
Comment on lines
+68
to
+71
| event = AuditEvent( | ||
| event_id=self._generate_event_id(roll_number, "face_match", datetime.now(timezone.utc)), | ||
| timestamp=datetime.now(timezone.utc), | ||
| event_type="face_match", |
Comment on lines
+90
to
+93
| event = AuditEvent( | ||
| event_id=self._generate_event_id(roll_number, "face_mismatch", datetime.now(timezone.utc)), | ||
| timestamp=datetime.now(timezone.utc), | ||
| event_type="face_mismatch", |
Comment on lines
+113
to
+116
| event = AuditEvent( | ||
| event_id=self._generate_event_id(roll_number, "suspicious_identity", datetime.now(timezone.utc)), | ||
| timestamp=datetime.now(timezone.utc), | ||
| event_type="suspicious_identity", |
Comment on lines
+160
to
+163
| event = AuditEvent( | ||
| event_id=self._generate_event_id(roll_number, "examination_access", datetime.now(timezone.utc)), | ||
| timestamp=datetime.now(timezone.utc), | ||
| event_type="examination_access", |
| query_lower = query.lower() | ||
| results = [] | ||
| for event in self._logs: | ||
| payload_str = json.dumps(event.payload).lower() |
Comment on lines
+31
to
+33
| def __init__(self): | ||
| self._logs: List[AuditEvent] = [] | ||
|
|
Comment on lines
+30
to
+33
| class AuditLogService: | ||
| def __init__(self): | ||
| self._logs: List[AuditEvent] = [] | ||
|
|
Comment on lines
+165
to
+166
| import time | ||
| from datetime import datetime, timezone |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #22