feat: validate Gateway= in .network files (route_section gateway ltypes)#475
Open
SJrX wants to merge 1 commit into
Open
feat: validate Gateway= in .network files (route_section gateway ltypes)#475SJrX wants to merge 1 commit into
SJrX wants to merge 1 commit into
Conversation
… gateway ltypes) [Network] Gateway= and [Route] Gateway= mapped to config_parse_route_section with ltypes ROUTE_GATEWAY_NETWORK / ROUTE_GATEWAY, but neither ltype was registered, so Gateway values got no validation at all (resolved to NullOptionValue). This also showed up as the key staying unmarked under the new GrammarEngineKeyAnnotator. Add two grammar validators (reusing the existing IPV4_ADDR / IPV6_ADDR combinators): - ConfigParseRouteSectionGatewayNetworkOptionValue ([Network] Gateway=): IPv4/IPv6 address only — per systemd.network(5) the [Network] short-hand does not take the special tokens. - ConfigParseRouteSectionGatewayOptionValue ([Route] Gateway=): IPv4/IPv6 address or the special values "_dhcp4" / "_ipv6ra". Registered for ROUTE_GATEWAY_NETWORK and ROUTE_GATEWAY in AiGenerated. Works under the default engine and lights up under the experimental key marker (it's a GrammarOptionValue), confirming the pipeline end-to-end. Refs #467 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds value validation for
[Network] Gateway=and[Route] Gateway=in systemd.networkfiles. These map toconfig_parse_route_sectionwith ltypesROUTE_GATEWAY_NETWORK/ROUTE_GATEWAY, but neither ltype was registered, so Gateway values previously got no validation (resolved toNullOptionValue). This is the gap the new key-marker (#474) surfaced whenGatewaystayed un-tinted.Grammars (reusing the existing
IPV4_ADDR/IPV6_ADDRcombinators)Per systemd.network(5):
ConfigParseRouteSectionGatewayNetworkOptionValue—[Network] Gateway=: an IPv4/IPv6 address only. The man page: "the gateway address … This is a short-hand for a [Route] section only containing a Gateway= key." — no special tokens here.ConfigParseRouteSectionGatewayOptionValue—[Route] Gateway=: an IPv4/IPv6 address or_dhcp4/_ipv6ra. The man page: "Takes the gateway address or the special values "_dhcp4" and "_ipv6ra"."Registered for
ROUTE_GATEWAY_NETWORKandROUTE_GATEWAYinAiGenerated.Tests
ConfigParseRouteSectionGatewayOptionValueTest: valid addresses (v4/v6) in both sections + the specials in[Route]→ 0 highlights; and the specials rejected in[Network], a bad address, and_dhcp6in[Route]→ one highlight each. Runs under the default engine; full suite green.Aside (separate, pre-existing)
While here I noticed
config_parse_route_sectionis also registered (inAiGenerated) forROUTE_PRIORITY,ROUTE_NEXTHOP, etc., all pointing atConfigParseRouteSectionOptionValue— which is actually the route-type enum grammar. So e.g. a numeric[Route] Priority=would likely be mis-flagged. That's pre-existing and out of scope here; happy to file an issue if you'd like.Refs #467
🤖 Generated with Claude Code