Skip to content

Commit 97a2b0c

Browse files
committed
fix cases
1 parent 71b8b16 commit 97a2b0c

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

.dccache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"/Users/arshan/code/bad-java-code/pom.xml":[3000,1718917349969.081,"4ca0de2d17b12b52ecf638bd3529d914f1f750898f876269d182ab79cf74728a"],"/Users/arshan/code/bad-java-code/src/main/java/com/acme/XXEVuln.java":[2982,1719002214286.9138,"5e87995eedebe28ff93049eea7e7807851dcfeb40e05f74af61b5eae351b6de2"],"/Users/arshan/code/bad-java-code/src/main/java/com/acme/XXEVulnFixed.java":[3603,1719002288827.916,"c736fde04ea3864ea1a1d7dc680491b0005fc4e71921e4f78baf0929e9569ec9"],"/Users/arshan/code/bad-java-code/src/main/java/com/acme/reflection/TranslatorStrategy.java":[182,1718917349970.476,"aaebffa4316c4b698bb186d80bccd0b1344ddd1bd837f96cea34a08b5003ccf2"],"/Users/arshan/code/bad-java-code/src/main/java/com/acme/reflection/UnsafeReflection.java":[1755,1718917349970.8848,"bb2d13e795f710d48ba7232694f994257c4ed72b36329e0365ba430092efe784"],"/Users/arshan/code/bad-java-code/src/main/java/com/acme/reflection/UnsafeReflectionFixed.java":[1789,1718917349971.234,"fa8dc9b96ec62f8db22c208a9f2cd20fd219f0115bfd51aaae023c56c3028f00"]}

src/main/java/com/acme/XXEVuln.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static void main(String[] args)
3131
saxTransformer(args[0]);
3232
withDom(args[1]);
3333
withDomButDisabled(args[2]);
34-
withReaderFactory(null);
34+
withReaderFactory(args[3]);
3535

3636
String sql = "select * from users where name= '" + args[0] + "'";
3737
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test");
@@ -78,8 +78,9 @@ public static Document withDomButDisabled(String xml)
7878
return db.parse(new InputSource(new StringReader(xml)));
7979
}
8080

81-
public static XMLReader withReaderFactory(XMLReaderFactory factory)
82-
throws ParserConfigurationException, IOException, SAXException {
83-
return factory.createXMLReader();
81+
public static void withReaderFactory(String xml)
82+
throws IOException, SAXException {
83+
XMLReader reader = XMLReaderFactory.createXMLReader();
84+
reader.parse(new InputSource(new StringReader(xml)));
8485
}
8586
}

src/main/java/com/acme/XXEVulnFixed.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static void main(String[] args)
3232
saxTransformer(args[0]);
3333
withDom(args[1]);
3434
withDomButDisabled(args[2]);
35-
withReaderFactory(null);
35+
withReaderFactory(args[3]);
3636

3737
String sql = "select * from users where name= '" + args[0] + "'";
3838
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test");
@@ -86,8 +86,9 @@ public static Document withDomButDisabled(String xml)
8686
return db.parse(new InputSource(new StringReader(xml)));
8787
}
8888

89-
public static XMLReader withReaderFactory(XMLReaderFactory factory)
90-
throws ParserConfigurationException, IOException, SAXException {
91-
return factory.createXMLReader();
89+
public static void withReaderFactory(String xml)
90+
throws IOException, SAXException {
91+
XMLReader reader = XMLReaderFactory.createXMLReader();
92+
reader.parse(new InputSource(new StringReader(xml)));
9293
}
9394
}

0 commit comments

Comments
 (0)