Skip to content

Commit 162245f

Browse files
committed
Fix unrelated test using reverse DNS as source
1 parent 059ef42 commit 162245f

File tree

1 file changed

+7
-5
lines changed
  • java/ql/test/query-tests/security/CWE-022/semmle/tests

1 file changed

+7
-5
lines changed

java/ql/test/query-tests/security/CWE-022/semmle/tests/Test.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
import java.io.IOException;
66
import java.io.InputStream;
77
import java.io.OutputStream;
8-
import java.net.InetAddress;
98
import java.net.URL;
109
import java.nio.charset.Charset;
1110
import java.nio.file.Files;
1211
import java.nio.file.Path;
12+
13+
import javax.servlet.http.HttpServletRequest;
1314
import javax.xml.transform.stream.StreamResult;
15+
1416
import org.apache.commons.io.FileUtils;
1517
import org.apache.tools.ant.AntClassLoader;
1618
import org.apache.tools.ant.DirectoryScanner;
@@ -24,10 +26,10 @@
2426

2527
public class Test {
2628

27-
private InetAddress address;
29+
private HttpServletRequest request;
2830

2931
public Object source() {
30-
return address.getHostName();
32+
return request.getParameter("source");
3133
}
3234

3335
void test() throws IOException {
@@ -166,8 +168,8 @@ void test(AntClassLoader acl) {
166168
new LargeText((File) source(), null, false, false); // $ hasTaintFlow
167169
}
168170

169-
void doGet6(String root, InetAddress address) throws IOException {
170-
String temp = address.getHostName();
171+
void doGet6(String root, HttpServletRequest request) throws IOException {
172+
String temp = request.getParameter("source");
171173
// GOOD: Use `contains` and `startsWith` to check if the path is safe
172174
if (!temp.contains("..") && temp.startsWith(root + "/")) {
173175
File file = new File(temp);

0 commit comments

Comments
 (0)