Skip to content

the observe/apply gap has two more instances #634

Description

@haribo

Two more defs report already over a machine their own apply would have changed. Same
mistake as #594, in defs that epic did not look at.

Found by an external review; each verified in the files.

def apply guarantees observe asks
htpasswd.entry the user's line and the file at 0600 does the stored hash verify
system.timezone /etc/localtime and /etc/timezone what does the link point at

htpasswd.entry is the sharper one: the file it leaves at 644 holds credentials, and the
def's own apply carries the comment "A credentials file readable by anyone is the
credential leaked."
Its observe never checks that the chmod happened.

sudo.write and sshd.config — the two defs shaped like it — both observe a secured
field beside their content field. htpasswd.entry observes one field.

Why this is an epic and not two bugs

Because it is the third time. #486 and #480 were the first, #594 the second with four
defs, and here are two more the sweep missed. The fixes are small; the question worth
answering at the end is not.

test/e2e/adverse-cases.md names the category ("right-shaped but wrong") and holds five
worked examples. What it does not have is a way to find the next one without a human
reading every def. Candidates, to weigh rather than assume:

  • a check that every field an apply writes has a matching field in the observe — not
    decidable in general, but a def whose apply runs chmod and whose observe never reads a
    mode is a shape a linter can see;
  • a sweep asserting, per def, that each of its adverse cases fails when the observe is
    weakened — expensive, and closer to mutation testing than to a gate;
  • or accepting that this is a review discipline and writing it as one, which at least stops
    it being rediscovered by an outside reader every few weeks.

Sub-issues

  • htpasswd.entry does not observe the mode its apply sets
  • system.timezone does not observe /etc/timezone

Locked decisions

  • Each fix arrives with an adverse case verified red first — a weak observe passes its
    unit test by construction, so only a machine in the wrong state proves anything.
  • The observe changes, never the apply. Both applies are correct.

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

    type: bugdefect or malfunction

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions