Skip to content

Installer: validate CMDB data before publishing and roll back on a policy refusal #57

Open

Description

@djbclark

deploy/linux/tendcf-install.sh (put_data,

}
put_data() { # put_data FILE
local src="$1" backup=""
[ -f "$src" ] || die "no such data file: $src"
if [ -f "$data" ]; then
backup="$data.previous"
cp -p "$data" "$backup"
fi
# Write beside the live file, then rename over it: the agent (cf-execd runs
# it on a schedule) never reads a half-written host_specific.json, and the
# loader and the policy's cross-check cannot see two different halves.
local tmp="$data.new"
if ! install -m 0600 -o root -g root "$src" "$tmp"; then
rm -f "$tmp"
die "could not write $tmp"
fi
mv -f "$tmp" "$data"
if ! "$cf_promises" -f "$entry" >/dev/null; then
if [ -n "$backup" ]; then mv -f "$backup" "$data"; else rm -f "$data"; fi
die "cf-promises rejected $src; previous data restored"
) publishes the new CMDB data, then runs cf-promises and checks only its exit status.

  1. A syntactically valid projection that the policy refuses (tendcf_cmdb_refused) passes cf-promises. The script prints "data installed" and leaves a host on which every run refuses. That fails closed, but nobody is told and nothing rolls back.
  2. The new data is live before validation, so an agent run in that window acts on unvalidated data.

Wanted: validate the staged candidate before publication, and detect a policy refusal explicitly (for example cf-promises --show-classes for tendcf_cmdb_refused), with rollback to the backup and a regression test for both.

Related: #53 (the same path skips the projector).

From the round-2/3 reviews of #42 (frontier review C1; adversary r2 I2, r3 I3.2).

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions