feat: deliver Sense audits to Bell (T-016)
This commit is contained in:
@@ -71,8 +71,8 @@ BEGIN
|
||||
OR NOT has_table_privilege('sense_app', 'sense.device_operation_outbox', 'DELETE') THEN
|
||||
RAISE EXCEPTION 'sense_app lacks access to its local audit Outbox';
|
||||
END IF;
|
||||
IF (SELECT max(version) FROM bell.schema_migrations) <> 3
|
||||
OR (SELECT max(version) FROM sense.schema_migrations) <> 5 THEN
|
||||
IF (SELECT max(version) FROM bell.schema_migrations) <> 4
|
||||
OR (SELECT max(version) FROM sense.schema_migrations) <> 6 THEN
|
||||
RAISE EXCEPTION 'schema migration version drift';
|
||||
END IF;
|
||||
|
||||
@@ -201,3 +201,30 @@ BEGIN
|
||||
END IF;
|
||||
END
|
||||
$reconcile_safety$;
|
||||
|
||||
DO $audit_relay$
|
||||
BEGIN
|
||||
IF NOT has_table_privilege('yovision_t012_sense', 'sense.device_operation_outbox', 'SELECT,INSERT,UPDATE,DELETE')
|
||||
OR has_table_privilege('yovision_t012_sense', 'bell.audit_events', 'SELECT,INSERT,UPDATE,DELETE')
|
||||
OR has_table_privilege('yovision_t012_sense', 'bell.audit_relay_receipts', 'SELECT,INSERT,UPDATE,DELETE') THEN
|
||||
RAISE EXCEPTION 'Sense runtime violates audit relay schema ownership';
|
||||
END IF;
|
||||
IF NOT has_table_privilege('yovision_t015_bell', 'bell.audit_events', 'SELECT,INSERT')
|
||||
OR has_table_privilege('yovision_t015_bell', 'bell.audit_events', 'UPDATE,DELETE,TRUNCATE')
|
||||
OR NOT has_table_privilege('yovision_t015_bell', 'bell.audit_relay_receipts', 'SELECT,INSERT,DELETE')
|
||||
OR has_table_privilege('yovision_t015_bell', 'bell.audit_relay_receipts', 'UPDATE,TRUNCATE') THEN
|
||||
RAISE EXCEPTION 'Bell runtime violates audit relay privileges';
|
||||
END IF;
|
||||
IF has_table_privilege('public', 'bell.audit_events', 'SELECT,INSERT,UPDATE,DELETE,TRUNCATE')
|
||||
OR has_table_privilege('public', 'bell.audit_relay_receipts', 'SELECT,INSERT,UPDATE,DELETE,TRUNCATE') THEN
|
||||
RAISE EXCEPTION 'Bell audit relay tables leaked to PUBLIC';
|
||||
END IF;
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema='sense' AND table_name='device_operation_outbox'
|
||||
AND column_name='relay_lease_token'
|
||||
) THEN
|
||||
RAISE EXCEPTION 'Sense audit relay fencing columns are missing';
|
||||
END IF;
|
||||
END
|
||||
$audit_relay$;
|
||||
|
||||
Reference in New Issue
Block a user