Skip to content

Commit d5f1538

Browse files
committed
first commit
0 parents  commit d5f1538

File tree

47,457 files changed

+7835598
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47,457 files changed

+7835598
-0
lines changed

Java/Main.java.template

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package testcasesupport;
2+
3+
import testcasesupport.*;
4+
5+
public class Main {
6+
7+
public static void main(String[] args) {
8+
9+
if(args.length != 0) {
10+
11+
if(args[0].equals("-h") || args[0].equals("--help")) {
12+
13+
System.err.println("To use this main, you can either run the program with no " +
14+
"command line arguments to run all test cases or you can specify one or more classes to test");
15+
System.err.println("For example:");
16+
System.err.println("java testcasesupport.Main testcases.CWE690_Unchecked_Return_Value_to_NULL_Pointer_Dereference.custom_function.CWE690_Unchecked_Return_Value_to_NULL_Pointer_Dereference__custom_function_01 testcases.CWE481_Assigning_instead_of_Comparing.bool.CWE481_Assigning_instead_of_Comparing__bool_01");
17+
System.exit(1);
18+
}
19+
20+
/* User supplied some class names on the command line, just use those with introspection
21+
*
22+
* String classNames[] = { "CWE481_Assigning_instead_of_Comparing__boolean_01",
23+
* "CWE476_Null_Pointer_Dereference__getProperty_01" };
24+
* could read class names from command line or use
25+
* http://sadun-util.sourceforge.net/api/org/sadun/util/
26+
* ClassPackageExplorer.html
27+
*/
28+
29+
for (String className : args) {
30+
31+
try {
32+
33+
/* String classNameWithPackage = "testcases." + className; */
34+
35+
/* IO.writeLine("classNameWithPackage = " + classNameWithPackage); */
36+
37+
Class<?> myClass = Class.forName(className);
38+
39+
AbstractTestCase myObject = (AbstractTestCase) myClass
40+
.newInstance();
41+
42+
myObject.runTest(className);
43+
44+
} catch (Exception ex) {
45+
46+
IO.writeLine("Could not run test for class " + className);
47+
ex.printStackTrace();
48+
49+
}
50+
51+
IO.writeLine(""); /* leave a blank line between classes */
52+
53+
}
54+
55+
} else {
56+
57+
/* No command line args were used, we want to run every testcase */
58+
59+
/* needed to separate these calls into other methods because
60+
we were running into the size limit Java has for a single method */
61+
runTestCWE1();
62+
runTestCWE2();
63+
runTestCWE3();
64+
runTestCWE4();
65+
runTestCWE5();
66+
runTestCWE6();
67+
runTestCWE7();
68+
runTestCWE8();
69+
runTestCWE9();
70+
}
71+
}
72+
73+
private static void runTestCWE1() {
74+
/* BEGIN-AUTOGENERATED-JAVA-TESTS-1 */
75+
/* END-AUTOGENERATED-JAVA-TESTS-1 */
76+
}
77+
78+
private static void runTestCWE2() {
79+
/* BEGIN-AUTOGENERATED-JAVA-TESTS-2 */
80+
/* END-AUTOGENERATED-JAVA-TESTS-2 */
81+
}
82+
83+
private static void runTestCWE3() {
84+
/* BEGIN-AUTOGENERATED-JAVA-TESTS-3 */
85+
/* END-AUTOGENERATED-JAVA-TESTS-3 */
86+
}
87+
88+
private static void runTestCWE4() {
89+
/* BEGIN-AUTOGENERATED-JAVA-TESTS-4 */
90+
/* END-AUTOGENERATED-JAVA-TESTS-4 */
91+
}
92+
93+
private static void runTestCWE5() {
94+
/* BEGIN-AUTOGENERATED-JAVA-TESTS-5 */
95+
/* END-AUTOGENERATED-JAVA-TESTS-5 */
96+
}
97+
98+
private static void runTestCWE6() {
99+
/* BEGIN-AUTOGENERATED-JAVA-TESTS-6 */
100+
/* END-AUTOGENERATED-JAVA-TESTS-6 */
101+
}
102+
103+
private static void runTestCWE7() {
104+
/* BEGIN-AUTOGENERATED-JAVA-TESTS-7 */
105+
/* END-AUTOGENERATED-JAVA-TESTS-7 */
106+
}
107+
108+
private static void runTestCWE8() {
109+
/* BEGIN-AUTOGENERATED-JAVA-TESTS-8 */
110+
/* END-AUTOGENERATED-JAVA-TESTS-8 */
111+
}
112+
113+
private static void runTestCWE9() {
114+
/* BEGIN-AUTOGENERATED-JAVA-TESTS-9 */
115+
/* END-AUTOGENERATED-JAVA-TESTS-9 */
116+
}
117+
}

Java/ServletMain.java.template

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
package testcasesupport;
2+
3+
import javax.servlet.http.*;
4+
5+
public class ServletMain extends HttpServlet {
6+
7+
private static final long serialVersionUID = 1L; /* needed since Servlets are serializable */
8+
9+
10+
11+
public void doPost(HttpServletRequest request, HttpServletResponse response) {
12+
doGet(request, response);
13+
}
14+
15+
public void doGet(HttpServletRequest request, HttpServletResponse response) {
16+
doGetCWE1(request, response);
17+
doGetCWE2(request, response);
18+
doGetCWE3(request, response);
19+
doGetCWE4(request, response);
20+
doGetCWE5(request, response);
21+
doGetCWE6(request, response);
22+
doGetCWE7(request, response);
23+
doGetCWE8(request, response);
24+
doGetCWE9(request, response);
25+
}
26+
27+
private static void doGetCWE1(HttpServletRequest request, HttpServletResponse response) {
28+
try {
29+
/* BEGIN-AUTOGENERATED-SERVLET-TESTS-1 */
30+
/* END-AUTOGENERATED-SERVLET-TESTS-1 */
31+
} catch (Throwable t) {
32+
33+
/* this will only happen on an IOException or something (the runTest for the test cases will catch any exceptions from the test cases). So, we just abort
34+
* and write to the console (since we can't write to the response without possibly throwing another exception)
35+
*/
36+
37+
System.out.println(
38+
" Caught thowable from doGetCWE1 ");
39+
40+
System.out.println(" Throwable's message = " + t.getMessage());
41+
42+
System.out.println("Stack trace below");
43+
44+
StackTraceElement stes[] = t.getStackTrace();
45+
46+
for (StackTraceElement ste : stes) {
47+
System.out.println(" " + ste.toString());
48+
}
49+
}
50+
}
51+
52+
private static void doGetCWE2(HttpServletRequest request, HttpServletResponse response) {
53+
try {
54+
/* BEGIN-AUTOGENERATED-SERVLET-TESTS-2 */
55+
/* END-AUTOGENERATED-SERVLET-TESTS-2 */
56+
} catch (Throwable t) {
57+
58+
/* this will only happen on an IOException or something (the runTest for the test cases will catch any exceptions from the test cases). So, we just abort
59+
* and write to the console (since we can't write to the response without possibly throwing another exception)
60+
*/
61+
62+
System.out.println(
63+
" Caught thowable from doGetCWE2 ");
64+
65+
System.out.println(" Throwable's message = " + t.getMessage());
66+
67+
System.out.println("Stack trace below");
68+
69+
StackTraceElement stes[] = t.getStackTrace();
70+
71+
for (StackTraceElement ste : stes) {
72+
System.out.println(" " + ste.toString());
73+
}
74+
}
75+
}
76+
77+
private static void doGetCWE3(HttpServletRequest request, HttpServletResponse response) {
78+
try {
79+
/* BEGIN-AUTOGENERATED-SERVLET-TESTS-3 */
80+
/* END-AUTOGENERATED-SERVLET-TESTS-3 */
81+
} catch (Throwable t) {
82+
83+
/* this will only happen on an IOException or something (the runTest for the test cases will catch any exceptions from the test cases). So, we just abort
84+
* and write to the console (since we can't write to the response without possibly throwing another exception)
85+
*/
86+
87+
System.out.println(
88+
" Caught thowable from doGetCWE3 ");
89+
90+
System.out.println(" Throwable's message = " + t.getMessage());
91+
92+
System.out.println("Stack trace below");
93+
94+
StackTraceElement stes[] = t.getStackTrace();
95+
96+
for (StackTraceElement ste : stes) {
97+
System.out.println(" " + ste.toString());
98+
}
99+
}
100+
}
101+
102+
private static void doGetCWE4(HttpServletRequest request, HttpServletResponse response) {
103+
try {
104+
/* BEGIN-AUTOGENERATED-SERVLET-TESTS-4 */
105+
/* END-AUTOGENERATED-SERVLET-TESTS-4 */
106+
} catch (Throwable t) {
107+
108+
/* this will only happen on an IOException or something (the runTest for the test cases will catch any exceptions from the test cases). So, we just abort
109+
* and write to the console (since we can't write to the response without possibly throwing another exception)
110+
*/
111+
112+
System.out.println(
113+
" Caught thowable from doGetCWE4 ");
114+
115+
System.out.println(" Throwable's message = " + t.getMessage());
116+
117+
System.out.println("Stack trace below");
118+
119+
StackTraceElement stes[] = t.getStackTrace();
120+
121+
for (StackTraceElement ste : stes) {
122+
System.out.println(" " + ste.toString());
123+
}
124+
}
125+
}
126+
127+
private static void doGetCWE5(HttpServletRequest request, HttpServletResponse response) {
128+
try {
129+
/* BEGIN-AUTOGENERATED-SERVLET-TESTS-5 */
130+
/* END-AUTOGENERATED-SERVLET-TESTS-5 */
131+
} catch (Throwable t) {
132+
133+
/* this will only happen on an IOException or something (the runTest for the test cases will catch any exceptions from the test cases). So, we just abort
134+
* and write to the console (since we can't write to the response without possibly throwing another exception)
135+
*/
136+
137+
System.out.println(
138+
" Caught thowable from doGetCWE5 ");
139+
140+
System.out.println(" Throwable's message = " + t.getMessage());
141+
142+
System.out.println("Stack trace below");
143+
144+
StackTraceElement stes[] = t.getStackTrace();
145+
146+
for (StackTraceElement ste : stes) {
147+
148+
System.out.println(" " + ste.toString());
149+
}
150+
}
151+
}
152+
153+
private static void doGetCWE6(HttpServletRequest request, HttpServletResponse response) {
154+
try {
155+
/* BEGIN-AUTOGENERATED-SERVLET-TESTS-6 */
156+
/* END-AUTOGENERATED-SERVLET-TESTS-6 */
157+
} catch (Throwable t) {
158+
159+
/* this will only happen on an IOException or something (the runTest for the test cases will catch any exceptions from the test cases). So, we just abort
160+
* and write to the console (since we can't write to the response without possibly throwing another exception)
161+
*/
162+
163+
System.out.println(
164+
" Caught thowable from doGetCWE6 ");
165+
166+
System.out.println(" Throwable's message = " + t.getMessage());
167+
168+
System.out.println("Stack trace below");
169+
170+
StackTraceElement stes[] = t.getStackTrace();
171+
172+
for (StackTraceElement ste : stes) {
173+
System.out.println(" " + ste.toString());
174+
}
175+
}
176+
}
177+
178+
private static void doGetCWE7(HttpServletRequest request, HttpServletResponse response) {
179+
try {
180+
/* BEGIN-AUTOGENERATED-SERVLET-TESTS-7 */
181+
/* END-AUTOGENERATED-SERVLET-TESTS-7 */
182+
} catch (Throwable t) {
183+
184+
/* this will only happen on an IOException or something (the runTest for the test cases will catch any exceptions from the test cases). So, we just abort
185+
* and write to the console (since we can't write to the response without possibly throwing another exception)
186+
*/
187+
188+
System.out.println(
189+
" Caught thowable from doGetCWE7 ");
190+
191+
System.out.println(" Throwable's message = " + t.getMessage());
192+
193+
System.out.println("Stack trace below");
194+
195+
StackTraceElement stes[] = t.getStackTrace();
196+
197+
for (StackTraceElement ste : stes) {
198+
System.out.println(" " + ste.toString());
199+
}
200+
}
201+
}
202+
203+
private static void doGetCWE8(HttpServletRequest request, HttpServletResponse response) {
204+
try {
205+
/* BEGIN-AUTOGENERATED-SERVLET-TESTS-8 */
206+
/* END-AUTOGENERATED-SERVLET-TESTS-8 */
207+
} catch (Throwable t) {
208+
209+
/* this will only happen on an IOException or something (the runTest for the test cases will catch any exceptions from the test cases). So, we just abort
210+
* and write to the console (since we can't write to the response without possibly throwing another exception)
211+
*/
212+
213+
System.out.println(
214+
" Caught thowable from doGetCWE8 ");
215+
216+
System.out.println(" Throwable's message = " + t.getMessage());
217+
218+
System.out.println("Stack trace below");
219+
220+
StackTraceElement stes[] = t.getStackTrace();
221+
222+
for (StackTraceElement ste : stes) {
223+
System.out.println(" " + ste.toString());
224+
}
225+
}
226+
}
227+
228+
private static void doGetCWE9(HttpServletRequest request, HttpServletResponse response) {
229+
try {
230+
/* BEGIN-AUTOGENERATED-SERVLET-TESTS-9 */
231+
/* END-AUTOGENERATED-SERVLET-TESTS-9 */
232+
} catch (Throwable t) {
233+
234+
/* this will only happen on an IOException or something (the runTest for the test cases will catch any exceptions from the test cases). So, we just abort
235+
* and write to the console (since we can't write to the response without possibly throwing another exception)
236+
*/
237+
238+
System.out.println(
239+
" Caught thowable from doGetCWE9 ");
240+
241+
System.out.println(" Throwable's message = " + t.getMessage());
242+
243+
System.out.println("Stack trace below");
244+
245+
StackTraceElement stes[] = t.getStackTrace();
246+
247+
for (StackTraceElement ste : stes) {
248+
System.out.println(" " + ste.toString());
249+
}
250+
}
251+
}
252+
}

Java/WebContent/META-INF/MANIFEST.MF

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Class-Path:
3+

0 commit comments

Comments
 (0)