|
5 | 5 | import java.io.IOException;
|
6 | 6 | import java.io.InputStream;
|
7 | 7 | import java.io.OutputStream;
|
8 |
| -import java.net.InetAddress; |
9 | 8 | import java.net.URL;
|
10 | 9 | import java.nio.charset.Charset;
|
11 | 10 | import java.nio.file.Files;
|
12 | 11 | import java.nio.file.Path;
|
| 12 | + |
| 13 | +import javax.servlet.http.HttpServletRequest; |
13 | 14 | import javax.xml.transform.stream.StreamResult;
|
| 15 | + |
14 | 16 | import org.apache.commons.io.FileUtils;
|
15 | 17 | import org.apache.tools.ant.AntClassLoader;
|
16 | 18 | import org.apache.tools.ant.DirectoryScanner;
|
|
24 | 26 |
|
25 | 27 | public class Test {
|
26 | 28 |
|
27 |
| - private InetAddress address; |
| 29 | + private HttpServletRequest request; |
28 | 30 |
|
29 | 31 | public Object source() {
|
30 |
| - return address.getHostName(); |
| 32 | + return request.getParameter("source"); |
31 | 33 | }
|
32 | 34 |
|
33 | 35 | void test() throws IOException {
|
@@ -166,8 +168,8 @@ void test(AntClassLoader acl) {
|
166 | 168 | new LargeText((File) source(), null, false, false); // $ hasTaintFlow
|
167 | 169 | }
|
168 | 170 |
|
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"); |
171 | 173 | // GOOD: Use `contains` and `startsWith` to check if the path is safe
|
172 | 174 | if (!temp.contains("..") && temp.startsWith(root + "/")) {
|
173 | 175 | File file = new File(temp);
|
|
0 commit comments