naruto-lgtm commented on PR #1581:
URL: https://github.com/apache/poi/pull/1581#issuecomment-7059269909

   On the `hasSignedRelationships` / `getElementById` point, which I could not 
reply to inline: `validate()` now rejects a signature part which uses the same 
Id on more than one element, in the loop that marks the Id attributes, before 
anything is unmarshalled.
   
   Worth recording what I found while writing the test for it. Santuario's 
fragment resolver already refuses the ambiguous reference ("Multiple Elements 
with the same ID idPackageObject were detected"), so the forged manifest does 
not reach `hasSignedRelationships` on current code. But it refuses by throwing 
a URIReferenceException, which `validate()` turns into an 
`EncryptedDocumentException` instead of returning false, so a caller gets an 
exception for a document that is simply invalid. The explicit check gives them 
false plus a warning, and it stops the outcome depending on which element the 
provider's lookup happens to return.
   
   I left `hasSignedRelationships` on `getElementById`: with unique Ids the 
lookup is unambiguous, and going through `getObjects()` there would not cover a 
manifest referenced straight from SignedInfo. `testDuplicatePackageObjectId` 
covers the case.
   
   The three new tests fail on 45ddb50 and pass now, and `:poi-ooxml:check` 
passes locally.


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to