{"id":20741118,"url":"https://github.com/robtimus/obfuscation-xml","last_synced_at":"2025-06-30T02:36:53.554Z","repository":{"id":57722447,"uuid":"323668594","full_name":"robtimus/obfuscation-xml","owner":"robtimus","description":"Provides functionality for obfuscating XML","archived":false,"fork":false,"pushed_at":"2025-05-10T13:46:28.000Z","size":660,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-10T14:39:24.849Z","etag":null,"topics":["java","obfuscation","xml"],"latest_commit_sha":null,"homepage":"https://robtimus.github.io/obfuscation-xml","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robtimus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-22T15:49:04.000Z","updated_at":"2025-05-10T13:46:31.000Z","dependencies_parsed_at":"2023-02-15T17:35:31.295Z","dependency_job_id":"d75e775e-a92e-49dd-82b3-a823ed817864","html_url":"https://github.com/robtimus/obfuscation-xml","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/robtimus/obfuscation-xml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fobfuscation-xml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fobfuscation-xml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fobfuscation-xml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fobfuscation-xml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robtimus","download_url":"https://codeload.github.com/robtimus/obfuscation-xml/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fobfuscation-xml/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262699768,"owners_count":23350368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","obfuscation","xml"],"created_at":"2024-11-17T06:33:54.924Z","updated_at":"2025-06-30T02:36:53.539Z","avatar_url":"https://github.com/robtimus.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# obfuscation-xml\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.robtimus/obfuscation-xml)](https://search.maven.org/artifact/com.github.robtimus/obfuscation-xml)\n[![Build Status](https://github.com/robtimus/obfuscation-xml/actions/workflows/build.yml/badge.svg)](https://github.com/robtimus/obfuscation-xml/actions/workflows/build.yml)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=com.github.robtimus%3Aobfuscation-xml\u0026metric=alert_status)](https://sonarcloud.io/summary/overall?id=com.github.robtimus%3Aobfuscation-xml)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=com.github.robtimus%3Aobfuscation-xml\u0026metric=coverage)](https://sonarcloud.io/summary/overall?id=com.github.robtimus%3Aobfuscation-xml)\n[![Known Vulnerabilities](https://snyk.io/test/github/robtimus/obfuscation-xml/badge.svg)](https://snyk.io/test/github/robtimus/obfuscation-xml)\n\nProvides functionality for obfuscating XML documents. This can be useful for logging such documents, e.g. as part of request/response logging, where sensitive content like passwords should not be logged as-is.\n\nTo create an XML obfuscator, simply create a builder, add elements to it, and let it build the final obfuscator:\n\n```java\nObfuscator obfuscator = XMLObfuscator.builder()\n        .withElement(\"password\", Obfuscator.fixedLength(3))\n        .build();\n```\n\nAn XML obfuscator will only obfuscate text, and ignore leading and trailing whitespace, including inside CDATA sections. It will never obfuscate element tag names, comments, etc.\n\n## Obfuscation of nested elements\n\nBy default, if an obfuscator is configured for an element, it will be used to obfuscate the text of all nested elements as well. This can be turned on or off for all elements, or per element. For example:\n\n```java\nObfuscator obfuscator = XMLObfuscator.builder()\n        .textOnlyByDefault()\n        // .textOnlyByDefault() is equivalent to:\n        // .forNestedElementsByDefault(ObfucsationMode.EXCLUDE)\n        .withElement(\"password\", Obfuscator.fixedLength(3))\n        .withElement(\"complex\", Obfuscator.fixedLength(3))\n                .forNestedElements(ObfucsationMode.INHERIT) // override the default setting\n        .build();\n```\n\nThe three possible modes for nested elements are:\n* `EXCLUDE`: don't obfuscate nested elements, but instead traverse into them. Only the text of the element itself will be obfuscated.\n* `INHERIT`: use the obfuscator for the text of the element itself as well as the text of all nested elements.\n* `INHERIT_OVERRIDABLE`: use the obfuscator for the text of the element itself as well as the text of all nested elements. If a nested element has its own obfuscator defined this will be used instead.\n\n## Obfuscation of attributes\n\nIf needed, the values of attributes can be obfuscated as well as text. For example:\n\n```java\nObfuscator obfuscator = XMLObfuscator.builder()\n        // obfuscate any \"password\" attribute\n        .withAttribute(\"password\", Obfuscator.fixedLength(3))\n        // only obfuscate \"username\" attributes of \"request\" elements\n        // the Obfuscator.none() will be applied (so no obfuscation) for any other occurrence\n        .withAttribute(\"username\", Obfuscator.none())\n            .forElement(\"request\", Obfuscator.fixedLength(3))\n        .build();\n```\n\nNote that if attributes need to be obfuscated, XML obfuscators perform obfuscating by generating new, obfuscated XML documents. The resulting obfuscated XML documents may slightly differ from the original.\n\n## Handling malformed XML\n\nIf malformed XML is encountered, obfuscation aborts. It will add a message to the result indicating that obfuscation was aborted. This message can be changed or turned off when creating XML obfuscators:\n\n```java\nObfuscator obfuscator = XMLObfuscator.builder()\n        .withElement(\"password\", Obfuscator.fixedLength(3))\n        // use null to turn it off\n        .withMalformedXMLWarning(\"\u003cinvalid XML\u003e\")\n        .build();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobtimus%2Fobfuscation-xml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobtimus%2Fobfuscation-xml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobtimus%2Fobfuscation-xml/lists"}