|
27 | 27 | @Controller
|
28 | 28 | public class XsltInjectionTest {
|
29 | 29 | public void testStreamSourceInputStream(Socket socket) throws Exception {
|
30 |
| - StreamSource source = new StreamSource(socket.getInputStream()); |
31 |
| - TransformerFactory.newInstance().newTransformer(source).transform(null, null); // $hasXsltInjection |
| 30 | + StreamSource source = new StreamSource(socket.getInputStream()); // $ Source |
| 31 | + TransformerFactory.newInstance().newTransformer(source).transform(null, null); // $ Alert |
32 | 32 | }
|
33 | 33 |
|
34 | 34 | public void testStreamSourceReader(Socket socket) throws Exception {
|
35 |
| - StreamSource source = new StreamSource(new InputStreamReader(socket.getInputStream())); |
36 |
| - TransformerFactory.newInstance().newTemplates(source).newTransformer().transform(null, null); // $hasXsltInjection |
| 35 | + StreamSource source = new StreamSource(new InputStreamReader(socket.getInputStream())); // $ Source |
| 36 | + TransformerFactory.newInstance().newTemplates(source).newTransformer().transform(null, null); // $ Alert |
37 | 37 | }
|
38 | 38 |
|
39 | 39 | @RequestMapping
|
40 |
| - public void testStreamSourceInjectedParam(@RequestParam String param) throws Exception { |
| 40 | + public void testStreamSourceInjectedParam(@RequestParam String param) throws Exception { // $ Source |
41 | 41 | String xslt = "<xsl:stylesheet [...]" + param + "</xsl:stylesheet>";
|
42 | 42 | StreamSource source = new StreamSource(new StringReader(xslt));
|
43 |
| - TransformerFactory.newInstance().newTransformer(source).transform(null, null); // $hasXsltInjection |
| 43 | + TransformerFactory.newInstance().newTransformer(source).transform(null, null); // $ Alert |
44 | 44 | }
|
45 | 45 |
|
46 | 46 | public void testSAXSourceInputStream(Socket socket) throws Exception {
|
47 |
| - SAXSource source = new SAXSource(new InputSource(socket.getInputStream())); |
48 |
| - TransformerFactory.newInstance().newTemplates(source).newTransformer().transform(null, null); // $hasXsltInjection |
| 47 | + SAXSource source = new SAXSource(new InputSource(socket.getInputStream())); // $ Source |
| 48 | + TransformerFactory.newInstance().newTemplates(source).newTransformer().transform(null, null); // $ Alert |
49 | 49 | }
|
50 | 50 |
|
51 | 51 | public void testSAXSourceReader(Socket socket) throws Exception {
|
52 | 52 | SAXSource source =
|
53 |
| - new SAXSource(null, new InputSource(new InputStreamReader(socket.getInputStream()))); |
54 |
| - TransformerFactory.newInstance().newTransformer(source).transform(null, null); // $hasXsltInjection |
| 53 | + new SAXSource(null, new InputSource(new InputStreamReader(socket.getInputStream()))); // $ Source |
| 54 | + TransformerFactory.newInstance().newTransformer(source).transform(null, null); // $ Alert |
55 | 55 | }
|
56 | 56 |
|
57 | 57 | public void testStAXSourceEventReader(Socket socket) throws Exception {
|
58 | 58 | StAXSource source =
|
59 |
| - new StAXSource(XMLInputFactory.newInstance().createXMLEventReader(socket.getInputStream())); |
60 |
| - TransformerFactory.newInstance().newTransformer(source).transform(null, null); // $hasXsltInjection |
| 59 | + new StAXSource(XMLInputFactory.newInstance().createXMLEventReader(socket.getInputStream())); // $ Source |
| 60 | + TransformerFactory.newInstance().newTransformer(source).transform(null, null); // $ Alert |
61 | 61 | }
|
62 | 62 |
|
63 | 63 | public void testStAXSourceEventStream(Socket socket) throws Exception {
|
64 | 64 | StAXSource source = new StAXSource(XMLInputFactory.newInstance().createXMLStreamReader(null,
|
65 |
| - new InputStreamReader(socket.getInputStream()))); |
66 |
| - TransformerFactory.newInstance().newTemplates(source).newTransformer().transform(null, null); // $hasXsltInjection |
| 65 | + new InputStreamReader(socket.getInputStream()))); // $ Source |
| 66 | + TransformerFactory.newInstance().newTemplates(source).newTransformer().transform(null, null); // $ Alert |
67 | 67 | }
|
68 | 68 |
|
69 | 69 | public void testDOMSource(Socket socket) throws Exception {
|
70 | 70 | DOMSource source = new DOMSource(
|
71 |
| - DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(socket.getInputStream())); |
72 |
| - TransformerFactory.newInstance().newTransformer(source).transform(null, null); // $hasXsltInjection |
| 71 | + DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(socket.getInputStream())); // $ Source |
| 72 | + TransformerFactory.newInstance().newTransformer(source).transform(null, null); // $ Alert |
73 | 73 | }
|
74 | 74 |
|
75 | 75 | public void testDisabledXXE(Socket socket) throws Exception {
|
76 |
| - StreamSource source = new StreamSource(socket.getInputStream()); |
| 76 | + StreamSource source = new StreamSource(socket.getInputStream()); // $ Source |
77 | 77 | TransformerFactory factory = TransformerFactory.newInstance();
|
78 | 78 | factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
|
79 | 79 | factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
|
80 |
| - factory.newTransformer(source).transform(null, null); // $hasXsltInjection |
| 80 | + factory.newTransformer(source).transform(null, null); // $ Alert |
81 | 81 | }
|
82 | 82 |
|
83 | 83 | public void testFeatureSecureProcessingDisabled(Socket socket) throws Exception {
|
84 |
| - StreamSource source = new StreamSource(socket.getInputStream()); |
| 84 | + StreamSource source = new StreamSource(socket.getInputStream()); // $ Source |
85 | 85 | TransformerFactory factory = TransformerFactory.newInstance();
|
86 | 86 | factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
|
87 |
| - factory.newTransformer(source).transform(null, null); // $hasXsltInjection |
| 87 | + factory.newTransformer(source).transform(null, null); // $ Alert |
88 | 88 | }
|
89 | 89 |
|
90 | 90 | public void testSaxon(Socket socket) throws Exception {
|
91 |
| - StreamSource source = new StreamSource(socket.getInputStream()); |
| 91 | + StreamSource source = new StreamSource(socket.getInputStream()); // $ Source |
92 | 92 | XsltCompiler compiler = new Processor(true).newXsltCompiler();
|
93 | 93 |
|
94 |
| - compiler.compile(source).load().transform(); // $hasXsltInjection |
95 |
| - compiler.compile(source).load30().transform(null, null); // $hasXsltInjection |
96 |
| - compiler.compile(source).load30().applyTemplates((Source) null); // $hasXsltInjection |
97 |
| - compiler.compile(source).load30().applyTemplates((Source) null, null); // $hasXsltInjection |
98 |
| - compiler.compile(source).load30().applyTemplates((XdmValue) null); // $hasXsltInjection |
99 |
| - compiler.compile(source).load30().applyTemplates((XdmValue) null, null); // $hasXsltInjection |
100 |
| - compiler.compile(source).load30().callFunction(null, null); // $hasXsltInjection |
101 |
| - compiler.compile(source).load30().callFunction(null, null, null); // $hasXsltInjection |
102 |
| - compiler.compile(source).load30().callTemplate(null); // $hasXsltInjection |
103 |
| - compiler.compile(source).load30().callTemplate(null, null); // $hasXsltInjection |
| 94 | + compiler.compile(source).load().transform(); // $ Alert |
| 95 | + compiler.compile(source).load30().transform(null, null); // $ Alert |
| 96 | + compiler.compile(source).load30().applyTemplates((Source) null); // $ Alert |
| 97 | + compiler.compile(source).load30().applyTemplates((Source) null, null); // $ Alert |
| 98 | + compiler.compile(source).load30().applyTemplates((XdmValue) null); // $ Alert |
| 99 | + compiler.compile(source).load30().applyTemplates((XdmValue) null, null); // $ Alert |
| 100 | + compiler.compile(source).load30().callFunction(null, null); // $ Alert |
| 101 | + compiler.compile(source).load30().callFunction(null, null, null); // $ Alert |
| 102 | + compiler.compile(source).load30().callTemplate(null); // $ Alert |
| 103 | + compiler.compile(source).load30().callTemplate(null, null); // $ Alert |
104 | 104 | }
|
105 | 105 |
|
106 | 106 | @RequestMapping
|
107 |
| - public void testSaxonXsltPackage(@RequestParam String param, Socket socket) throws Exception { |
| 107 | + public void testSaxonXsltPackage(@RequestParam String param, Socket socket) throws Exception { // $ Source |
108 | 108 | URI uri = new URI(param);
|
109 |
| - StreamSource source = new StreamSource(socket.getInputStream()); |
| 109 | + StreamSource source = new StreamSource(socket.getInputStream()); // $ Source |
110 | 110 | XsltCompiler compiler = new Processor(true).newXsltCompiler();
|
111 | 111 |
|
112 |
| - compiler.loadExecutablePackage(uri).load().transform(); // $hasXsltInjection |
113 |
| - compiler.compilePackage(source).link().load().transform(); // $hasXsltInjection |
114 |
| - compiler.loadLibraryPackage(uri).link().load().transform(); // $hasXsltInjection |
| 112 | + compiler.loadExecutablePackage(uri).load().transform(); // $ Alert |
| 113 | + compiler.compilePackage(source).link().load().transform(); // $ Alert |
| 114 | + compiler.loadLibraryPackage(uri).link().load().transform(); // $ Alert |
115 | 115 | }
|
116 | 116 |
|
117 | 117 | public void testOkFeatureSecureProcessing(Socket socket) throws Exception {
|
|
0 commit comments