Skip to content

Commit b21cf43

Browse files
committed
RHINENG-24787: narrow manager db privileges
1 parent f5335be commit b21cf43

4 files changed

Lines changed: 23 additions & 6 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
REVOKE UPDATE ON system_patch FROM manager;
2+
GRANT UPDATE ON system_patch TO manager;
3+
4+
REVOKE UPDATE ON system_inventory FROM manager;
5+
GRANT UPDATE ON system_inventory TO manager;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- Restore least-privilege grants for manager after migration 145 temporarily
2+
-- broadened them for system_platform view/trigger updates (removed in 151).
3+
REVOKE UPDATE ON system_inventory FROM manager;
4+
GRANT UPDATE (stale) ON system_inventory TO manager;
5+
6+
REVOKE UPDATE ON system_patch FROM manager;
7+
GRANT UPDATE (
8+
installable_advisory_count_cache,
9+
installable_advisory_enh_count_cache,
10+
installable_advisory_bug_count_cache,
11+
installable_advisory_sec_count_cache,
12+
applicable_advisory_count_cache,
13+
applicable_advisory_enh_count_cache,
14+
applicable_advisory_bug_count_cache,
15+
applicable_advisory_sec_count_cache,
16+
template_id) ON system_patch TO manager;

database_admin/schema/create_schema.sql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS schema_migrations
77

88

99
INSERT INTO schema_migrations
10-
VALUES (151, false);
10+
VALUES (152, false);
1111

1212
-- ---------------------------------------------------------------------------
1313
-- Functions
@@ -603,8 +603,7 @@ SELECT create_table_partitions('system_inventory', 16,
603603

604604
GRANT SELECT, INSERT, UPDATE ON system_inventory TO listener;
605605
GRANT SELECT, UPDATE, DELETE ON system_inventory TO vmaas_sync; -- vmaas_sync performs system culling
606-
GRANT SELECT, UPDATE (stale) ON system_inventory TO manager; -- manager needs to be able to update opt_out column
607-
GRANT SELECT, UPDATE ON system_inventory TO manager; -- manager needs to be able to update opt_out column
606+
GRANT SELECT, UPDATE (stale) ON system_inventory TO manager;
608607
GRANT SELECT, UPDATE ON system_inventory TO evaluator;
609608

610609
SELECT create_table_partition_triggers('system_inventory_set_last_updated',
@@ -970,7 +969,6 @@ GRANT SELECT, UPDATE (installable_advisory_count_cache,
970969
applicable_advisory_bug_count_cache,
971970
applicable_advisory_sec_count_cache,
972971
template_id) ON system_patch TO manager;
973-
GRANT SELECT, UPDATE ON system_patch TO manager;
974972
GRANT SELECT, UPDATE, DELETE ON system_patch to vmaas_sync; -- vmaas_sync performs system culling
975973

976974
-- ----------------------------------------------------------------------------

manager/controllers/template_systems_update.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ func assignTemplateSystems(c *gin.Context, db *gorm.DB, accountID int, template
139139
templateID = &template.ID
140140
}
141141

142-
// TODO: Revisit migration 145 manager privileges on system_inventory/system_patch; they were tied to
143-
// system_platform view/update-trigger work and may be narrower now that template_id is updated on system_patch.
144142
siSub := tx.Model(&models.SystemInventory{}).
145143
Select("id").
146144
Where("rh_account_id = ? AND inventory_id IN (?::uuid)", accountID, inventoryIDs)

0 commit comments

Comments
 (0)