Commit fbe0f29
* feat: grammar validators for MAC / hardware-address directives (#501)
Nine networkd/.link/.netdev directives took a MAC or hardware address but
had no value validator (key recognized, value accepted unconditionally).
Add grammar-based validators faithful to how systemd actually parses each,
verified against src/basic/ether-addr-util.c.
Two shared combinators:
MAC_ADDRESS — a 6-byte Ethernet MAC (parse_ether_addr): colon,
hyphen, or dot separators.
HARDWARE_ADDRESS — parse_hw_addr_full(expected_len=0): 4/6/16/20-byte
hardware addresses in colon/hyphen (1-byte) or dot
(2-byte) fields, AND — since the parser tries
in_addr_from_string first — IPv4/IPv6 literals.
Wired up (parser, ltype) -> validator:
hw_addrs Match.MACAddress / PermanentMACAddress (list, hw addr)
hw_addr Link.MACAddress (single hw addr)
neighbor_section Neighbor.LinkLayerAddress (+dep MACAddress) (hw addr)
sr_iov_mac SR-IOV.MACAddress (6-byte MAC)
fdb_hwaddr BridgeFDB.MACAddress (6-byte MAC)
dhcp_static_lease DHCPServerStaticLease.MACAddress (6-byte MAC)
netdev_hw_addr NetDev/Peer.MACAddress (6-byte MAC)
macsec_hw_address MACsec*.MACAddress (6-byte MAC)
ether_addrs MACVLAN/MACVTAP.SourceMACAddress (list, 6-byte MAC)
Longest group-count alternatives come first so the classic first-full-match
matcher never stops on a shorter prefix. Purely additive: these previously
resolved to NullOptionValue. Covered by a new-engine grammar test and a
classic-engine inspection wiring test; whole suite green under both engines.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test: verify IPv6 canonicalization composes with hardware-address fields (#501)
Because a HARDWARE_ADDRESS field (Match=, Link=, Neighbor=) accepts IPv6
literals via the shared IPV6_ADDR combinator — which carries SemanticTag.IPV6
— the RFC 5952 canonicalization inspection and its quick-fix work there too.
Add tests proving: a non-canonical IPv6 in Match=/Link= is flagged and
rewritten (including rewriting only the IPv6 within a list, exercising the
quick-fix offset); a plain MAC is untouched; and a strict 6-byte MAC field
(SR-IOV=) never triggers it. Also assert both combinators colour as a single
Role.LITERAL span.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor: wrap only the raw-hex hardware-address forms in the literal label (#501)
HARDWARE_ADDRESS wrapped its whole alternation in Labeled(Role.LITERAL),
but two branches — IPV4_ADDR and IPV6_ADDR — are already Labeled (IPv6 also
carries SemanticTag.IPV6). So an IP literal got a redundant second literal
region over the same span. Move the wrapper down onto just the raw-hex forms
(RAW_HARDWARE_ADDRESS) and let the already-labeled IP forms sit beside it, so
every accepted value now colours as exactly one region. No matching change.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Steve Ramage <gitcommits@sjrx.net>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 946d80c commit fbe0f29
14 files changed
Lines changed: 429 additions & 0 deletions
File tree
- src
- main/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/optionvalues
- ai
- grammar
- test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles
- inspections/ai
- semanticdata/optionvalues/grammar
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
276 | 287 | | |
277 | 288 | | |
278 | 289 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
0 commit comments