Repository navigation
Read the plugin protocol's stanzas with the header's parser - #148
Merged
Merged
Conversation
No change in behaviour: the first step towards reading the plugin protocol's stanzas with the same parser, as go-age does (finding S6 of the 2026-11-30 review). Stanza.Read takes the opening line and a way to get the next one, and Header.Parse hands it the line it has already read, so HeaderReader's push-back is gone. The decoded body lines are now cleared once joined, which the plugin side needs and the header side does not mind.
Finding S6 of the 2026-11-30 review. The plugin channel had a stanza parser of its own, laxer than the header's: a CR ended a line, a byte outside ASCII became a question mark on the plugin's side, a stanza could have any number of arguments, and a last line cut off by the end of the output counted as whole. go-age reads files and plugins with one parser. StanzaChannel now reads through Stanza.Read and the header's line rules, a character at a time so that a CR is seen rather than taken for a line ending, and from Latin-1 readers so that each byte arrives as itself. Of the header's framer it uses the rules only: nothing is recorded and no total applies. A stanza may have the header's 128 arguments and the two a forwarded one gains. A malformed stanza is reported in the parser's words, with who sent it in front; output that ends partway through a stanza is reported as that, with the plugin's stderr. The three places that parsed a plugin's key strings are one, PluginKeys, which also checks their case as go-age does: a recipient is lowercase, an identity uppercase. The fuzzer follows the cause of a plugin exception, and of a malformed stanza the plugin reports, so that it still tells them apart.
The process tests' plugins on Windows are batch scripts, and cmd's echo ends a line with CRLF. The protocol's lines end with LF alone, and a CR is now refused, as go-age refuses it, so six of them failed there. Each script now keeps its answer in a file and writes it out with `type`.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #148 +/- ##
==========================================
+ Coverage 97.51% 97.70% +0.19%
==========================================
Files 76 77 +1
Lines 5074 5064 -10
Branches 699 692 -7
==========================================
Hits 4948 4948
+ Misses 77 70 -7
+ Partials 49 46 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The plugin channel relies on both: a line there may hold a file key, and a session has no fixed length. Nothing held the framer to it.
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.
Finding S6 of the 2026-11-30 review, in two commits so that the header side can be judged on its own.
The problem
The plugin channel had a stanza parser of its own, laxer than the header's. go-age reads files and plugins with one parser.
?before any rule saw it, and passed.PluginRecipient.Parseaccepted an uppercase recipient andPluginIdentity.Parsea lowercase identity, andAgePluginaccepted both.Commit 1: the header's parser can read from any source of lines
No change in behaviour.
Stanza.Readtakes the opening line and a way to get the next one;Header.Parsehands it the line it has already read, soHeaderReader's push-back is gone. Decoded body lines are cleared once joined.Checked on its own: 1,176 vectors and all unit tests pass. The fuzzer's
headertarget names 32 outcomes where it named 34 to 36 before; I listed every outcome of both and the difference is two armor outcomes that occurred once each, and the same errors attributed to different methods after the code moved.Commit 2: the plugin channel reads through it
StanzaChannel.ReadcallsStanza.Readand the header's line rules (HeaderLineFramer.ForStanzasAlone: the rules only, nothing recorded, no total). It reads a character at a time, sinceReadLinetakes a CR for a line ending and hides it, and from Latin-1 readers, so each byte arrives as itself.plugin sent a malformed stanza: …orclient sent a malformed stanza: …, in the parser's words.Failure, so the plugin's stderr is attached, as when a plugin dies between stanzas.PluginKeysreplaces the three places that parsed a plugin's key strings and checks their case: a recipient is lowercase, an identity uppercase.Tests
PluginFramingTests(28 cases), all red before commit 2. The server-side ones feed raw bytes throughRun(args, Stream, Stream, TextWriter).ReadLineand now overridesRead.Stanza.Reador the framer now fails more tests than before this PR (over-long body line 3 → 5, empty argument 4 → 10, CR allowed 2 → 6).Fuzzer
All malformed stanzas now throw from one place, which would have hidden them from each other.
Outcomes.Shapefollows the cause of anAgePluginException, and the server target reads the second half of a malformed-stanza report. The client target decodes its input as Latin-1, as production does. Outcomes:plugin54 (43 before),plugin-client30 (26 before); no findings in 30 s.Behaviour changes
Noted in
TODO.mdfor the next release notes. The one a plugin author may feel: a plugin that writes CRLF line endings is now refused, as go-age refuses it.Checked
dotnet testanddotnet test -c Release -p:ForcePortableAead=true -p:TreatWarningsAsErrors=true: 1,176 vectors and 1,714 unit tests pass, 3 skipped as before, so the go-age and rage plugin interop tests ran.