Audit Log Event Inconsistencies
- Dominant language
- Java
- Stars
- 80
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
## Status Quo
`EMERGENCY_ACCESS_SETUP` and `EMERGENCY_ACCESS_SETTINGS_UPDATED` share the same data (council members, required key shares, ...) but encode them in the database differently:
https://github.com/cryptomator/hub/blob/04f4b58ad1bdb1de856e1a58f07519ef6974c27b/backend/src/main/resources/org/cryptomator/hub/flyway/V24__Emergency_Access.sql#L56-L67
vs.
https://github.com/cryptomator/hub/blob/04f4b58ad1bdb1de856e1a58f07519ef6974c27b/backend/src/main/resources/org/cryptomator/hub/flyway/V24__Emergency_Access.sql#L69-L78
Note, how `audit_event_emergaccess_settings_updated.council_member_ids` is already today encoded as a json array to avoid even more complex joins for 3NF:
```json
["alice", "bob", "carol"]
```
`audit_event_emergaccess_setup.settings` is even including the council member IDs:
```json
{ "requiredEmergencyKeyShares": 2, "emergencyCouncilMemberIds": ["alice", "bob", "carol"] }
```
## Desired State
Both tables should be similar. Whether full JSON or better normalization depends on various factors:
* what migration is easier?
* do we need to search on structured data?
* ...
## Maybe...?
Should we even do a big refactoring and let *all* events store their specific data in JSON? Benefits:
1. eliminating the large number of subtables (and thus the many joins when querying from audit log)
2. be a "dumb log", same as any external logging server would treat the data, easy import/export capabilities
3. allow changing what data is recorded per event without touching history
4. easy hashing of recoreded events, allows building a hash chain and introduce a tamper-proof audit log
Contributor guide
Research direction
Start by comparing the two event definitions in backend/src/main/resources/org/cryptomator/hub/flyway/V24__Emergency_Access.sql, especially lines 56-78. Review the migration and the stated questions about structured-data search, normalization, and history preservation before choosing a consistent representation. Done means the related audit-event tables store equivalent data consistently and existing records remain usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json, sql
- Domain
- backend, databases
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100