This repository has been archived by the owner on Feb 12, 2025. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix change detection condition on KeeperMap read-only step
Unfortunately looking at `system.grants` to check whether specific grants have been successfully revoked in ClickHouse is not perfect. Let a user with a set of initial grants, including some ALTER statements. Doing ``REVOKE INSERT, ALTER UPDATE, ALTER DELETE ON <user> FROM <table>`` on this user creates rows in ``system.grants`` for each of the grants with ``is_partial_revoke=1``. If the user doesn't have ``ALTER`` statements in their initial grants, then after executing ``REVOKE`` the ``system.grants`` table simply has no corresponding rows. Here's an example taken from running ``tests/integration/coordinator/plugins/clickhouse/test_steps.py::test_keeper_map_table_read_only_step``. After ``REVOKE``: ``` SELECT * FROM grants WHERE user_name='bob' AND database='keeperdata' AND table='keepertable' AND access_type IN ('INSERT', 'ALTER UPDATE', 'ALTER DELETE') user_name role_name access_type database table column is_partial_revoke grant_option ----------- ----------- ------------- ---------- ----------- -------- ------------------- -------------- bob INSERT keeperdata keepertable 1 0 bob ALTER UPDATE keeperdata keepertable 1 0 bob ALTER DELETE keeperdata keepertable 1 0 ``` After re-``GRANT``: ``` SELECT * FROM grants WHERE database='default' AND table='keeper_map' user_name role_name access_type database table column is_partial_revoke grant_option ---------------- ----------- ------------- ---------- ---------- -------- ------------------- -------------- aiven_monitoring INSERT default keeper_map 0 0 aiven_monitoring ALTER UPDATE default keeper_map 0 0 aiven_monitoring ALTER DELETE default keeper_map 0 0 alice INSERT default keeper_map 0 0 alice ALTER UPDATE default keeper_map 0 0 alice ALTER DELETE default keeper_map 0 0 avnadmin INSERT default keeper_map 1 1 avnadmin ALTER UPDATE default keeper_map 1 1 avnadmin ALTER DELETE default keeper_map 1 1 ``` The fix is as follows: when checking for revoked DML grants, ignore rows in system table that indicate partially revoked grants.
- Loading branch information