Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 2f9919c

Browse files
author
Keith Hoodlet
committed
Initial commit; Tests not passing at the moment
1 parent 0e6d688 commit 2f9919c

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import java.io.File;
2+
import java.io.FileInputStream;
3+
import javax.xml.parsers.SAXParser;
4+
import javax.xml.parsers.SAXParserFactory;
5+
import org.xml.sax.InputSource;
6+
import org.xml.sax.XMLReader;
7+
8+
public class XMLParser {
9+
public static void main(String[] args) throws Exception {
10+
// Get user input from file
11+
File file = new File("input.xml");
12+
FileInputStream inputStream = new FileInputStream(file);
13+
InputSource inputSource = new InputSource(inputStream);
14+
15+
// Get XML reader
16+
XMLReader xmlReader = getXMLReader();
17+
18+
// Parse XML
19+
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
20+
SAXParser saxParser = saxParserFactory.newSAXParser();
21+
saxParser.parse(inputSource, xmlReader);
22+
}
23+
24+
private static XMLReader getXMLReader() throws Exception {
25+
// Create XML reader
26+
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
27+
SAXParser saxParser = saxParserFactory.newSAXParser();
28+
XMLReader xmlReader = saxParser.getXMLReader();
29+
30+
// Set properties for XML reader
31+
xmlReader.setFeature("http://xml.org/sax/features/external-general-entities", false);
32+
xmlReader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
33+
xmlReader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
34+
35+
return xmlReader;
36+
}
37+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CWE-611/XXELocal.ql

0 commit comments

Comments
 (0)