Skip to content

test: pin the hoisted ancestor namespace behaviour #541 fixed - #565

Closed
cjbarth wants to merge 1 commit into
masterfrom
test/c14n-ancestor-namespace-regressions
Closed

test: pin the hoisted ancestor namespace behaviour #541 fixed#565
cjbarth wants to merge 1 commit into
masterfrom
test/c14n-ancestor-namespace-regressions

Conversation

@cjbarth

@cjbarth cjbarth commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Refs #538, #541.

Three branches were open against defects in the ancestor-namespace path of non-exclusive C14N:

  1. a hoisted ancestor default namespace not becoming the default its descendants were canonicalized against, so a child's own xmlns="" read as redundant and was dropped;
  2. an ancestor declaration being appended alongside one the node made itself, producing two xmlns attributes on one element;
  3. process() marking ancestor prefixes in scope before anything had been rendered, so the apex's own redeclaration of such a prefix was skipped as redundant and resolved to the outer binding.

All three are already fixed on master. #541 got there by a different route — localDefaultNs/nodeDefaultNs in renderNs, newDefaultNs seeded from the hoisted entry in the ancestor merge, and findSubsetNSPrefixes collecting every prefix the subset declares rather than the first. So the fixes those branches carried are obsolete and are dropped.

Their tests are not obsolete. master satisfies these spec requirements without asserting any of them, in an area that has now produced four separate defects.

These are guards, not documentation

Each of the six unit cases fails against src/c14n-canonicalization.ts as it stood before #541 and passes on master. Two spot checks confirm they bite against plausible regressions:

Perturbation of master Failures
drop newDefaultNs = ancestorNamespace.namespaceURI from the ancestor merge 7 (4 without this PR)
revert findSubsetNSPrefixes to the first declaration only 12 (11 without this PR)

The cases are parameterized over both C14nCanonicalization and C14nCanonicalizationWithComments, which the original branches did not do.

The integration case

The one worth having. A hoisted default namespace leaking into a descendant leaves the signature verifying while getSignedReferences() — the API the README designates as the secure replacement for getValidatedNode() — reports the element in a namespace the sender never signed it in. A caller that dispatches on element namespace then acts on an identity that was never signed, and the sender picks it. Nothing else in the suite covers that.

Cited inline: C14N 1.0 §2.3, the §4.7 rationale for preserving xmlns="", and Namespaces in XML §2.2 for prefix scoping.

Milestone

v6.2, matching #541 — test-only, no behaviour change.

Verification

npm run build && npm test && npm run lint clean; 254 passing (241 + 13; 6 cases × 2 canonicalizers + 1 integration).

🤖 Generated with Claude Code

Three branches were open against defects in the ancestor-namespace path of
non-exclusive C14N: a hoisted ancestor default namespace not becoming the
default its descendants were canonicalized against, an ancestor declaration
being appended alongside one the node made itself, and `process()` marking
ancestor prefixes in scope before anything had been rendered so the apex's own
redeclaration was skipped as redundant.

#541 fixed all three by a different route — `localDefaultNs`/`nodeDefaultNs` in
`renderNs`, `newDefaultNs` seeded from the hoisted entry, and
`findSubsetNSPrefixes` collecting every prefix the subset declares rather than
the first. The fixes those branches carried are obsolete, so only their tests
land here, parameterized over both non-exclusive canonicalizers.

Each case fails against the implementation as it stood before #541 and passes
now, so they are guards rather than documentation. Two spot checks confirm they
bite: dropping the `newDefaultNs` assignment from the ancestor merge fails
three of them, and reverting `findSubsetNSPrefixes` to the first declaration
only fails another.

The integration case is the one worth having. A hoisted default namespace
leaking into a descendant leaves the signature verifying while
`getSignedReferences()` reports an element in a namespace the sender never
signed it in, and nothing else in the suite covers that.

Refs #538, #541

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 0558ce69-4a55-4b25-8757-a85da84e3dfe

📥 Commits

Reviewing files that changed from the base of the PR and between 0409418 and e9e3cbb.

📒 Files selected for processing (2)
  • test/c14n-non-exclusive-unit-tests.spec.ts
  • test/signature-integration-tests.spec.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cjbarth cjbarth added this to the v6.2 milestone Sep 9, 2026
@cjbarth cjbarth added the chore label Sep 9, 2026
@cjbarth cjbarth closed this Sep 9, 2026
@cjbarth
cjbarth deleted the test/c14n-ancestor-namespace-regressions branch September 9, 2026 23:50
@cjbarth

cjbarth commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Closed in favour of #572 — the same commits, opened from cjbarth/xml-crypto instead of a branch pushed directly to this repo by mistake. The branch here has been deleted.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant