xsd-aware-xml-obfuscator
v0.1.0
Published
Streaming, XSD-aware XML obfuscation CLI for Node.js
Maintainers
Readme
XSD-aware streaming XML obfuscator
TypeScript/Node.js streaming obfuscator intended for very large XML documents. It does not load the input XML into memory.
Install
Run without installing globally:
npx xsd-aware-xml-obfuscator \
--xsd schema.xsd \
--input input.xml \
--output output.xml \
--secret "$XML_OBFUSCATION_SECRET"Or install the CLI globally:
npm install --global xsd-aware-xml-obfuscator
xsd-xml-obfuscate --helpDevelop/build
npm install
npm run buildRun
xsd-xml-obfuscate \
--xsd "s3000l_3-0_lsaDataset.xsd" \
--input input.xml \
--output output.xml \
--secret "$XML_OBFUSCATION_SECRET"Add --readable-names to replace values of name elements and attributes with
deterministic readable pseudonyms such as Amber Falcon.
Use a long random secret and do not commit it to source control.
Design
- input XML: streaming SAX parser;
- XSD: loaded into an in-memory rule model;
- named
complexTypeandgroupdeclarations are expanded where possible; - deterministic HMAC-based masking;
xsd:ID,xsd:IDREF, andxsd:IDREFSshare one masking domain so references remain consistent;- enumeration values stay inside their XSD enumeration;
- unknown/unresolved XSD types are preserved, not guessed;
- output is streamed to disk.
The CLI prints counts including changed, preservedBySchema, and unresolvedPreserved.
See SCHEMA_NOTES.md for findings from the supplied files and the missing schema dependencies.
Current limitations
This is still an MVP, not a complete implementation of the XSD 1.1 specification. Arbitrary regex generation for xsd:pattern, XSD 1.1 assertions as transformation rules, substitution groups, wildcards, type alternatives, and every possible schema composition construct are not fully modeled.
For safety, unresolved values are preserved. This avoids producing values that look obfuscated but violate S3000L constraints.
