mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
* feat(ecs): implement ExecuteCommand ECS Exec was accepted at the API but opened nothing: a client got a response it could not connect to. This implements the whole path, so `aws ecs execute-command` gives a real shell in a task's container. The gate matches AWS. The session must be interactive, which is the only mode ECS supports; the task must belong to the cluster the request names, must be RUNNING and must have been run with enableExecuteCommand; and the container must have a runtime behind it, so a mock-mode task answers TargetNotConnectedException. The response carries a session with a single-use tokenValue and a streamUrl pointing at Floci's own data channel, which is where session-manager-plugin then connects. Floci plays the SSM agent's half of the Session Manager protocol on that channel, the binary AgentMessage framing, the handshake, sequenced acknowledgements and terminal resizes, and bridges it to a docker exec with a TTY. Two threads meet on that channel. Every call into the Docker daemon blocks, so it runs on a worker rather than on the event loop, and the daemon streams the container's output back on its own thread; frames are written from the channel's Vert.x context only, which also keeps the outbound sequence numbers in the order they reach the wire. The command is attached to only once the client has accepted the handshake, so no output can be written to a channel that is still being opened. Deliberate limits, documented in docs/services/ecs.md: - The command runs through /bin/sh -c, so an image without a shell cannot be exec'd into. - Sessions are in memory, single use, and expire after five minutes if nobody connects. - ExecuteCommand logging, the executeCommandConfiguration that sends session transcripts to S3 or CloudWatch, is not implemented. The cluster field still round-trips. EcsExecSessionRegistry holds a SecureRandom, so it is registered under --initialize-at-run-time for the native image. AgentMessageTest covers the wire framing against a JDK-side encode and decode, EcsExecuteCommandIntegrationTest covers the API gate, and EcsExecChannelDockerIntegrationTest runs a real session end to end under Docker. * fix(ecs): compare the ECS Exec session token in constant time The token is the single gate in front of an interactive shell in a container, so compare it with MessageDigest.isEqual on the UTF-8 bytes rather than String.equals, which returns on the first differing character. Matches the constant-time comparison the repo already does in ScimController, IamAuthValidator and LambdaLayerService. A failed claim still leaves the session in place: dropping it would let anyone holding a session id cancel somebody else's session. * fix(ecs): expire an unclaimed ECS Exec session on read Only create() swept the session map, and neither claim() nor find() looked at createdAt, so a session nobody connected to stayed claimable, token included, until the next ExecuteCommand call happened to come in. On an idle emulator that is forever, which also made the five minute expiry documented in docs/services/ecs.md untrue. claim() and find() now go through liveSession(), which drops a session past SESSION_TTL and reports it as gone: claim() rejects it before the token comparison, and the WebSocket upgrade refuses to open a channel for it. The registry takes the CDI Clock so the tests exercise expiry without waiting out the TTL.