XPathDescendantWeakness implements XPathWeaknessInterface { @Override public int getNumberOfPossibilities() { return numberOfPostProcessPossibilites > 0 ? numberOfPossibilites * numberOfPostProcessPossibilites : numberOfPossibilites; } XPathDescendantWeakness( Step descendantStep, SignedElement signedElement, PayloadElement payloadElement,
                                    SchemaAnalyzer schemaAnalyser ); @Override int getNumberOfPossibilities(); String getPreXPath(); String getPostXPath(); List<XPathWeaknessInterface> getPostProcessList(); List<WrapperProperties> getWrapperProperties(); @Override void abuseWeakness( int index, SignedElement signedElement, PayloadElement payloadElement );  }
@Test public void withPreXPath() throws Exception { Document doc = DomUtilities.readDocument( "src/test/resources/signed_rampart_message_soap_1.2.xml" ); SchemaAnalyzer sa = SchemaAnalyzerFactory.getInstance( SchemaAnalyzerFactory.NULL ); SignatureManager sm = new SignatureManager(); sm.setDocument( doc ); Payload option = sm.getPayloads().get( 1 ); ReferringElementInterface ref = option.getReferringElement(); ref.setXPath( "/soap:Envelope/soap:Header/wsse:Security" + ref.getXPath() ); AbsoluteLocationPath abs = new AbsoluteLocationPath( ref.getXPath() ); XPathDescendantWeakness weakness = new XPathDescendantWeakness( abs.getRelativeLocationPaths().get( 3 ), new SignedElement( option.getSignedElement(), option.getReferringElement().getElementNode() ), new PayloadElement( option.getPayloadElement(), option.getReferringElement().getElementNode() ), sa ); assertTrue( weakness.getNumberOfPossibilities() > 0 ); option = sm.getPayloads().get( 0 ); option.setValue( option.getValue().replace( "Know-How", "ATTACKER" ) ); ref = option.getReferringElement(); ref.setXPath( "/soap:Envelope" + ref.getXPath() ); abs = new AbsoluteLocationPath( ref.getXPath() ); weakness = new XPathDescendantWeakness( abs.getRelativeLocationPaths().get( 1 ), new SignedElement( option.getSignedElement(), option.getReferringElement().getElementNode() ), new PayloadElement( option.getPayloadElement(), option.getReferringElement().getElementNode() ), sa ); assertTrue( weakness.getNumberOfPossibilities() > 0 ); WrappingOracle wrap = new WrappingOracle( doc, sm.getPayloads(), sa ); assertTrue( wrap.maxPossibilities() > 0 ); }