Repository navigation
fix: harden the deploy agent and its trigger, back up volumes through container labels - #45
Merged
Merged
Conversation
…ough container labels The agent caps the request body, times out stalled clients, serves health while a deploy runs, refuses a replayed signature, and drops /reapply, CONSOLE_TOKEN and the secrets action. graphite-up and compose run without the agent's environment. Every project but console, edge and backup gets a policy: no privileged or host settings, no host paths, ports, env_file or foreign volumes and networks, and a route only for its own hostnames and containers. deploy.py sends compose and the route as JSON for it. The public route to the agent passes only /deploy and /healthz. A bot push may change only IMAGE_TAG lines before Deploy runs. Existing volumes cannot take new labels, so the backup service reads the volumes to keep from graphite.backup.volumes on the container that mounts them.
… console's redeploy hint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes from the review of the deploy agent, plus the volume backup labels that existing volumes could not take.
Agent (
host/agent.py)console,edgeandbackupis checked before anything is written: noprivileged,pid,ipc,uts,userns_mode,network_mode,cgroup,cap_add,devices,volumes_from,sysctls,ports,build,env_file, nosecurity_optbeyondno-new-privileges, bind mounts only under./, no external, foreign or driver-option volumes, only the externaledgenetwork, config files only under./and never from the environment. The list of projects with host access lives inagent.pyon the host, so CI cannot change it.Host(...)rules, may not name a hostname another route file already holds, and may only send traffic to its own containers (http://<project>:portor<project>-*).${DEPLOY_TOKEN}would have reached a container.graphite-upandcompose downnow run with onlyPATHandHOME.Content-Lengthis required and capped at 4 MiB; clients time out after 30 s; a threaded server keeps/healthzanswering while one lock keeps deploys serial./reapplyexposedCONSOLE_TOKEN; the console redeploys through a host unit instead (console PR). The public route now passes only/deployand/healthz.secretsactionscripts/agent.py'ssecretscommand. Thesecretsrepository's Apply workflow fails from now on; disable it.Containers on the host can still reach
172.17.0.1:9000; with/reapplygone, only signed/deployrequests do anything there.Deploy trigger
The
graphite-deployapp can push tomainpast review (it is a bypass actor) and every project's CI can mint its token, so a compromised project CI could push any file and Deploy would run it. The app has noworkflowspermission, sodeploy.ymlis the place to check: a push by a bot now fails Deploy unless it changes onlyIMAGE_TAG=sha-…lines indeploy/*/values.projects/**no longer triggers Deploy, so registry syncs never deploy on their own; deploy by hand after a hosting change.Backups
Docker cannot add labels to existing volumes, so the deploys kept
console_dataandstrata_files-datawithoutgraphite.backupand printed a recreate prompt each time. The label moves to the container:graphite.backup.volumes: <volume>[,<volume>]on the service that mounts them, whichbackup.pyreads.Redeploy hint
graphite-uptouches/srv/graphite/<project>/.appliedafter a successfulup. The console compares a project's env file with it, so a redeploy that recreates nothing (a secret no container reads) still clears "needs redeploy".Rollout
After merge, install the new agent and edge route over SSH, then run Deploy with project
all:CONSOLE_TOKENcan be deleted from/agent/in the console.Checks
The policy was run against the flattened compose and route of Strata, Tracker and PixelPocket (no findings) and against a crafted compose and route (each rule caught); a replayed signature is refused.
deploy.py check,check-values.py,check-memory.pypass.