mirror of
https://github.com/github/codeql.git
synced 2026-05-05 05:35:13 +02:00
Merge branch 'main' into atorralba/java/promote-xxe-experimental-sinks
This commit is contained in:
@@ -26,4 +26,19 @@ public class XPathExpressionTests {
|
||||
XPathExpression expr = path.compile("");
|
||||
expr.evaluate(new InputSource(sock.getInputStream())); // $ hasTaintFlow
|
||||
}
|
||||
|
||||
public void safeXPathEvaluateTest(Socket sock) throws Exception {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
XPathFactory xFactory = XPathFactory.newInstance();
|
||||
XPath path = xFactory.newXPath();
|
||||
path.evaluate("", builder.parse(sock.getInputStream())); // safe
|
||||
}
|
||||
|
||||
public void unsafeXPathEvaluateTest(Socket sock) throws Exception {
|
||||
XPathFactory xFactory = XPathFactory.newInstance();
|
||||
XPath path = xFactory.newXPath();
|
||||
path.evaluate("", new InputSource(sock.getInputStream())); // $ hasTaintFlow
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user