mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
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 <noreply@anthropic.com>
This commit is contained in:
parent
468a7a4d12
commit
5a054b97bc
2 changed files with 0 additions and 23 deletions
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue