Expected Behavior
create_test strips directories from test_name with os.path.basename so a name cannot leave the app tests/ folder.
GET, DELETE, and rebuild of a single test should use the same rule.
Actual Behavior
On main @ b018062, only create_test calls os.path.basename. delete_test, get_test_content, and rebuild_app_tests join test_name as given.
A percent-encoded path segment ../outside.json (%2e%2e%2foutside.json) on DELETE/GET is joined onto tests/ and can read or remove a JSON file in the agent directory, outside tests/.
rebuild?test_name=../outside.json does the same for the rebuild path.
This is the local adk web server. It is unauthenticated. Default bind is loopback. It still matters when --host 0.0.0.0 is used, or when anything else can hit those routes.
Steps to Reproduce
adk web (or the TestClient in tests/unittests/cli/test_adk_web_server_tests.py)
- Put
outside.json in the agent directory, not in tests/
DELETE /dev/apps/<app>/tests/%2e%2e%2foutside.json
- On current
main, that file is removed. After sanitising with basename, the request 404s and the file stays.
I can send a PR that shares one helper with create_test and adds those cases to test_adk_web_server_tests.py.
Expected Behavior
create_teststrips directories fromtest_namewithos.path.basenameso a name cannot leave the apptests/folder.GET, DELETE, and rebuild of a single test should use the same rule.
Actual Behavior
On
main@b018062, onlycreate_testcallsos.path.basename.delete_test,get_test_content, andrebuild_app_testsjointest_nameas given.A percent-encoded path segment
../outside.json(%2e%2e%2foutside.json) on DELETE/GET is joined ontotests/and can read or remove a JSON file in the agent directory, outsidetests/.rebuild?test_name=../outside.jsondoes the same for the rebuild path.This is the local
adk webserver. It is unauthenticated. Default bind is loopback. It still matters when--host 0.0.0.0is used, or when anything else can hit those routes.Steps to Reproduce
adk web(or the TestClient intests/unittests/cli/test_adk_web_server_tests.py)outside.jsonin the agent directory, not intests/DELETE /dev/apps/<app>/tests/%2e%2e%2foutside.jsonmain, that file is removed. After sanitising withbasename, the request 404s and the file stays.I can send a PR that shares one helper with
create_testand adds those cases totest_adk_web_server_tests.py.