furniture-3d-system-Wu/furniture-3d-system/scripts/sql/check-store-account-password-reveal.sql

21 lines
1.4 KiB
SQL

-- Post-migration read-only acceptance. Contains no credential material or row data.
BEGIN READ ONLY;
SET LOCAL statement_timeout = '10s';
SELECT jsonb_build_object(
'database', current_database(),
'count', count(*),
'distinctIds', count(DISTINCT id),
'passwordConfiguredTrue', count(*) FILTER (WHERE "passwordConfigured" IS TRUE),
'passwordConfiguredFalse', count(*) FILTER (WHERE "passwordConfigured" IS FALSE),
'passwordConfiguredNull', count(*) FILTER (WHERE "passwordConfigured" IS NULL),
'type', (SELECT data_type FROM information_schema.columns
WHERE table_schema='external_store_accounts' AND table_name='accounts_v1' AND column_name='passwordConfigured'),
'isLastColumn', (SELECT column_name='passwordConfigured' FROM information_schema.columns
WHERE table_schema='external_store_accounts' AND table_name='accounts_v1' ORDER BY ordinal_position DESC LIMIT 1),
'readerCanReadView', has_table_privilege('store_account_reader','external_store_accounts.accounts_v1','SELECT'),
'readerCanReadBase', has_table_privilege('store_account_reader','public."StoreAccount"','SELECT'),
'readerCanReadPassword', has_column_privilege('store_account_reader','public."StoreAccount"','passwordCiphertext','SELECT'),
'readerCanReadAudit', has_table_privilege('store_account_reader','public."StoreAccountPasswordAccessAudit"','SELECT')
) FROM external_store_accounts.accounts_v1;
ROLLBACK;