Check service methods for audit logging compliance
Scans service files for audit logging compliance and reports missing implementations.
/plugin marketplace add adelabdelgawad/full-stack/plugin install audit-logging@full-stackIMPORTANT: When this command is invoked, you MUST actually SCAN the codebase and REPORT findings. Do NOT just describe what to check.
Use Glob to find all service files:
{backend}/api/services/*_service.py
Identify services for sensitive entities:
Find methods that perform mutations:
create_*, add_*update_*, modify_*delete_*, remove_*assign_*, revoke_*toggle_*, activate_*, deactivate_*For each mutation method, verify:
from api.services.log_user_service import LogUserService)__init__FORMAT YOUR OUTPUT EXACTLY LIKE THIS:
╔══════════════════════════════════════════════════════════════╗
║ AUDIT LOGGING COMPLIANCE REPORT ║
╚══════════════════════════════════════════════════════════════╝
📋 SERVICES CHECKED
────────────────────────
✅ user_service.py - Has audit logging
✅ role_service.py - Has audit logging
❌ permission_service.py - MISSING audit logging
📊 METHOD ANALYSIS
────────────────────────
user_service.py:
✅ create_user (line 45) - logs to LogUserService
✅ update_user (line 78) - logs to LogUserService
✅ delete_user (line 112) - logs to LogUserService
permission_service.py:
❌ create_permission (line 32) - NO AUDIT LOG
❌ update_permission (line 56) - NO AUDIT LOG
❌ delete_permission (line 89) - NO AUDIT LOG
📊 SUMMARY
────────────────────────
Services with audit logging: 2/3
Methods with audit logging: 3/6
🔧 REQUIRED FIXES
────────────────────────
1. permission_service.py:
- Import: from api.services.log_permission_service import LogPermissionService
- Add to __init__: self._log_service = LogPermissionService()
- Add logging calls after create/update/delete operations
If issues are found, ask: "Would you like me to add audit logging to the services missing it?"
If user agrees, for each service:
__init__await self._log_service.log_create(
session,
entity_id=str(entity.id),
created_by_id=created_by_id,
details={"field": entity.field_value},
)
This command MUST:
DO NOT just tell the user to run a script. PERFORM THE CHECK.