-
Notifications
You must be signed in to change notification settings - Fork 0
fix: minimize durable audit metadata #795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
59a7aaf
fix: minimize durable audit metadata
BigSimmo 5b1ce7c
Merge branch 'main' into codex/review-and-fix-top-security-defects
BigSimmo a96567e
fix: rename migration to avoid timestamp collision with main
cursoragent 0c6932b
docs: record CI fix review in branch-review-ledger
cursoragent b23983d
fix: rename minimize_audit_log migration to precede reassert_supabase…
cursoragent e23cc03
merge: resolve branch-review-ledger conflict (take main)
cursoragent c546b4f
Merge remote-tracking branch 'origin/main' into cursor/minimize-audit…
cursoragent 7b10d92
Merge remote-tracking branch 'origin/main' into cursor/minimize-audit…
cursoragent 180af46
Merge remote-tracking branch 'origin/main' into cursor/minimize-audit…
cursoragent a7a3fa0
Merge remote-tracking branch 'origin/main' into cursor/minimize-audit…
cursoragent f83cb10
Merge remote-tracking branch 'origin/main' into cursor/minimize-audit…
cursoragent 38737e3
fix: retain numeric storageRemoved in minimized audit metadata
cursoragent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
33 changes: 33 additions & 0 deletions
33
supabase/migrations/20260717163000_minimize_audit_log_metadata.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| -- Audit logs are retained indefinitely for clinical governance. Historical writes | ||
| -- included user-controlled document names/titles and content hashes in metadata, | ||
| -- which could preserve patient identifiers after the source document was renamed | ||
| -- or deleted. Keep the immutable event/resource record but remove free text and | ||
| -- retain only operational facts needed for audit triage. | ||
|
|
||
| update public.audit_logs | ||
| set metadata = case action | ||
| when 'document_upload' then jsonb_strip_nulls(jsonb_build_object( | ||
| 'fileType', case when jsonb_typeof(metadata -> 'fileType') = 'string' then metadata -> 'fileType' end, | ||
| 'fileSize', case when jsonb_typeof(metadata -> 'fileSize') = 'number' then metadata -> 'fileSize' end | ||
| )) | ||
| when 'document_delete' then jsonb_strip_nulls(jsonb_build_object( | ||
| 'storageRemoved', case | ||
| when jsonb_typeof(metadata -> 'storageRemoved') in ('number', 'boolean') then metadata -> 'storageRemoved' | ||
| end | ||
| )) | ||
| else '{}'::jsonb | ||
| end | ||
| where metadata <> '{}'::jsonb; | ||
|
|
||
| do $$ | ||
| declare | ||
| unsafe_metadata_count integer; | ||
| begin | ||
| select count(*) into unsafe_metadata_count | ||
| from public.audit_logs | ||
| where metadata ?| array['fileName', 'contentHash', 'previousTitle', 'newTitle', 'title']; | ||
|
|
||
| if unsafe_metadata_count > 0 then | ||
| raise exception 'audit-log metadata minimization incomplete: % rows still contain user-controlled document text', unsafe_metadata_count; | ||
| end if; | ||
| end $$; | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.