Skip to content

Commit 38c0557

Browse files
committed
Adjust test to moved and expanded stubs
1 parent ca4ef65 commit 38c0557

File tree

3 files changed

+35
-31
lines changed

3 files changed

+35
-31
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
edges
2-
| JSchOSInjectionTest.java:14:30:14:60 | getParameter(...) : String | JSchOSInjectionTest.java:26:48:26:64 | ... + ... |
3-
| JSchOSInjectionTest.java:38:30:38:60 | getParameter(...) : String | JSchOSInjectionTest.java:50:32:50:48 | ... + ... |
2+
| JSchOSInjectionTest.java:14:30:14:60 | getParameter(...) : String | JSchOSInjectionTest.java:27:52:27:68 | ... + ... |
3+
| JSchOSInjectionTest.java:40:30:40:60 | getParameter(...) : String | JSchOSInjectionTest.java:53:36:53:52 | ... + ... |
44
nodes
55
| JSchOSInjectionTest.java:14:30:14:60 | getParameter(...) : String | semmle.label | getParameter(...) : String |
6-
| JSchOSInjectionTest.java:26:48:26:64 | ... + ... | semmle.label | ... + ... |
7-
| JSchOSInjectionTest.java:38:30:38:60 | getParameter(...) : String | semmle.label | getParameter(...) : String |
8-
| JSchOSInjectionTest.java:50:32:50:48 | ... + ... | semmle.label | ... + ... |
6+
| JSchOSInjectionTest.java:27:52:27:68 | ... + ... | semmle.label | ... + ... |
7+
| JSchOSInjectionTest.java:40:30:40:60 | getParameter(...) : String | semmle.label | getParameter(...) : String |
8+
| JSchOSInjectionTest.java:53:36:53:52 | ... + ... | semmle.label | ... + ... |
99
subpaths
1010
#select
11-
| JSchOSInjectionTest.java:26:48:26:64 | ... + ... | JSchOSInjectionTest.java:14:30:14:60 | getParameter(...) : String | JSchOSInjectionTest.java:26:48:26:64 | ... + ... | $@ flows to here and is used in a command. | JSchOSInjectionTest.java:14:30:14:60 | getParameter(...) | User-provided value |
12-
| JSchOSInjectionTest.java:50:32:50:48 | ... + ... | JSchOSInjectionTest.java:38:30:38:60 | getParameter(...) : String | JSchOSInjectionTest.java:50:32:50:48 | ... + ... | $@ flows to here and is used in a command. | JSchOSInjectionTest.java:38:30:38:60 | getParameter(...) | User-provided value |
11+
| JSchOSInjectionTest.java:27:52:27:68 | ... + ... | JSchOSInjectionTest.java:14:30:14:60 | getParameter(...) : String | JSchOSInjectionTest.java:27:52:27:68 | ... + ... | $@ flows to here and is used in a command. | JSchOSInjectionTest.java:14:30:14:60 | getParameter(...) | User-provided value |
12+
| JSchOSInjectionTest.java:53:36:53:52 | ... + ... | JSchOSInjectionTest.java:40:30:40:60 | getParameter(...) : String | JSchOSInjectionTest.java:53:36:53:52 | ... + ... | $@ flows to here and is used in a command. | JSchOSInjectionTest.java:40:30:40:60 | getParameter(...) | User-provided value |

java/ql/test/experimental/query-tests/security/CWE-078/JSchOSInjectionTest.java

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
1717
config.put("StrictHostKeyChecking", "no");
1818

1919
JSch jsch = new JSch();
20-
Session session = jsch.getSession(user, host, 22);
21-
session.setPassword(password);
22-
session.setConfig(config);
23-
session.connect();
24-
25-
Channel channel = session.openChannel("exec");
26-
((ChannelExec) channel).setCommand("ping " + command);
27-
channel.setInputStream(null);
28-
((ChannelExec) channel).setErrStream(System.err);
29-
30-
channel.connect();
20+
try {
21+
Session session = jsch.getSession(user, host, 22);
22+
session.setPassword(password);
23+
session.setConfig(config);
24+
session.connect();
25+
26+
Channel channel = session.openChannel("exec");
27+
((ChannelExec) channel).setCommand("ping " + command);
28+
channel.setInputStream(null);
29+
((ChannelExec) channel).setErrStream(System.err);
30+
31+
channel.connect();
32+
} catch (JSchException e) { }
3133
}
3234

3335
protected void doPost(HttpServletRequest request, HttpServletResponse response)
@@ -41,16 +43,18 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
4143
config.put("StrictHostKeyChecking", "no");
4244

4345
JSch jsch = new JSch();
44-
Session session = jsch.getSession(user, host, 22);
45-
session.setPassword(password);
46-
session.setConfig(config);
47-
session.connect();
48-
49-
ChannelExec channel = (ChannelExec)session.openChannel("exec");
50-
channel.setCommand("ping " + command);
51-
channel.setInputStream(null);
52-
channel.setErrStream(System.err);
53-
54-
channel.connect();
46+
try {
47+
Session session = jsch.getSession(user, host, 22);
48+
session.setPassword(password);
49+
session.setConfig(config);
50+
session.connect();
51+
52+
ChannelExec channel = (ChannelExec)session.openChannel("exec");
53+
channel.setCommand("ping " + command);
54+
channel.setInputStream(null);
55+
channel.setErrStream(System.err);
56+
57+
channel.connect();
58+
} catch (JSchException e) { }
5559
}
56-
}
60+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/servlet-api-2.4:${testdir}/../../../stubs/jsch-0.1.55
1+
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/servlet-api-2.4:${testdir}/../../../../stubs/jsch-0.1.55
22

0 commit comments

Comments
 (0)