Skip to content

bump xmldom to 0.9 #501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

bump xmldom to 0.9 #501

wants to merge 2 commits into from

Conversation

elbuo8
Copy link

@elbuo8 elbuo8 commented Apr 22, 2025

Fixes #108 and as an alternative to: #492

const signatureNode = doc.documentElement;

if (!signatureNode) {
throw new Error("signatureNode is not defined");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity: why xmldom version bump required this change to signature-unit-tests.spec.ts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linting/eslint complaining that documentElement can now be null. So either a bunch of ignore statements or assert it actually exists. Tried doing it with expect but wasn't enough to make linter happy.

@@ -54,7 +54,7 @@ describe("Canonicalization unit tests", function () {

it("Exclusive canonicalization works with default namespace for prefix", function () {
compare(
'<ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></ds:SignedInfo>',
'<ds:SignedInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></ds:SignedInfo>',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why version bump required addition of xmlns definition to input xml?

I guess that new xmldom version refuses to understand that particular input xml anymore when it is parsed at the beginning of compare function...but is this test case ("Exclusive canonicalization works with default namespace for prefix") still testing what it claims to to test. Line 61 configures

{ ds: "http://www.w3.org/2000/09/xmldsig#" }

as parameter for compare functions defaultNsForPrefix which is passed as parameter for canonicalization process. I did not spend time to try to understand how canonicalization function should work but parameter name implicates that canonixalization function was previously instructed to use aforementioned NS for prefix ds (if/when it was missing from input xml).

Disclaimer: I am not xml dsig or canonicalization expert. This change just popped up from the mass when I quickly scrolled through changes out of curiosity.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 61 configures
as parameter for compare functions defaultNsForPrefix which is passed as parameter for canonicalization process.

These happen after parsing the DOM, so they are unrelated/ignored by xmldom.
It considers it invalid payload since it was never defined. The excerpt itself
<ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></ds:SignedInfo> is invalid in any XML validator I punch it into. (I'm def no expert on XML either 😅 ).

Seems xmldom is becoming more strict overall.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These happen after parsing the DOM, so they are unrelated/ignored by xmldom

Yes...canonicalzation's process implementation is tested at compare after inputxml is parsed with xmldom and after SignedInfo is extracted from DOM produced by xmldom and yes xmldom is more stricter now, but:
Under what conditions canonicalization was invoked with Element which did/might not have namespace uri available / defined for prefix (in this case for ds). Dunno why such test case and functionality (defaultNsForPrefix') would exists without some reason. Should such functionality be preserved with tests that actually test it(?)

Unfortunately there isn't much info available at these related commits:

  1. 7d69a26
  2. 5f2278b

@cjbarth
Copy link
Contributor

cjbarth commented Apr 23, 2025

There is a lot of work done here, but ultimately, [email protected] isn't ready for this project. I've already been through this.

See xmldom/xmldom#812 (comment)
See also my fork where I did pretty much all the required work: https://github.com/cjbarth/node-saml/tree/xmldom-0.9.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Break the signature validation (>0.8.2)
3 participants