From f9ebf17d43706e12a981f5eb9c80a6ebebf1b7b0 Mon Sep 17 00:00:00 2001 From: sonicaj Date: Fri, 9 Aug 2024 11:01:26 +0500 Subject: [PATCH] NAS-129590 / 24.10 / Fix querying apps for readonly user (#14172) * Fix app.query with readonly role * Use correct schema name * Cover usages of app_query schema name * Fix schema for active workloads --- src/middlewared/middlewared/plugins/apps/crud.py | 9 +++++++-- src/middlewared/middlewared/plugins/apps/rollback.py | 2 +- src/middlewared/middlewared/plugins/apps/upgrade.py | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/middlewared/middlewared/plugins/apps/crud.py b/src/middlewared/middlewared/plugins/apps/crud.py index 6b0cbf5510617..c044b0989e907 100644 --- a/src/middlewared/middlewared/plugins/apps/crud.py +++ b/src/middlewared/middlewared/plugins/apps/crud.py @@ -29,7 +29,7 @@ class Config: role_prefix = 'APPS' ENTRY = Dict( - 'app_query', + 'app_entry', Str('name'), Str('id'), Str('state', enum=['STOPPED', 'DEPLOYING', 'RUNNING']), @@ -49,14 +49,17 @@ class Config: Str('host_port'), Str('host_ip'), )]), + additional_attrs=True, )]), List('container_details', items=[Dict( 'container_detail', + Str('id'), Str('service_name'), Str('image'), List('port_config'), Str('state', enum=['running', 'starting', 'exited']), List('volume_mounts'), + additional_attrs=True, )]), List('volumes', items=[Dict( 'volume', @@ -64,7 +67,9 @@ class Config: Str('destination'), Str('mode'), Str('type'), + additional_attrs=True, )]), + additional_attrs=True, ), additional_attrs=True, ) @@ -120,7 +125,7 @@ def config(self, app_name): return get_current_app_config(app_name, app['version']) @accepts(Str('app_name'), roles=['APPS_WRITE']) - @returns(Ref('app_query')) + @returns(Ref('app_entry')) @job(lock=lambda args: f'app_start_{args[0]}') async def convert_to_custom(self, job, app_name): """ diff --git a/src/middlewared/middlewared/plugins/apps/rollback.py b/src/middlewared/middlewared/plugins/apps/rollback.py index 4c09d914e54e2..a3683de868563 100644 --- a/src/middlewared/middlewared/plugins/apps/rollback.py +++ b/src/middlewared/middlewared/plugins/apps/rollback.py @@ -23,7 +23,7 @@ class Config: ), roles=['APPS_WRITE'], ) - @returns(Ref('app_query')) + @returns(Ref('app_entry')) @job(lock=lambda args: f'app_rollback_{args[0]}') def rollback(self, job, app_name, options): """ diff --git a/src/middlewared/middlewared/plugins/apps/upgrade.py b/src/middlewared/middlewared/plugins/apps/upgrade.py index 2496198f241b1..0eaf8bd5dd1a8 100644 --- a/src/middlewared/middlewared/plugins/apps/upgrade.py +++ b/src/middlewared/middlewared/plugins/apps/upgrade.py @@ -25,7 +25,7 @@ class Config: ), roles=['APPS_WRITE'], ) - @returns(Ref('app_query')) + @returns(Ref('app_entry')) @job(lock=lambda args: f'app_upgrade_{args[0]}') def upgrade(self, job, app_name, options): """