Skip to content

Commit 97012aa

Browse files
author
Dave Wichers
committed
Reformat all the test cases, their code and associated .xml files.
1 parent e52cbe8 commit 97012aa

File tree

5,480 files changed

+247726
-236147
lines changed

Some content is hidden

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

5,480 files changed

+247726
-236147
lines changed
Lines changed: 74 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,96 @@
11
/**
2-
* OWASP Benchmark v1.2
3-
*
4-
* This file is part of the Open Web Application Security Project (OWASP)
5-
* Benchmark Project. For details, please see
6-
* <a href="https://owasp.org/www-project-benchmark/">https://owasp.org/www-project-benchmark/</a>.
7-
*
8-
* The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
9-
* of the GNU General Public License as published by the Free Software Foundation, version 2.
10-
*
11-
* The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
12-
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
* GNU General Public License for more details.
14-
*
15-
* @author Dave Wichers
16-
* @created 2015
17-
*/
18-
2+
* OWASP Benchmark v1.2
3+
*
4+
* <p>This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
5+
* details, please see <a
6+
* href="https://owasp.org/www-project-benchmark/">https://owasp.org/www-project-benchmark/</a>.
7+
*
8+
* <p>The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
9+
* of the GNU General Public License as published by the Free Software Foundation, version 2.
10+
*
11+
* <p>The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
12+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13+
* PURPOSE. See the GNU General Public License for more details.
14+
*
15+
* @author Dave Wichers
16+
* @created 2015
17+
*/
1918
package org.owasp.benchmark.testcode;
2019

2120
import java.io.IOException;
22-
2321
import javax.servlet.ServletException;
2422
import javax.servlet.annotation.WebServlet;
2523
import javax.servlet.http.HttpServlet;
2624
import javax.servlet.http.HttpServletRequest;
2725
import javax.servlet.http.HttpServletResponse;
2826

29-
@WebServlet(value="/pathtraver-00/BenchmarkTest00001")
27+
@WebServlet(value = "/pathtraver-00/BenchmarkTest00001")
3028
public class BenchmarkTest00001 extends HttpServlet {
31-
32-
private static final long serialVersionUID = 1L;
33-
34-
@Override
35-
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
36-
response.setContentType("text/html;charset=UTF-8");
37-
javax.servlet.http.Cookie userCookie = new javax.servlet.http.Cookie("BenchmarkTest00001", "FileName");
38-
userCookie.setMaxAge(60*3); //Store cookie for 3 minutes
39-
userCookie.setSecure(true);
40-
userCookie.setPath(request.getRequestURI());
41-
userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
42-
response.addCookie(userCookie);
43-
javax.servlet.RequestDispatcher rd = request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00001.html");
44-
rd.include(request, response);
45-
}
4629

47-
@Override
48-
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
49-
// some code
50-
response.setContentType("text/html;charset=UTF-8");
51-
30+
private static final long serialVersionUID = 1L;
31+
32+
@Override
33+
public void doGet(HttpServletRequest request, HttpServletResponse response)
34+
throws ServletException, IOException {
35+
response.setContentType("text/html;charset=UTF-8");
36+
javax.servlet.http.Cookie userCookie =
37+
new javax.servlet.http.Cookie("BenchmarkTest00001", "FileName");
38+
userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
39+
userCookie.setSecure(true);
40+
userCookie.setPath(request.getRequestURI());
41+
userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
42+
response.addCookie(userCookie);
43+
javax.servlet.RequestDispatcher rd =
44+
request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00001.html");
45+
rd.include(request, response);
46+
}
47+
48+
@Override
49+
public void doPost(HttpServletRequest request, HttpServletResponse response)
50+
throws ServletException, IOException {
51+
// some code
52+
response.setContentType("text/html;charset=UTF-8");
5253

53-
javax.servlet.http.Cookie[] theCookies = request.getCookies();
54-
55-
String param = "noCookieValueSupplied";
56-
if (theCookies != null) {
57-
for (javax.servlet.http.Cookie theCookie : theCookies) {
58-
if (theCookie.getName().equals("BenchmarkTest00001")) {
59-
param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
60-
break;
61-
}
62-
}
63-
}
54+
javax.servlet.http.Cookie[] theCookies = request.getCookies();
55+
56+
String param = "noCookieValueSupplied";
57+
if (theCookies != null) {
58+
for (javax.servlet.http.Cookie theCookie : theCookies) {
59+
if (theCookie.getName().equals("BenchmarkTest00001")) {
60+
param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
61+
break;
62+
}
63+
}
64+
}
6465

65-
6666
String fileName = null;
6767
java.io.FileInputStream fis = null;
6868

6969
try {
70-
fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + param;
71-
fis = new java.io.FileInputStream(new java.io.File(fileName));
72-
byte[] b = new byte[1000];
73-
int size = fis.read(b);
74-
response.getWriter().println(
75-
"The beginning of file: '" + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)
76-
+ "' is:\n\n" + org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b,0,size))
77-
);
70+
fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + param;
71+
fis = new java.io.FileInputStream(new java.io.File(fileName));
72+
byte[] b = new byte[1000];
73+
int size = fis.read(b);
74+
response.getWriter()
75+
.println(
76+
"The beginning of file: '"
77+
+ org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)
78+
+ "' is:\n\n"
79+
+ org.owasp
80+
.esapi
81+
.ESAPI
82+
.encoder()
83+
.encodeForHTML(new String(b, 0, size)));
7884
} catch (Exception e) {
7985
System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'");
80-
response.getWriter().println(
81-
"Problem getting FileInputStream: "
82-
+ org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage())
83-
);
86+
response.getWriter()
87+
.println(
88+
"Problem getting FileInputStream: "
89+
+ org.owasp
90+
.esapi
91+
.ESAPI
92+
.encoder()
93+
.encodeForHTML(e.getMessage()));
8494
} finally {
8595
if (fis != null) {
8696
try {
@@ -91,6 +101,5 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr
91101
}
92102
}
93103
}
94-
}
95-
104+
}
96105
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<test-metadata>
2-
<benchmark-version>1.2</benchmark-version>
3-
<category>pathtraver</category>
4-
<test-number>00001</test-number>
5-
<vulnerability>true</vulnerability>
6-
<cwe>22</cwe>
2+
<benchmark-version>1.2</benchmark-version>
3+
<category>pathtraver</category>
4+
<test-number>00001</test-number>
5+
<vulnerability>true</vulnerability>
6+
<cwe>22</cwe>
77
</test-metadata>
Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,92 @@
11
/**
2-
* OWASP Benchmark v1.2
3-
*
4-
* This file is part of the Open Web Application Security Project (OWASP)
5-
* Benchmark Project. For details, please see
6-
* <a href="https://owasp.org/www-project-benchmark/">https://owasp.org/www-project-benchmark/</a>.
7-
*
8-
* The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
9-
* of the GNU General Public License as published by the Free Software Foundation, version 2.
10-
*
11-
* The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
12-
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
* GNU General Public License for more details.
14-
*
15-
* @author Dave Wichers
16-
* @created 2015
17-
*/
18-
2+
* OWASP Benchmark v1.2
3+
*
4+
* <p>This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
5+
* details, please see <a
6+
* href="https://owasp.org/www-project-benchmark/">https://owasp.org/www-project-benchmark/</a>.
7+
*
8+
* <p>The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
9+
* of the GNU General Public License as published by the Free Software Foundation, version 2.
10+
*
11+
* <p>The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
12+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13+
* PURPOSE. See the GNU General Public License for more details.
14+
*
15+
* @author Dave Wichers
16+
* @created 2015
17+
*/
1918
package org.owasp.benchmark.testcode;
2019

2120
import java.io.IOException;
22-
2321
import javax.servlet.ServletException;
2422
import javax.servlet.annotation.WebServlet;
2523
import javax.servlet.http.HttpServlet;
2624
import javax.servlet.http.HttpServletRequest;
2725
import javax.servlet.http.HttpServletResponse;
2826

29-
@WebServlet(value="/pathtraver-00/BenchmarkTest00002")
27+
@WebServlet(value = "/pathtraver-00/BenchmarkTest00002")
3028
public class BenchmarkTest00002 extends HttpServlet {
31-
32-
private static final long serialVersionUID = 1L;
33-
34-
@Override
35-
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
36-
response.setContentType("text/html;charset=UTF-8");
37-
javax.servlet.http.Cookie userCookie = new javax.servlet.http.Cookie("BenchmarkTest00002", "FileName");
38-
userCookie.setMaxAge(60*3); //Store cookie for 3 minutes
39-
userCookie.setSecure(true);
40-
userCookie.setPath(request.getRequestURI());
41-
userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
42-
response.addCookie(userCookie);
43-
javax.servlet.RequestDispatcher rd = request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00002.html");
44-
rd.include(request, response);
45-
}
4629

47-
@Override
48-
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
49-
// some code
50-
response.setContentType("text/html;charset=UTF-8");
51-
30+
private static final long serialVersionUID = 1L;
31+
32+
@Override
33+
public void doGet(HttpServletRequest request, HttpServletResponse response)
34+
throws ServletException, IOException {
35+
response.setContentType("text/html;charset=UTF-8");
36+
javax.servlet.http.Cookie userCookie =
37+
new javax.servlet.http.Cookie("BenchmarkTest00002", "FileName");
38+
userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
39+
userCookie.setSecure(true);
40+
userCookie.setPath(request.getRequestURI());
41+
userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
42+
response.addCookie(userCookie);
43+
javax.servlet.RequestDispatcher rd =
44+
request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00002.html");
45+
rd.include(request, response);
46+
}
47+
48+
@Override
49+
public void doPost(HttpServletRequest request, HttpServletResponse response)
50+
throws ServletException, IOException {
51+
// some code
52+
response.setContentType("text/html;charset=UTF-8");
53+
54+
javax.servlet.http.Cookie[] theCookies = request.getCookies();
55+
56+
String param = "noCookieValueSupplied";
57+
if (theCookies != null) {
58+
for (javax.servlet.http.Cookie theCookie : theCookies) {
59+
if (theCookie.getName().equals("BenchmarkTest00002")) {
60+
param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
61+
break;
62+
}
63+
}
64+
}
5265

53-
javax.servlet.http.Cookie[] theCookies = request.getCookies();
54-
55-
String param = "noCookieValueSupplied";
56-
if (theCookies != null) {
57-
for (javax.servlet.http.Cookie theCookie : theCookies) {
58-
if (theCookie.getName().equals("BenchmarkTest00002")) {
59-
param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
60-
break;
61-
}
62-
}
63-
}
66+
String fileName = null;
67+
java.io.FileOutputStream fos = null;
6468

65-
66-
String fileName = null;
67-
java.io.FileOutputStream fos = null;
69+
try {
70+
fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + param;
6871

69-
try {
70-
fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + param;
71-
72-
fos = new java.io.FileOutputStream(fileName, false);
73-
response.getWriter().println(
74-
"Now ready to write to file: " + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)
75-
);
72+
fos = new java.io.FileOutputStream(fileName, false);
73+
response.getWriter()
74+
.println(
75+
"Now ready to write to file: "
76+
+ org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName));
7677

77-
} catch (Exception e) {
78-
System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'");
79-
// System.out.println("File exception caught and swallowed: " + e.getMessage());
80-
} finally {
81-
if (fos != null) {
82-
try {
83-
fos.close();
78+
} catch (Exception e) {
79+
System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'");
80+
// System.out.println("File exception caught and swallowed: " + e.getMessage());
81+
} finally {
82+
if (fos != null) {
83+
try {
84+
fos.close();
8485
fos = null;
85-
} catch (Exception e) {
86-
// we tried...
87-
}
88-
}
89-
}
90-
}
91-
86+
} catch (Exception e) {
87+
// we tried...
88+
}
89+
}
90+
}
91+
}
9292
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<test-metadata>
2-
<benchmark-version>1.2</benchmark-version>
3-
<category>pathtraver</category>
4-
<test-number>00002</test-number>
5-
<vulnerability>true</vulnerability>
6-
<cwe>22</cwe>
2+
<benchmark-version>1.2</benchmark-version>
3+
<category>pathtraver</category>
4+
<test-number>00002</test-number>
5+
<vulnerability>true</vulnerability>
6+
<cwe>22</cwe>
77
</test-metadata>

0 commit comments

Comments
 (0)