fix: start pull events when the pull begins and reject unsafe image names

The pull started event was emitted by the route before the pull took
its per compute lock, so a request queued behind another pull claimed
to be running while it was still waiting. The pull now reports the
started state itself, once it owns the lock.

Deleting an image interpolates the name into the daemon API path. The
pattern on the path parameter limits it to the characters of an image
reference and validate_docker_image_name also rejects "..", so a name
cannot escape that path. Applied on both the controller and compute
routes.
This commit is contained in:
YueGuobin committed 2026-11-06 15:42:51 +08:00
1 parent d5d25eba06
commit 04a8ba06a8
7 files changed
+99 -18

No files matched your search

+8 -2
View File
@@ -207,8 +207,14 @@ async def test_pull_image_reports_aggregated_progress():
with asyncio_patch("gns3server.compute.docker.Docker.http_query", return_value=response):
await Docker.instance().pull_image("ubuntu", progress_callback=progress.append)
# the callback sees the running totals of layers, not raw daemon lines
assert progress[0] == {"layers_total": 1, "layers_done": 0, "message": "Pulling fs layer"}
assert progress[1] == {"layers_total": 2, "layers_done": 0, "message": "Pulling fs layer"}
assert progress[0] == {
"layers_total": 0,
"layers_done": 0,
"message": "Pulling 'ubuntu' from Docker repository",
"state": "started",
}
assert progress[1] == {"layers_total": 1, "layers_done": 0, "message": "Pulling fs layer"}
assert progress[2] == {"layers_total": 2, "layers_done": 0, "message": "Pulling fs layer"}
assert {"layers_total": 2, "layers_done": 0, "message": "[==> ] 40/100"} in progress
assert progress[-1] == {"layers_total": 2, "layers_done": 2, "message": "Pull complete"}