Repository navigation
Conversation
| # (PUT, DELETE .../executions/{id}). "*" is one segment, so an operation | ||
| # id containing "/" is held only by the per-client limit. | ||
| endpoint_limits: ["/api/v1/*/*/operations/*:30", "/api/v1/*/*/operations/*/executions:30", | ||
| "/api/v1/*/*/operations/*/executions/*:30"] |
There was a problem hiding this comment.
The limiter does not look at the method, so this entry also meters GET .../executions/{id}, the status poll, in the same bucket as PUT and DELETE. A client polling an async execution at 1 Hz empties the 30/min bucket in about a minute, and its cancel can then get 429. Drop this entry until the limiter can match on method, or raise it so polling fits, and add a test that a cancel still passes after polling.
| client_requests_per_minute: 120 | ||
| # Tighten mutating endpoints (operations / data writes). | ||
| endpoint_limits: ["/api/v1/*/operations/*:30"] | ||
| # Operation calls: start (.../operations/{op}, .../executions) and control |
There was a problem hiding this comment.
No route starts an operation at .../operations/{op}. The only handler there is GET operation detail, so /api/v1/*/*/operations/*:30 limits a read. Drop that entry, or keep it and say here and in hardening.rst that it limits detail reads.
| ``locking`` on operations none lock required for component and app operations | ||
| ================================ ============== =========================================== | ||
|
|
||
| ``rate_limiting`` is 600 requests per minute for the gateway, 120 per client and 30 per |
There was a problem hiding this comment.
Each endpoint pattern has its own bucket (client_ip + "|" + matched_pattern), and those calls use it instead of the 120/min client bucket. So a client gets 30/min per pattern, not 30 across operation calls. Please say "30 per client per pattern, outside the 120" here, and fix the "start" label of the first pattern as in the yaml.
| # One request per pattern, built from the real route template: method and path. | ||
| OPERATION_REQUESTS = { | ||
| '/api/v1/*/*/operations/*': | ||
| ('POST', f'{API_BASE_PATH}/apps/app1/operations/calibrate'), |
There was a problem hiding this comment.
There is no POST route at .../operations/{op}, so this case passes on 404/405 answers followed by 429. Use GET here, the only method on that path, and assert the expected status before the 429, not only "not 401/403".
| AREAS = f'{API_BASE_PATH}/areas' | ||
| HEALTH = f'{API_BASE_PATH}/health' | ||
| VERSION_INFO = f'{API_BASE_PATH}/version-info' | ||
| WRITE_ROUTE = f'{API_BASE_PATH}/components/test/operations/calibrate' |
There was a problem hiding this comment.
WRITE_ROUTE is a POST to .../operations/calibrate, which has no handler. The viewer gets 403 from deny-by-default on an unknown key and the admin passes on 404 through POST:/api/v1/**. Point it at .../operations/calibrate/executions so the test checks the operator requirement of a real write route.
| docker cp gateway_params.secure.yaml medkit:/etc/ros2_medkit/params.yaml | ||
| tar --owner="$(docker run --rm --entrypoint id "$IMAGE" -u)" \ | ||
| --group="$(docker run --rm --entrypoint id "$IMAGE" -g)" \ | ||
| -cf - certs | docker cp - medkit:/etc/ros2_medkit |
There was a problem hiding this comment.
generate_dev_certs.sh writes ca_key.pem and client-key.pem into the same certs/, and this tar ships all of it into the container, owned by medkit. If mTLS trusts that CA, its key can mint accepted client certificates. Tar only cert.pem and key.pem here and at hardening.rst:51, plus ca.pem when mTLS is on.
| cls.gw.__exit__(None, None, None) | ||
| raise AssertionError(f'secure gateway did not start: {output}') | ||
| cls.port = cls.gw.port | ||
| cls.admin = _login(cls.port, ADMIN) |
There was a problem hiding this comment.
If a login fails here, tearDownClass does not run and the gateway, started in its own session, keeps running. Register cls.addClassCleanup(cls.gw.__exit__, None, None, None) right after the start and drop the manual cleanup and tearDownClass, so __exit__ runs once.
Pull Request
Summary
A new test starts the gateway from the installed
gateway_params.secure.yaml, with the secrets only inMEDKIT_JWT_SECRETandMEDKIT_CLIENTSand a generated certificate. It checks each control the profile turns on:/api/v1/auth/*;The test also pins the security values of the file, so a weaker file fails it.
The image smoke script runs the image with the profile as its params layer.
rate_limiting.endpoint_limits:*matches one path segment, so/api/v1/*/operations/*matched no route. The profile now limits the operation routes (start and control) to 30 requests per minute per client. The examples in the docs now match a real route.The profile's comments name
MEDKIT_JWT_SECRETandMEDKIT_CLIENTS. The profile listsauth.public_routes(empty), with a health example for a probe.docs/tutorials/docker.rstshows how to run the image with the profile.scripts/generate_dev_certs.shis now executable. It also writes a client certificate (client.pem,client-key.pem) for mutual TLS. The docs list the files it really writes (ca.pem,cert.pem,key.pem); before, they named files it never wrote.Breaking changes:
Issue
Type
Testing
In a second shell:
The image:
docker build -t medkit-test . && scripts/smoke_image_auth_posture.sh medkit-test.Checklist