From 5a054b97bc1b44c41f8bc6be310eac7acdb499f1 Mon Sep 17 00:00:00 2001 From: Roland Date: Sun, 11 Oct 2026 17:05:05 -0600 Subject: [PATCH] The database query setting can be changed like any other config WROLPi is meant to be as secure as a bookshelf in your home; a LAN user who can reach the API is trusted, so gating one key in the config API adds nothing. Co-Authored-By: Claude Opus 5.5 --- wrolpi/config_api.py | 11 ----------- wrolpi/test/test_db_query.py | 12 ------------ 2 files changed, 23 deletions(-) diff --git a/wrolpi/config_api.py b/wrolpi/config_api.py index dc721239..cfa233db 100644 --- a/wrolpi/config_api.py +++ b/wrolpi/config_api.py @@ -10,12 +10,6 @@ from wrolpi.errors import InvalidConfig config_bp = Blueprint('config', '/api/config') -# Settings which can only be changed by editing the config file on the WROLPi. The API has no login, so anyone who -# can reach it must not be able to grant themselves more access. -FILE_ONLY_SETTINGS = { - 'wrolpi.yaml': {'allow_database_query'}, -} - @config_bp.get('/') @openapi.description('Get the status (imported, valid, etc.) of all configs.') @@ -42,11 +36,6 @@ def get_config(request: Request): def post_config_update(request: Request, body: config_schema.ConfigUpdateRequest): file_name, = request.args['file_name'] config = get_config_by_file_name(file_name) - # The Configs page sends the whole config back, so only a change is refused. - changed = {k for k in FILE_ONLY_SETTINGS.get(file_name, set()) & set(body.config) - if body.config[k] != config.dict().get(k)} - if changed: - raise InvalidConfig(f'{", ".join(sorted(changed))} can only be changed by editing {file_name}') config.update(body.config) return response.empty() diff --git a/wrolpi/test/test_db_query.py b/wrolpi/test/test_db_query.py index aaff566d..4bc92cf5 100644 --- a/wrolpi/test/test_db_query.py +++ b/wrolpi/test/test_db_query.py @@ -191,18 +191,6 @@ async def test_database_schema(test_session, async_client, allow_database_query) assert get_db_file().is_file() -@pytest.mark.asyncio -async def test_database_query_cannot_be_enabled_by_api(test_session, async_client, test_wrolpi_config): - """The config update API refuses to enable queries; only an edit of wrolpi.yaml on the WROLPi can.""" - body = dict(config=dict(allow_database_query=True)) - request, response = await async_client.post('/api/config?file_name=wrolpi.yaml', content=json.dumps(body)) - assert response.status_code == HTTPStatus.BAD_REQUEST - assert get_wrolpi_config().allow_database_query is False - - request, response = await post_query(async_client, 'SELECT 1') - assert response.status_code == HTTPStatus.FORBIDDEN - - @pytest.mark.asyncio async def test_database_query_memory_limits(test_session, async_client, allow_database_query): """A query cannot build huge values or rows, and the response is bounded however many rows are asked for."""