Skip to content

firru 1.2.0: site/ configuration, propose and check, edit verbs - #20

Merged
ppietikainen merged 11 commits into
mainfrom
release-1.2
Nov 23, 2026
Merged

ppietikainen merged 11 commits into
mainfrom
release-1.2

Conversation

@ppietikainen

Copy link
Copy Markdown
Member

Commands that changed or went:

  • firru tighten --policy P … → firru propose P …. Each edit is printed as a firru command ending in its reason, and the proposals are still written to proposals/ (-o yaml writes only those). Choosing a posture is a grep: | grep observed | sh applies the narrowings, and | grep -e observed -e unexercised | sh also denies, logged, the listeners nothing reached. Widenings, egress terms and anything the site declares or scores are printed as comments, so | sh on the whole output never runs them. A pinned edit (declared or scored) is printed commented out with its reason; grep pinned lists them, and dropping the leading # is the deliberate act.
  • firru tighten --check → firru check P: what each policy refuses of the traffic, split into answered (would break) and unanswered. It exits 1 when an answered flow is refused.
  • firru apply → the edit verbs: remove-source and add-source (-dest for egress), set-action TERM deny --log, and add-term POL TERM --from NEW (--replace OLD for a rename). --narrow, --prune and --base have no replacement; their edits are now lines of propose's or diff's -o sh output.
  • firru score → scored(host, metadata) in site/policy.py, which reads the site's scoring list wherever it keeps it. propose never edits a term covering a scored port by itself: it prints the edit commented out, tagged pinned.
  • firru diff --baseline or --closest → firru loot-diff --baseline or --closest. diff now refuses two loots and points to loot-diff.

Configuration:

  • Inside a project (firru.toml), site/heuristics.py, site/policy.py and site/host_metadata.json are found without flags. A missing file is reported once per run, with what its absence costs.
  • site/policy.py holds what the site decides: who may administer a host, and the ports that must stay open.
  • Check this when upgrading: a site's own heuristics.py no longer inherits the SSDP deny or the mDNS/LLMNR link-local scoping. Copy them from firru's def/heuristics.py, as the LSPR24 and fleet-zones examples now do.

Checked on LSPR24 (night window):

  • The proposals match what tighten wrote for all 59 hosts.
  • The command stream has 83 narrowings and 193 denies as runnable lines. 34 widenings, 80 pinned terms and 325 egress terms are comments.
  • All 276 runnable lines apply through firru mass and all 59 policies compile.
  • check on dc1, trained on the night window and checked against the first live hour, finds 1,216 refused flows, 7 of them unanswered.

🤖 Generated with Claude Code

ppietikainen and others added 11 commits November 23, 2026 14:53
Inside a project, firru now reads site/ beside firru.toml the way it
already reads def/: site/heuristics.py (before def/heuristics.py, which
still works) and site/host_metadata.json for synth. A flag still names
another file for one run. A missing file is said once per run where its
absence costs something ("synthesis knows no zones"); an empty one is
the site saying none.

The README's "A project" section says what goes where.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What the site decides, as opposed to what heuristics.py guesses, goes in
site/policy.py beside it. MGMT_SERVICES, MGMT_ANY_FALLBACK and
management_sources are that kind of decision, so site/policy.py may set
them and is read first; heuristics.py is still read for them where a
site has not moved them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SSDP deny and the mDNS/LLMNR link-local tokens were tables in
src_heuristics.py, applied under every site's own heuristics.py. They are
sane defaults, but still configuration, so the stock def/heuristics.py
now sets them: a project without site/heuristics.py gets that file as it
is, and a project with one gets only its own. Nothing is layered
underneath. The shipped file is the template to copy into site/ and edit,
and its management example says that belongs in site/policy.py.

The LSPR24 and fleet-zones examples keep both tables in their own files;
without them examples/check.sh shows fleet-zones' firewalls losing the
SSDP deny and the link-local scoping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- site/policy.py: who may administer a host (MGMT_SERVICES,
  management_sources). Nobody here decided it; it is what the case study
  assumes, each assumption in assumptions.yml with its source.
- site/heuristics.py: what holds by definition, the shipped template's
  SSDP and link-local settings and NetBIOS/discovery scoped to the zone.
- host_metadata.json stays in def/: it is inventory, written from the
  dataset with networks.yml.
- The README says which hand-written files add facts (two) and which are
  configuration.
- synth names the site policy it read beside the source policy.

r1 and r2 are byte-identical before and after (59 hosts, night window).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- remove-source / remove-destination narrow by the peers named, and
  add-source / add-destination widen by them. A line edits only what it
  names, so it holds on a policy edited by hand since it was written, and
  lines apply in any order or one at a time. Removing the last peer makes
  the term a logged deny: an empty list would be ANY. Removing from ANY is
  refused (set-source narrows it).
- set-action TERM accept|deny|reject [--log|--no-log] keeps the term, so
  what it refuses can be logged. A term with a [score] note is not denied
  without --force, as rm already refuses to remove one. logging goes
  beside the action, so the term's trailing comment stays last.
- apply's merge modes go: --base, --narrow, --prune and its floor,
  --scoring and --dry-run. Nothing ran them; each edit they made is now a
  line of an -o sh stream. What was still used, copying a term by name
  from a policy or loot, is add-term POL TERM... --from NEW, with
  --replace OLD for a rename that keeps the ports (a regroup that would
  widen the old term is refused). diff -o sh emits it for added terms,
  renames and the terminal swap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- firru propose POLICY... (tighten renamed; the policies are positional)
  writes each host's proposal to proposals/ as soon as it is read and,
  with -o sh (the default), prints the edits as firru commands, one per
  line, each ending in its reason. A posture is a grep: `grep observed`
  takes the narrowings, `grep -e observed -e unexercised` also denies,
  logged, the listeners nothing reached. -o yaml writes the proposals
  only. A widening, an egress term and anything the site declares or
  scores are comments, so `| sh` on the whole output never widens, never
  adds egress and never touches them.
- Ingress is compared term by term, by name: two terms can cover one port
  (a tcp+udp service beside a tcp-only term), and a comparison by port
  folds them into one and drops a change. Gaining an address family is a
  widening: ANY_V4 compares as ANY, so ANY_V4 -> [hosts with v6
  addresses] would otherwise read as a runnable narrowing. A narrowing to
  a subset of the term's tokens is remove-source; from ANY, or a group
  replaced by its members, set-source.
- firru check POLICY... is tighten --check: what each policy refuses of
  the inbound traffic, split into answered (would break) and unanswered
  (agrees). Flows that record no answer count as answered. Exits 1 when
  an answered flow is refused.
- tighten, --check and --dry-run go. propose and check share the flow
  source and host resolution (add_flow_arguments, open_flows).

LSPR24, r1 against the night window: the proposals are tighten's, header
aside, for all 59 hosts; the stream holds 83 narrowings and 193 denies
(runnable), 34 widenings, 80 pinned and 325 egress lines (comments).
Every runnable line through firru mass: 276 ok, all 59 policies compile,
and each ingress term then equals the proposal but for the 34 widenings.
check on dc1's r2 against d2 08:00-09:00: 1,216 refused, 7 unanswered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What must stay open, such as the ports an availability check scores, is
a decision the site makes, so site/policy.py says it:
scored(host, metadata) gives (protocol, port[, note]) pairs, read from
wherever the site keeps them (an export as it is, in the site's own
code). propose leaves a term covering one as it is, narrowed or not,
exercised or not, with a `# pinned` line naming the port. heuristics.py
cannot score.

firru score and firru.scoring go: the site reads its list itself. A
term's [score] note stays what rm, set-action and propose read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… writes

- diff needs a policy on one side. Two loots would compare what the
  heuristics make of each listener, losing its process and bind address,
  so diff refuses them and names loot-diff, which compares the listeners.
  A policy against loot, a stock baseline among them, stays diff's.
- `firru diff --baseline` / `--closest` no longer turn into loot-diff:
  -o sh means policy edits from diff and a review script from loot-diff,
  so which one ran should not depend on a flag. The docs and the fleet
  example say loot-diff.
- The help groups commands by what they write: propose (new files only),
  edit a policy (one class of change per verb), compare and check
  (read-only), flows. diff was listed under editing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The module turns site/heuristics.py (the site's guesses) and
site/policy.py (its decisions) into one Profile and holds the contract
for both; "source heuristics" was the first half of that. Nothing a site
writes imports it, so only firru's own imports and the comments that
point at the contract change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A term the site scores, or one carrying a [score] note, or one whose
sources the site declares, is never edited automatically. propose used
to say only that it was kept; it now prints the edit it would make,
commented out and tagged `pinned` with the reason:

  # firru remove-source POL TERM PEER  # pinned, narrowed: [..] -> [..];
  #   the site scores tcp/443 (Scored: ...)

The reason avoids the posture words, so `grep observed` and `grep -e
observed -e unexercised` never take one; `grep pinned` lists them, and
dropping the leading `# ` is the deliberate act. A deny on a term with a
[score] note carries --force, which set-action needs for it. A term with
a [score] note is now pinned for narrowings as well as denies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ppietikainen
ppietikainen merged commit 1376679 into main Nov 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant