TIKA-4837 - flag extra contents in ooxml files - #3063
Conversation
There was a problem hiding this comment.
Pull request overview
Adds best-effort detection of unreferenced OOXML package parts and exposes the results as Office metadata.
Changes:
- Traverses OPC relationships and records unreferenced part names.
- Adds metadata properties and schema entries.
- Adds regression tests for orphan parts and VBA macro resolution.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/test/java/org/apache/tika/parser/microsoft/ooxml/ZipStructureCoverageTest.java | Updated as part of this pull request. |
| tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/test/java/org/apache/tika/parser/microsoft/ooxml/MacroPartResolutionTest.java | Updated as part of this pull request. |
| tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/ooxml/OOXMLExtractorFactory.java | Updated as part of this pull request. |
| tika-metadata-schema/src/main/resources/org/apache/tika/metadata/metadata-keys.json | Updated as part of this pull request. |
| tika-metadata-schema/src/main/resources/org/apache/tika/metadata/metadata-key-fields.json | Updated as part of this pull request. |
| tika-core/src/main/java/org/apache/tika/metadata/Office.java | Updated as part of this pull request. |
Suppressed comments (3)
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/ooxml/OOXMLExtractorFactory.java:105
- This call runs before format dispatch, so it also processes XPS. XPS is supported by this factory, but its extractor resolves page/image resources through direct ZIP paths (for example
ImageSourceandPageContent), not OPC relationships; valid resources in a normal XPS such astestXPS_various.xpswill therefore be reported as unreferenced. Restrict this check to relationship-driven Office OOXML formats or make the traversal format-aware.
markUnreferencedParts(pkg, metadata);
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/ooxml/OOXMLExtractorFactory.java:105
- This introduces new metadata keys and changes observable OOXML parse output, but the unreleased
CHANGES.txthas no TIKA-4837 entry. Please add a release-note entry describing the flags and their best-effort semantics so consumers can discover this API.
markUnreferencedParts(pkg, metadata);
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/test/java/org/apache/tika/parser/microsoft/ooxml/ZipStructureCoverageTest.java:44
- The opening description says an unreachable part sits outside the parsed structure, but this same test later demonstrates that
/word/orphan.xmlis still parsed through content-type enumeration (lines 131-133). Describe this as an OPC reachability signal instead, or readers may incorrectly treat the flag as proof that the bytes were not parsed.
* {@link Office#HAS_UNREFERENCED_PARTS} signal. Tika (like Office) loads content by
* following the OPC relationship graph, so a declared part that nothing references is
* carried in the file but sits outside the parsed structure -- a place to hide bytes a
* raw-ZIP reader (AV/DLP/CDR) can still see.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| * relationship graph. Office and Tika load content by following relationships, so an | ||
| * unreferenced part is carried in the file but never parsed -- a place to hide bytes | ||
| * that a raw-ZIP reader (AV/DLP/CDR) can still see. (Note: a part with no declared |
| Property HAS_UNREFERENCED_PARTS = | ||
| Property.internalBoolean("msoffice:has-unreferenced-parts"); |
Thanks for your contribution to Apache Tika! Your help is appreciated!
Before opening the pull request, please verify that
TIKA-XXXX)[TIKA-XXXX] Issue or pull request title)./mvnw clean testmainbranch. If there are conflicts, please try to rebase the pull request branch on top of a freshly pulledmainbranchtika-bom/pom.xml.We will be able to faster integrate your pull request if these conditions are met. If you have any questions how to fix your problem or about using Tika in general, please sign up for the Tika mailing list. Thanks!