Files
devvm/docs/content/docs/getting-started
w3cjandClaude Opus 5.5 487366d186 fix(netpolicy): one strict parser for policy files, lines that aren't rules named, broken denies fail closed
The proxy read policy files with a laxer parser than devvm network allow's
check: a line that wasn't a rule was dropped without a word, or kept as a
rule that matched nothing (example.com:x became a host of that name, a
rule's trailing dot never matched), so a hand-edited deny could lapse
unseen. proxy.ParsePolicy is now the one parser: it returns each line
that holds more than a comment, with its number and whether it's a rule,
and a line is a rule only when ValidRule takes it, which is what devvm
network allow and deny take. parseRule is strict: ports 1 to 65535 in
digits, printable ASCII names with no empty label, brackets for IPv6
alone, no address under *., IPv4-mapped prefixes as their IPv4 ones, and
one trailing dot dropped, as requests' are.

A line that isn't a rule but starts with ! (proxy.BrokenDeny) fails
closed: while any of a VM's policy files has one, its proxy denies every
name and address, each request getting 403 and a refused block that names
the file and line, with no allow advice (block honours Refused;
policy.verdict and checkRefused carry it). Other lines that aren't rules
are skipped. The proxy logs each one, devvm network marks it (its control
characters dropped, msg.OneLine) and --json lists it in not_rules.
netpolicy.PolicyWarnings warns of each (policy_broken_deny or
policy_not_rule): at each launch with network policy (Proxy.Prepare),
after devvm network allow, deny and rm for the file they change, and in
devvm doctor for the files you edit (NotRules). AddRule and RemoveRule
find rules through ParsePolicy, so ruleOf is gone. A policy file that
comes back after it was missing is read again whatever its mtime, an
error other than a missing file keeps its last rules and broken deny, and
a leading byte-order mark isn't part of the first line.

Docs: rules, broken denies and devvm network's output (safety network),
the parser and the fail-closed policy (internals network), doctor's
warnings (install, internals install), the e2e network section
(contributing), the proxy's README.

Tests: TestParsePolicy, TestPolicySkipsBadLines, TestPolicyBrokenDeny,
TestPolicyFileBack,
TestValidRule's new cases and FuzzParseRule's agreement and host
properties (proxy); TestBuiltinPolicies, every policy file devvm ships,
TestNotRules, TestPrepareWarnsPolicy, TestWriteRules and
TestAddRemoveRule's new cases (netpolicy); TestDoctorReport and the
network JSON shape (cli); network_rules.txtar's mark, not_rules and the
warnings on a change, a launch and in doctor; e2e network: a broken deny
makes the running proxy refuse an allowed host until it's gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 18:23:22 -07:00
..