Skip to content

Feat/validators nspawn - #553

Closed
SJrX wants to merge 7 commits into
242.xfrom
feat/validators-nspawn
Closed

SJrX wants to merge 7 commits into
242.xfrom
feat/validators-nspawn

Conversation

@SJrX

@SJrX SJrX commented Oct 24, 2026

Copy link
Copy Markdown
Owner

No description provided.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Unit Test Results (grammar engine true)

1 388 tests   1 388 ✅  1m 3s ⏱️
  353 suites      0 💤
  353 files        0 ❌

Results for commit d71fa9c.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Unit Test Results (grammar engine false)

1 388 tests   1 388 ✅  1m 5s ⏱️
  353 suites      0 💤
  353 files        0 ❌

Results for commit d71fa9c.

♻️ This comment has been updated with latest results.

@sjrx-claude-sandbox
sjrx-claude-sandbox force-pushed the feat/validators-nspawn branch 3 times, most recently from 55549cb to 992b83a Compare October 24, 2026 17:11
SJrX and others added 6 commits October 24, 2026 11:24
Validators for the 21 (parser, ltype) pairs in nspawn-gperf.gperf that had
none: Capability=/DropCapability=/AmbientCapability=, Volatile=, ResolvConf=,
LinkJournal=, OOMScoreAdjust=, MachineID=, Zone=, Port=, Interface=/MACVLAN=/
IPVLAN=, VirtualEthernetExtra=, Bind=/BindReadOnly=, TemporaryFileSystem=,
Inaccessible=, PivotRoot=, Overlay=/OverlayReadOnly=, BindUser= and
RestrictAddressFamilies=. Each is modelled on the C parser at systemd
0f0682b773 and its leaf helpers, with tests drawn from TEST-13-NSPAWN and
test-id128.c.

Shared helpers live in BatchNspawnCombinators.kt: a safe_atoi/safe_atou number
terminal (sign, 0x, octal, 0o, 0b), a case-insensitive parse_boolean, a
colon-delimited interface name, colon-field path terminals, strict user names,
128-bit IDs and the case-insensitive, prefix-optional address family names.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- VirtualEthernetExtra=: the container-side field honours backslash
  escapes like extract_first_word(), so `a:b\:c` is accepted.
- safeAtoNumber: accept a sign after the 0b/0o prefix (`0b-1`), which
  strtol() in base 2/8 takes after mangle_base() strips the prefix.
- Interface names: refuse spellings parse_ifindex() reads as a positive
  index (`0x10`, `+5`, `0o7`, `0b1`), as ifname_valid() does.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Several batch branches declared public helpers with the same name in the
shared grammar package (SafeAtouTerminal, UINT32_LIMIT, safeAtou,
SafeAtoNumberTerminal, BOOLEAN_ANY_CASE, COALESCED_COLONS). Each branch
compiled alone but any two merged together would not. Prefix them per
family so the batch PRs can merge in any order; consolidating them into
Combinators.kt is left for a follow-up.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Checked against fuzz-nspawn-settings built at 0f0682b773:

- OOMScoreAdjust= and Port= accept whitespace between a 0b/0o prefix
  and the digits (strtol skips it), e.g. `0b 1`, `tcp:0o 120`.
  Capability= keeps the strict form, since the word split comes first.
- Interface=/MACVLAN=/IPVLAN= refuse a name that runs into whitespace
  after a backslash run whose length is not a multiple of 4. Each word
  is unescaped twice, so `a\ b` is the invalid name "a b" and `a\\ b`
  leaves a dangling backslash.
- Bind= option-list checks are now a separate test that states they
  fail only at container start (parse_mount_bind_options), not at
  parse time.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
242.x now makes BOOLEAN case-insensitive, so the batch's own
CASE_INSENSITIVE_BOOLEAN copy and the enumWithBoolean() helper are gone.
LinkJournal=, ResolvConf= and Volatile= now spell out
PreferValidAlternativeCombinator(names, BOOLEAN) inline, with the
boolean spellings (off; no/yes) dropped from the case-sensitive names.

Tests gain mixed-case booleans (Yes, TRUE, oFf) and mixed-case names
that must stay invalid, all confirmed with fuzz-nspawn-settings at
0f0682b773.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Replace the branch-local NspawnSafeAtoNumberTerminal, safeAtoNumber(),
SAFE_ATO_SHAPE/NSPAWN_SAFE_ATO_SHAPE_SPACED, safeAtoValueOf() and
isPositiveIfindex() with the shared SafeAtoTerminal, written out at each
call site:

- OOMScoreAdjust=: signed, -1000..1000, whole value.
- Port=: parse_ip_port, REFUSE_LEADING_WHITESPACE, 1..65535.
- Capability=: signed, 0..62, whitespace-split word.
- Interface names: parse_ifindex via SafeAtoTerminal.valueOf().

Now accepted, matching sd-check: OOMScoreAdjust=\v5, \v-5, \f-1000;
Port=\v80, tcp:\v80:81, 80:\v81, and the strtoul wrap-around
0b -<2^64-80 in binary> (port 80).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
bind_mount_parse() stores everything after the second colon verbatim, so
the settings parser accepts any option string; only
parse_mount_bind_options() rejects unknown options when the container
starts. Keep the known options as the first alternative for completion
and highlighting, and accept any other option string. Paths and field
counts are still checked as bind_mount_parse() does.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@SJrX SJrX closed this Oct 24, 2026
@SJrX
SJrX deleted the feat/validators-nspawn branch October 24, 2026 20:38
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