henry-lindeman-glean commented on code in PR #3278:
URL: https://github.com/apache/tika/pull/3278#discussion_r4221618344


##########
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/onenote/OneNoteTreeWalker.java:
##########
@@ -615,6 +624,20 @@ private Map<String, Object> 
processPropertyValue(PropertyValue propertyValue,
                         // have the onlyLatestRevision = false
                         handleRichEditTextUnicode(content.size());
                     }
+                } else if (propertyValue.propertyId.propertyEnum ==
+                        OneNotePropertyEnum.NotebookManagementEntityGuid
+                        && content.size() == 16) {
+                    ByteBuffer guidBuffer = ByteBuffer.allocate(16);
+                    dif.read(guidBuffer);
+                    String guid = 
pooledGuid(GUID.fromMicrosoftBytes(guidBuffer.array()).toString());
+                    propMap.put("notebookManagementEntityGuid", guid);
+                    // Version-history copies of a page are object-space 
roots; only the
+                    // current page's metadata is referenced via 
MetaDataObjectsAboveGraphSpace.
+                    if (objectType != OneNoteJcid.PAGE_METADATA || 
(parentPropertyId != null
+                            && parentPropertyId.propertyEnum ==
+                            
OneNotePropertyEnum.MetaDataObjectsAboveGraphSpace)) {
+                        addClassicEntityGuid(objectType, guid);
+                    }

Review Comment:
   Partial read in OneNoteTreeWalker (claimed High) — false positive.
   Copilot says dif.read(guidBuffer) isn't guaranteed to fill the 16-byte 
buffer and the NPE risk if decode returns null. But dif is a 
OneNoteDirectFileResource, whose read(ByteBuffer) loops until the buffer is 
drained and explicitly throws IOException("End of stream reached earlier than 
expected") on premature EOF. A silent short read is impossible. The NPE claim 
is also impossible: guidBuffer.array() is always exactly 16 bytes, and 
GUID.fromMicrosoftBytes only returns null for wrong-length input.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to