Repository navigation
chore: deprecate signing and verifying a document that has a DOCTYPE - #661
Conversation
xmldom does not process a document type declaration, so an entity or a default attribute it declares is missing from the canonical form, which XML 1.0 and Canonical XML require to include both. 7.0 will refuse such a document. Print a DeprecationWarning from computeSignature() and checkSignature() until then. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 49 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
…ocuments-with-doctype
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (20.00%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #661 +/- ##
==========================================
- Coverage 86.30% 86.05% -0.25%
==========================================
Files 9 9
Lines 1336 1341 +5
Branches 344 346 +2
==========================================
+ Hits 1153 1154 +1
- Misses 104 106 +2
- Partials 79 81 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ribute Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #524.
xml-crypto parses with xmldom, which does not process a document type declaration. XML 1.0 §5.1 requires even a non-validating processor to "include the replacement text of internal entities, and supply default attribute values", and Canonical XML §1.1 builds on that: "Character and parsed entity references are replaced" and "Default attributes are added to each element". So for a document whose DOCTYPE declares either, the canonical form xml-crypto signs or verifies is not the one the specifications define.
With xmldom 0.8.15 and xml-crypto 6.3.3:
<!DOCTYPE foo [<!ENTITY bar "admin">]><foo>&bar;</foo><foo>&bar;</foo><foo>&bar;</foo><foo>&bar;</foo><!DOCTYPE foo [<!ATTLIST foo role CDATA "admin">]><foo>x</foo><foo>x</foo>The first two documents mean different things and get the same digest. The third loses the default attribute.
7.0 will refuse a document that has a DOCTYPE (#524). This PR is the warning that comes first:
computeSignature()andcheckSignature()print theDeprecationWarningXML_CRYPTO_DOCUMENT_TYPE_DECLARATION, once per process, when the document they are given has a DOCTYPE. Any DOCTYPE counts, with or without an internal subset. The document is signed or verified exactly as before.The warning is in those two methods because they are where xml-crypto parses a document itself. The canonicalization classes take a DOM the caller parsed, so what the parser did with the declaration is the caller's.
Tests
The warning has no test, like the other deprecations. One test is new, in
test/document-type-declaration.spec.ts: a document whose DOCTYPE declares a default attribute is still signed and verified, and the attribute is not in what is signed. Nothing exercised a DOCTYPE through these two methods before.Checks
npm run build && npm test && npm run lintpass (551 tests).🤖 Generated with Claude Code
Summary by CodeRabbit
Documentation
Deprecation