-
Notifications
You must be signed in to change notification settings - Fork 0
fix(audit): remediate system audit findings (P0, P1, P2) #1198
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
+106
−15
Closed
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
9aa823f
fix(audit): system audit remediation (P0, P1, P2)
BigSimmo 5474fb6
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 7228a16
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 7050de6
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 77c9b63
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 348c764
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 36f040b
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 3bf226c
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 5f149b5
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 945fc6a
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] c985244
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] a7b6606
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] c043e31
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 09dbc49
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] f712132
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 1c9170b
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 47865cd
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] d67a92b
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] b82de97
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 59f31d2
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 5806b77
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 265ddc6
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 147be0c
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] e54b299
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] a7ea05e
Merge branch 'main' into fix/system-audit-remediation-pr
github-actions[bot] 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| -- REVOKE ALL on core tables from public/anon/authenticated | ||
| revoke all privileges on table | ||
| public.import_batches, | ||
| public.documents, | ||
| public.document_pages, | ||
| public.document_images, | ||
| public.image_caption_cache, | ||
| public.document_labels, | ||
| public.document_summaries, | ||
| public.document_sections, | ||
| public.document_memory_cards, | ||
| public.document_chunks, | ||
| public.document_table_facts, | ||
| public.document_embedding_fields, | ||
| public.document_index_quality, | ||
| public.ingestion_jobs, | ||
| public.ingestion_job_stages, | ||
| public.rag_queries, | ||
| public.rag_query_misses, | ||
| public.rag_aliases, | ||
| public.rag_response_cache, | ||
| public.api_rate_limits, | ||
| public.api_rate_limit_subjects, | ||
| public.audit_logs, | ||
| public.storage_cleanup_jobs, | ||
| public.rag_retrieval_logs | ||
| from public, anon, authenticated; | ||
|
|
||
| -- REVOKE EXECUTE on 5 internal maintenance RPCs | ||
| revoke execute on function public.correct_clinical_query_terms(text, real) from public, anon, authenticated; | ||
| revoke execute on function public.purge_expired_rag_response_cache(integer) from public, anon, authenticated; | ||
| revoke execute on function public.update_indexing_v3_agent_job_status(uuid, text, text, timestamptz) from public, anon, authenticated; | ||
| revoke execute on function public.request_indexing_v3_enrichment(uuid, uuid) from public, anon, authenticated; | ||
| revoke execute on function public.cleanup_abandoned_document_index_generations(uuid, integer, boolean) from public, anon, authenticated; | ||
| revoke execute on function public.detect_legacy_ivfflat_indexes() from public, anon, authenticated; | ||
| revoke execute on function public.document_summary_text(uuid) from public, anon, authenticated; | ||
| revoke execute on function public.search_document_chunks(uuid, text, integer, uuid) from public, anon, authenticated; | ||
| revoke execute on function public.set_document_embedding_field_content_hash() from public, anon, authenticated; | ||
|
Comment on lines
+29
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Correct the stale RPC count. Lines 30-38 revoke execution for nine functions, not five. Update the comment so it remains accurate for future maintainers. 🤖 Prompt for AI Agents |
||
|
|
||
40 changes: 40 additions & 0 deletions
40
supabase/migrations/20260724164600_dynamic_ingestion_worker_url.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,40 @@ | ||
| create or replace function public.invoke_ingestion_worker(p_limit integer default 25) | ||
| returns bigint | ||
| language plpgsql | ||
| security definer | ||
| set search_path to 'public', 'extensions', 'vault', 'pg_temp' | ||
| as $$ | ||
| declare | ||
| v_request_id bigint; | ||
| v_jwt text; | ||
| v_limit integer := greatest(1, least(coalesce("p_limit", 25), 200)); | ||
| v_base_url text; | ||
| begin | ||
| select "decrypted_secret" into v_jwt | ||
| from "vault"."decrypted_secrets" | ||
| where "name" = 'cron_ingestion_jwt' | ||
| limit 1; | ||
|
|
||
| if v_jwt is null or length(trim(v_jwt)) = 0 then | ||
| raise exception 'Missing Vault secret: cron_ingestion_jwt'; | ||
| end if; | ||
|
|
||
| v_base_url := coalesce( | ||
| nullif(current_setting('app.ingestion_worker_base_url', true), ''), | ||
| 'https://sjrfecxgysukkwxsowpy.supabase.co' | ||
| ); | ||
|
|
||
| select "net"."http_post"( | ||
| url := v_base_url || '/functions/v1/ingestion-worker?limit=' || v_limit::text, | ||
| headers := jsonb_build_object( | ||
| 'Content-Type','application/json', | ||
| 'Authorization','Bearer ' || v_jwt | ||
| ), | ||
| body := jsonb_build_object('source','pg_cron','worker','ingestion-worker','ts', now()), | ||
| timeout_milliseconds := 60000 | ||
| ) | ||
| into v_request_id; | ||
|
|
||
| return v_request_id; | ||
| end; | ||
| $$; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Do not let the medical-term bypass override explicit exclusion rules.
MEDICAL_TERMS_REGEXoverlapsclearlyOutsideCorpusMedicalPattern(depressionandssri). Because this return runs first, queries such asadolescent depressionorSSRIskip the existing outside-corpus short circuit and proceed to retrieval. Move the hard exclusion checks before this bypass, or remove the overlapping terms and add regression tests that define the intended precedence.🤖 Prompt for AI Agents