Skip to content

TIKA-4837 - flag extra contents in ooxml files - #3063

Open
tballison wants to merge 3 commits into
mainfrom
TIKA-4837-ooxml-contents
Open

TIKA-4837 - flag extra contents in ooxml files#3063
tballison wants to merge 3 commits into
mainfrom
TIKA-4837-ooxml-contents

Conversation

@tballison

Copy link
Copy Markdown
Contributor

Thanks for your contribution to Apache Tika! Your help is appreciated!

Before opening the pull request, please verify that

  • there is an open issue on the Tika issue tracker which describes the problem or the improvement. We cannot accept pull requests without an issue because the change wouldn't be listed in the release notes.
  • the issue ID (TIKA-XXXX)
    • is referenced in the title of the pull request
    • and placed in front of your commit messages surrounded by square brackets ([TIKA-XXXX] Issue or pull request title)
  • commits are squashed into a single one (or few commits for larger changes)
  • Tika is successfully built and unit tests pass by running ./mvnw clean test
  • there should be no conflicts when merging the pull request branch into the recent main branch. If there are conflicts, please try to rebase the pull request branch on top of a freshly pulled main branch
  • if you add new module that downstream users will depend upon add it to relevant group in tika-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!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 ImageSource and PageContent), not OPC relationships; valid resources in a normal XPS such as testXPS_various.xps will 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.txt has 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.xml is 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.

Comment on lines +240 to +242
* 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
Comment on lines +251 to +252
Property HAS_UNREFERENCED_PARTS =
Property.internalBoolean("msoffice:has-unreferenced-parts");
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.

2 participants