Harden YAML engine and conformance accounting#40
Draft
Marius Storhaug (MariusStorhaug) wants to merge 24 commits into
Draft
Harden YAML engine and conformance accounting#40Marius Storhaug (MariusStorhaug) wants to merge 24 commits into
Marius Storhaug (MariusStorhaug) wants to merge 24 commits into
Conversation
Use YAML s-white and ordinal token checks, consume legal BOMs, preserve flow scalar folding, and disambiguate anchor and alias colons without regressing the official corpus. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Apply the 1024-character limit with System.Text.Rune, cover plain and quoted boundaries, and retain the official multiline flow-mapping grammar while rejecting multiline flow-sequence pairs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Include effective tags in structural key fingerprints, validate ns-uri-char and percent escapes by whitelist, and accept reserved directives through their YAML productions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Canonicalize Decimal, Double, and Single values by decimal significand and exponent, making large equivalent values and signed zero obey YAML representation equality. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.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.
Summary
emit.yamlfixtures independent from module self-round-trip accountingStack
This is the third remediation layer and is intentionally stacked on
yaml-conformance-fixes.yaml-conformance-fixesyaml-engine-hardeningat0c2fcc16e942ac282bb5fb2ecba4441243c16ea4Original review findings
Parser and representation
s-whiteand ordinal comparisons; NBSP remains scalar content.---; invalid token placements fail and quoted scalar BOM content is preserved.{foo:[bar]},{foo:{bar: baz}}, and[foo:[bar]]parse.System.Text.Rune, with emoji boundary coverage.ns-uri-char, percent escapes, UTF-8 decoding, and backslash rejection are enforced.%FOO-BAR bazparse while malformed productions fail.Projection and serialization
?keys and the output parses itself.OrderedDictionaryexceptions.-AsHashtablerepresentability guidance.DateTimeMin/Max andDateTimeOffsetrepresentation failures are validated and classified stably.Conformance runner
!!omaporder is carried from representation metadata rather than inferred from CLR dictionary type, and ordered mappings use anomap:discriminator distinct from ordinarymap:values.emit.yamlfixtures are validated against an independent source/JSON oracle; module emission and reparse belong only to self-round-trip.2JQSandX38Ware classified before invalid-stream applicability, andX38Wremains visible on itsout.yamlsurface.Final-review follow-up
?and:accept YAML tabs-white; compact-collection indentation restrictions remain intact.source: &a key\n*a: valueproduces the aliased key mapping while legal alias-name colons remain supported.#as validns-uri-char; only whitespace-separated#starts a comment.l-document-prefix*sequences and legal trailing prefixes are consumed without phantom documents.!!omaporder comes from representation nodes, and official fixture results cannot be overwritten by self-round-trip logic.A final code review also found quadratic repeated-BOM prefix rescanning. The parser now keeps source text immutable, advances per-line physical offsets, and validates a repeated prefix suffix once. The 1,000-prefix reproduction improved from 5.230s to 0.277s locally, and a mock-backed regression requires exactly one suffix validation.
Two final scoped findings were closed in separate commits:
995a6b9allows noninitial/repeated document prefixes before bare documents whenever an explicit start is not required.# prefix\n<BOM>valueand---\none\n...\n<BOM>twomatch their BOM-free forms; a BOM before a second document without.../---, and a directive followed by a bare document, remain invalid.0c2fcc1encodes explicit ordered mappings asomap:while preserving entry order. A canonically ordered!!omapno longer equals an ordinary map, and focusedout.yaml, official-oracle, and self-round-trip mutations prove representation-tag loss is detected/classified.Released yaml-test-suite accounting
Pinned release:
v2022-01-17, 402 inputs, zero genuine failures.out.yamlemit.yamlExplicit policy differences
2JQS,X38W: YAML representation mapping-key uniqueness; both affect syntax and self-round-trip, andX38Walso affectsout.yaml.565N:!!binaryintentionally projects asbyte[], affecting JSON projection only.J7PZ: legacy!!omapintentionally projects asOrderedDictionary, affecting JSON projection; self-round-trip preserves entries and order but cannot reconstruct the lost explicit!!omaprepresentation tag.No parser or emitter inability is classified as policy. There are no deferred findings.
Validation
Local PowerShell 7.6.4 Core:
src: 0 findingsProcess-PSModule run
30058785794passed at the final SHA in 257 seconds. Windows, Linux, and macOS all used PowerShell 7.6.3 Core and tested the built module artifact.Counts are passed/failed/skipped; total time is the sum of each platform's reported project Pester durations. The Process-PSModule source harness also passed 9/0/1 and the built-module harness passed 4/0/1 on every platform. Source and built-artifact analyzer suites each passed 73/0/2 on every platform. Build-Module passed in 21s, Build-Docs in 133s, Build-Site in 22s, aggregate test reporting in 25s, and code coverage in 65s. Repository lint and publish jobs were intentionally skipped for the manual draft-branch dispatch; no required check failed or remains pending.